vmm: make output for failed vmexits more threadsafe
authorBarret Rhoden <brho@cs.berkeley.edu>
Thu, 11 Apr 2019 21:10:04 +0000 (17:10 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 11 Apr 2019 21:13:58 +0000 (17:13 -0400)
If you had concurrent threads vmexit and the 2LS was unable to handle
the exits, you'd get an unintelligible mess.

This commit removes some unnecessary info - namely all of the info in
handle_vmexit() - and protects all of the output with a single lock.
It's not super elegant, and other printing can interfere with the
output, but it helps when there is a coordinated failure across numerous
threads.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
user/vmm/sched.c
user/vmm/vmexit.c

index 280e39e..c91753b 100644 (file)
@@ -421,10 +421,10 @@ static void __ctlr_entry(void)
 
        if (!handle_vmexit(cth->buddy)) {
                struct vm_trapframe *vm_tf = gth_to_vmtf(cth->buddy);
+               static struct spin_pdr_lock spew = SPINPDR_INITIALIZER;
 
-               fprintf(stderr, "vmm: handle_vmexit returned false\n");
-               fprintf(stderr,
-                       "Note: this may be a kernel module, not the kernel\n");
+               spin_pdr_lock(&spew);
+               fprintf(stderr, "vmm: handle_vmexit failed!\n");
                fprintf(stderr, "RSP was %p, ", (void *)vm_tf->tf_rsp);
                fprintf(stderr, "RIP was %p:\n", (void *)vm_tf->tf_rip);
                /* TODO: properly walk the kernel page tables to map the tf_rip
@@ -433,6 +433,7 @@ static void __ctlr_entry(void)
                 */
                hexdump(stderr, (void *)(vm_tf->tf_rip & 0x3fffffff), 16);
                showstatus(stderr, cth->buddy);
+               spin_pdr_unlock(&spew);
                exit(0);
        }
        /* We want to atomically yield and start/reenqueue our buddy.  We do so
index 0cbff79..331633a 100644 (file)
@@ -418,11 +418,6 @@ bool handle_vmexit(struct guest_thread *gth)
                /* TODO: just ignore these? */
                return TRUE;
        default:
-               fprintf(stderr,
-                       "VMM library: don't know how to handle exit %d\n",
-                       vm_tf->tf_exit_reason);
-               fprintf(stderr, "RIP %p, shutdown 0x%x\n", vm_tf->tf_rip,
-                       vm_tf->tf_exit_reason);
                return FALSE;
        }
 }