Print this page
13275 bhyve needs richer INIT/SIPI support
Reviewed by: Robert Mustacchi <rm@fingolfin.org>
Approved by: Gordon Ross <gordon.w.ross@gmail.com>

@@ -2736,12 +2736,11 @@
         load_dr7(vmxctx->host_dr7);
         write_rflags(read_rflags() | vmxctx->host_tf);
 }
 
 static int
-vmx_run(void *arg, int vcpu, uint64_t rip, pmap_t pmap,
-    struct vm_eventinfo *evinfo)
+vmx_run(void *arg, int vcpu, uint64_t rip, pmap_t pmap)
 {
         int rc, handled, launched;
         struct vmx *vmx;
         struct vm *vm;
         struct vmxctx *vmxctx;

@@ -2832,46 +2831,24 @@
                 if (inject_state == EIS_CAN_INJECT) {
                         inject_state = vmx_inject_vlapic(vmx, vcpu, vlapic);
                 }
 
                 /*
-                 * Check for vcpu suspension after injecting events because
-                 * vmx_inject_events() can suspend the vcpu due to a
-                 * triple fault.
+                 * Check for vCPU bail-out conditions.  This must be done after
+                 * vmx_inject_events() to detect a triple-fault condition.
                  */
-                if (vcpu_suspended(evinfo)) {
+                if (vcpu_entry_bailout_checks(vmx->vm, vcpu, rip)) {
                         enable_intr();
-                        vm_exit_suspended(vmx->vm, vcpu, rip);
                         break;
                 }
 
-                if (vcpu_runblocked(evinfo)) {
+                if (vcpu_run_state_pending(vm, vcpu)) {
                         enable_intr();
-                        vm_exit_runblock(vmx->vm, vcpu, rip);
+                        vm_exit_run_state(vmx->vm, vcpu, rip);
                         break;
                 }
 
-                if (vcpu_reqidle(evinfo)) {
-                        enable_intr();
-                        vm_exit_reqidle(vmx->vm, vcpu, rip);
-                        break;
-                }
-
-                if (vcpu_should_yield(vm, vcpu)) {
-                        enable_intr();
-                        vm_exit_astpending(vmx->vm, vcpu, rip);
-                        vmx_astpending_trace(vmx, vcpu, rip);
-                        handled = HANDLED;
-                        break;
-                }
-
-                if (vcpu_debugged(vm, vcpu)) {
-                        enable_intr();
-                        vm_exit_debug(vmx->vm, vcpu, rip);
-                        break;
-                }
-
                 /*
                  * If subsequent activity queued events which require injection
                  * handling, take another lap to handle them.
                  */
                 if (vmx_inject_recheck(vmx, vcpu, inject_state)) {

@@ -2983,23 +2960,16 @@
                 DTRACE_PROBE3(vmm__vexit, int, vcpu, uint64_t, rip,
                     uint32_t, exit_reason);
                 rip = vmexit->rip;
         } while (handled);
 
-        /*
-         * If a VM exit has been handled then the exitcode must be BOGUS
-         * If a VM exit is not handled then the exitcode must not be BOGUS
-         */
-        if ((handled && vmexit->exitcode != VM_EXITCODE_BOGUS) ||
-            (!handled && vmexit->exitcode == VM_EXITCODE_BOGUS)) {
-                panic("Mismatch between handled (%d) and exitcode (%d)",
-                    handled, vmexit->exitcode);
+        /* If a VM exit has been handled then the exitcode must be BOGUS */
+        if (handled && vmexit->exitcode != VM_EXITCODE_BOGUS) {
+                panic("Non-BOGUS exitcode (%d) unexpected for handled VM exit",
+                    vmexit->exitcode);
         }
 
-        if (!handled)
-                vmm_stat_incr(vm, vcpu, VMEXIT_USERSPACE, 1);
-
         VCPU_CTR1(vm, vcpu, "returning from vmx_run: exitcode %d",
             vmexit->exitcode);
 
         vmcs_clear(vmcs_pa);
         vmx_msr_guest_exit(vmx, vcpu);

@@ -3259,11 +3229,11 @@
         }
         return (0);
 }
 
 static int
-vmx_setdesc(void *arg, int vcpu, int seg, struct seg_desc *desc)
+vmx_setdesc(void *arg, int vcpu, int seg, const struct seg_desc *desc)
 {
         int hostcpu, running;
         struct vmx *vmx = arg;
         uint32_t base, limit, access;