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>

@@ -441,10 +441,13 @@
         case VM_SET_INTINFO:
         case VM_GET_INTINFO:
         case VM_RESTART_INSTRUCTION:
         case VM_SET_KERNEMU_DEV:
         case VM_GET_KERNEMU_DEV:
+        case VM_RESET_CPU:
+        case VM_GET_RUN_STATE:
+        case VM_SET_RUN_STATE:
                 /*
                  * Copy in the ID of the vCPU chosen for this operation.
                  * Since a nefarious caller could update their struct between
                  * this locking and when the rest of the ioctl data is copied
                  * in, it is _critical_ that this local 'vcpu' variable be used

@@ -987,10 +990,49 @@
                         error = vm_set_register(sc->vmm_vm, vcpu, regnums[i],
                             regvals[i]);
                 }
                 break;
         }
+        case VM_RESET_CPU: {
+                struct vm_vcpu_reset vvr;
+
+                if (ddi_copyin(datap, &vvr, sizeof (vvr), md)) {
+                        error = EFAULT;
+                        break;
+                }
+                if (vvr.kind != VRK_RESET && vvr.kind != VRK_INIT) {
+                        error = EINVAL;
+                }
+
+                error = vcpu_arch_reset(sc->vmm_vm, vcpu, vvr.kind == VRK_INIT);
+                break;
+        }
+        case VM_GET_RUN_STATE: {
+                struct vm_run_state vrs;
+
+                bzero(&vrs, sizeof (vrs));
+                error = vm_get_run_state(sc->vmm_vm, vcpu, &vrs.state,
+                    &vrs.sipi_vector);
+                if (error == 0) {
+                        if (ddi_copyout(&vrs, datap, sizeof (vrs), md)) {
+                                error = EFAULT;
+                                break;
+                        }
+                }
+                break;
+        }
+        case VM_SET_RUN_STATE: {
+                struct vm_run_state vrs;
+
+                if (ddi_copyin(datap, &vrs, sizeof (vrs), md)) {
+                        error = EFAULT;
+                        break;
+                }
+                error = vm_set_run_state(sc->vmm_vm, vcpu, vrs.state,
+                    vrs.sipi_vector);
+                break;
+        }
 
         case VM_SET_KERNEMU_DEV:
         case VM_GET_KERNEMU_DEV: {
                 struct vm_readwrite_kernemu_device kemu;
                 size_t size = 0;