vmm: allow a vmm to override the vmcall function
authorRonald G. Minnich <rminnich@gmail.com>
Tue, 29 Nov 2016 01:23:45 +0000 (17:23 -0800)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 29 Nov 2016 16:12:43 +0000 (11:12 -0500)
Add a vmcall struct to the guest thread struct. This
allows us, on a guest thread by guest thread basis, to
support vmcalls.

I've tested this with dune and it works fine.
Longer term, we may want to define an ops structure
but I think that's rushing it a bit.

Change-Id: Ic381f0e70946ba2396303e5d6428bc999ec4b6dd
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
user/vmm/include/vmm/sched.h
user/vmm/vmexit.c

index a098cf7..567a77e 100644 (file)
@@ -33,6 +33,8 @@ struct guest_thread {
        bool                                            halt_exit;
        uth_mutex_t                                     halt_mtx;
        uth_cond_var_t                          halt_cv;
+       // TODO: work out a real ops strategy.
+       bool (*vmcall)(struct guest_thread *gth, struct vm_trapframe *);
 };
 
 struct ctlr_thread {
index 52479cd..3e8700b 100644 (file)
@@ -126,6 +126,8 @@ static bool handle_vmcall(struct guest_thread *gth)
        struct vm_trapframe *vm_tf = gth_to_vmtf(gth);
        uint8_t byte;
 
+       if (gth->vmcall)
+               return gth->vmcall(gth, vm_tf);
        byte = vm_tf->tf_rdi;
        printf("%c", byte);
        if (byte == '\n')