libmicrokit: add API for resuming x86 VCPU#431
Conversation
a0cf31f to
862ed5c
Compare
58c7a1e to
764504a
Compare
764504a to
3cccb71
Compare
|
For the record: I'm not entirely convinced this is the best way the API could look/behave, it feels quite ugly. |
59d8991 to
190c9d6
Compare
Yes I agree, as discussed internally, there isn't a clean way to integrate the way virtualisation works on x86 seL4 with the Microkit event loop. Unless we allow the user to override the |
Why can't the Microkit event loop be x86 virtualisation aware? Or have a x86 version of the event loop that calls VMEnter instead of recv. You can add a special function that enters this x86 virtualisation aware event loop and never returns. Then the user only needs to do one special call during init once. If the tooling is aware of all this, it could do this automatically on return of the init function too and the user wouldn't need to do anything special (other than being aware that a VCPU task runs both normal code and a VM). |
I've done some thinking on what you've said and I like it a lot. My take on your idea is that we will have one API that looks like: static void microkit_x86_vcpu_on(uint64_t rip, uint64_t prim_proc_ctl, uint32_t irq_info)The user calls this before returning from For argument passing to Under this model, the user just need to be aware that a PD with a VCPU will be executing guest code if Edit: it maybe beneficial to have a
This would be ideal, but VCPUs are resumed by user code at runtime so I'm unsure how this could fit in. |
190c9d6 to
e77d9df
Compare
microkit_vcpu_x86_deferred_resume() callBecause you cannot pass an endpoint object with the syscall. Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
Add: microkit_vcpu_x86_on() microkit_vcpu_x86_off() Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
Add microkit_vcpu_x86_on() microkit_vcpu_x86_off() Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
e77d9df to
f770036
Compare
Resuming a VCPU is just calling Considering x86 VCPU tasks can't receive IPC calls anyway, but only notifications, for Microkit it would make sense to model non-notification returns from VMEnter as Protected procedure calls. Or be more specific and add another callback function for those. (I'm ignoring the practical implementation split between generic Microkit and libvm or whatever virtualisation aware code you have. For a more virtualisation agnostic Microkit it would help to move stuff more into libraries and less in the Microkit framework.) |
Depends on seL4/seL4#1534, I've worked around this for now by including
vmenter.hinlibmicrokit/include/microkit.h.Previously, the Microkit event handler had no mechanism on x86 to resume a vCPU while simultaneously waiting for an incoming notification. This PR adds
microkit_vcpu_x86_deferred_resume()to libmicrokit, providing a cleaner way to integrate x86 vCPU resumption with the Microkit event handler.Due to a kernel limitation in
void NORETURN slowpath(syscall_t syscall)ofsrc/arch/x86/c_traps.c, only the VMM's TCB bound Notification is checked for a pending Notification. An endpoint object can't passed toseL4_VMEnter()so PPCs won't work while the VCPU is running. Technically, PPCs still work if the VCPU isn't resumed, but I feel like we should not expose this footgun to users.