On 2013-07-17 12:31, Gleb Natapov wrote: >>>> I think the current version is mostly fine, but I'd prefer to move the >>>> inline functions to vmx.h, and the tests to a separate file. Perhaps >>>> lib/x86/vmx.h, lib/x86/vmx.c, and x86/vmx.c. >>>> >>>> All knowledge of setjmp and longjmp should then be hidden in >>>> lib/x86/vmx.c, perhaps by putting >>>> >>>> if (setjmp(env) == 0) { >>>> vmx_run(); >>>> return 1; >>>> } else >>>> return 0; >>>> >>>> or something like that in a new lib/x86/vmx.c function. >>>> >>> Use of setjmp to redirect control flow here is absolutely unnecessary. HW >>> provides you with capability to return control flow back where you want >>> it but you ignore it and save/restore context by yourself. Why?! Just tell >>> HW to return to the point you want to return to! >> >> This is not super-optimized kernel code, this has to be readable first >> and foremost. In C, the way to do global jumps and save/restore context >> is setjmp/longjmp. > If you do it right there will be _not point in doing_ global jumps. The > control flow will be linear, the code will be much more readable. Indeed. Arthur is already working on a setjmp/longjmp free version, let's wait for the outcome. Jan
Attachment:
signature.asc
Description: OpenPGP digital signature