Lines Matching +full:vm +full:- +full:map

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
46 #include <vm/vm.h>
47 #include <vm/vm_object.h>
48 #include <vm/vm_page.h>
49 #include <vm/pmap.h>
50 #include <vm/vm_map.h>
51 #include <vm/vm_extern.h>
52 #include <vm/vm_param.h>
60 #include <machine/vm.h>
86 struct vm *vm; /* (o) */ member
87 void *cookie; /* (i) cpu-specific data */
91 #define vcpu_lock_initialized(v) mtx_initialized(&((v)->mtx))
92 #define vcpu_lock_init(v) mtx_init(&((v)->mtx), "vcpu lock", 0, MTX_SPIN)
93 #define vcpu_lock_destroy(v) mtx_destroy(&((v)->mtx))
94 #define vcpu_lock(v) mtx_lock_spin(&((v)->mtx))
95 #define vcpu_unlock(v) mtx_unlock_spin(&((v)->mtx))
96 #define vcpu_assert_locked(v) mtx_assert(&((v)->mtx), MA_OWNED)
117 * (o) initialized the first time the VM is created
118 * (i) initialized when VM is created and when it is reinitialized
121 struct vm { struct
122 void *cookie; /* (i) cpu-specific data */
125 int suspend; /* (i) stop VM execution */
136 /* The following describe the vm cpu topology */ argument
221 VMM_STAT(VMEXIT_COUNT, "total number of vm exits");
233 VMM_STAT(VMEXIT_SS, "number of vmexits for a single-step exception");
241 #define VM_MAXCPU MIN(0xffff - 1, CPU_SETSIZE)
247 regs->field = vmm_arch_regs_masks.field; \ in vmm_regs_init()
248 if (!get_kernel_reg_masked(reg, &regs->field, masks->field)) \ in vmm_regs_init()
249 regs->field = 0; \ in vmm_regs_init()
270 vmmops_vcpu_cleanup(vcpu->cookie); in vcpu_cleanup()
271 vcpu->cookie = NULL; in vcpu_cleanup()
273 vmm_stat_free(vcpu->stats); in vcpu_cleanup()
274 fpu_save_area_free(vcpu->guestfpu); in vcpu_cleanup()
280 vcpu_alloc(struct vm *vm, int vcpu_id) in vcpu_alloc() argument
284 KASSERT(vcpu_id >= 0 && vcpu_id < vm->maxcpus, in vcpu_alloc()
289 vcpu->state = VCPU_IDLE; in vcpu_alloc()
290 vcpu->hostcpu = NOCPU; in vcpu_alloc()
291 vcpu->vcpuid = vcpu_id; in vcpu_alloc()
292 vcpu->vm = vm; in vcpu_alloc()
293 vcpu->guestfpu = fpu_save_area_alloc(); in vcpu_alloc()
294 vcpu->stats = vmm_stat_alloc(); in vcpu_alloc()
301 vcpu->cookie = vmmops_vcpu_init(vcpu->vm->cookie, vcpu, vcpu->vcpuid); in vcpu_init()
302 MPASS(vcpu->cookie != NULL); in vcpu_init()
303 fpu_save_area_reset(vcpu->guestfpu); in vcpu_init()
304 vmm_stat_init(vcpu->stats); in vcpu_init()
310 return (&vcpu->exitinfo); in vm_exitinfo()
357 * Something bad happened - prevent new in vmm_handler()
380 * - HYP initialization requires smp_rendezvous() and therefore must happen
382 * - vmm device initialization requires an initialized devfs.
388 vm_init(struct vm *vm, bool create) in vm_init() argument
392 vm->cookie = vmmops_init(vm, vmspace_pmap(vm->vmspace)); in vm_init()
393 MPASS(vm->cookie != NULL); in vm_init()
395 CPU_ZERO(&vm->active_cpus); in vm_init()
396 CPU_ZERO(&vm->debug_cpus); in vm_init()
398 vm->suspend = 0; in vm_init()
399 CPU_ZERO(&vm->suspended_cpus); in vm_init()
401 memset(vm->mmio_region, 0, sizeof(vm->mmio_region)); in vm_init()
402 memset(vm->special_reg, 0, sizeof(vm->special_reg)); in vm_init()
405 for (i = 0; i < vm->maxcpus; i++) { in vm_init()
406 if (vm->vcpu[i] != NULL) in vm_init()
407 vcpu_init(vm->vcpu[i]); in vm_init()
413 vm_disable_vcpu_creation(struct vm *vm) in vm_disable_vcpu_creation() argument
415 sx_xlock(&vm->vcpus_init_lock); in vm_disable_vcpu_creation()
416 vm->dying = true; in vm_disable_vcpu_creation()
417 sx_xunlock(&vm->vcpus_init_lock); in vm_disable_vcpu_creation()
421 vm_alloc_vcpu(struct vm *vm, int vcpuid) in vm_alloc_vcpu() argument
425 if (vcpuid < 0 || vcpuid >= vm_get_maxcpus(vm)) in vm_alloc_vcpu()
429 if (vcpuid >= vgic_max_cpu_count(vm->cookie)) in vm_alloc_vcpu()
433 atomic_load_acq_ptr((uintptr_t *)&vm->vcpu[vcpuid]); in vm_alloc_vcpu()
437 sx_xlock(&vm->vcpus_init_lock); in vm_alloc_vcpu()
438 vcpu = vm->vcpu[vcpuid]; in vm_alloc_vcpu()
439 if (vcpu == NULL && !vm->dying) { in vm_alloc_vcpu()
440 vcpu = vcpu_alloc(vm, vcpuid); in vm_alloc_vcpu()
447 atomic_store_rel_ptr((uintptr_t *)&vm->vcpu[vcpuid], in vm_alloc_vcpu()
450 sx_xunlock(&vm->vcpus_init_lock); in vm_alloc_vcpu()
455 vm_slock_vcpus(struct vm *vm) in vm_slock_vcpus() argument
457 sx_slock(&vm->vcpus_init_lock); in vm_slock_vcpus()
461 vm_unlock_vcpus(struct vm *vm) in vm_unlock_vcpus() argument
463 sx_unlock(&vm->vcpus_init_lock); in vm_unlock_vcpus()
467 vm_create(const char *name, struct vm **retvm) in vm_create()
469 struct vm *vm; in vm_create() local
486 vm = malloc(sizeof(struct vm), M_VMM, M_WAITOK | M_ZERO); in vm_create()
487 strcpy(vm->name, name); in vm_create()
488 vm->vmspace = vmspace; in vm_create()
489 vm_mem_init(&vm->mem); in vm_create()
490 sx_init(&vm->vcpus_init_lock, "vm vcpus"); in vm_create()
492 vm->sockets = 1; in vm_create()
493 vm->cores = 1; /* XXX backwards compatibility */ in vm_create()
494 vm->threads = 1; /* XXX backwards compatibility */ in vm_create()
495 vm->maxcpus = vm_maxcpu; in vm_create()
497 vm->vcpu = malloc(sizeof(*vm->vcpu) * vm->maxcpus, M_VMM, in vm_create()
500 vm_init(vm, true); in vm_create()
502 *retvm = vm; in vm_create()
507 vm_get_topology(struct vm *vm, uint16_t *sockets, uint16_t *cores, in vm_get_topology() argument
510 *sockets = vm->sockets; in vm_get_topology()
511 *cores = vm->cores; in vm_get_topology()
512 *threads = vm->threads; in vm_get_topology()
513 *maxcpus = vm->maxcpus; in vm_get_topology()
517 vm_get_maxcpus(struct vm *vm) in vm_get_maxcpus() argument
519 return (vm->maxcpus); in vm_get_maxcpus()
523 vm_set_topology(struct vm *vm, uint16_t sockets, uint16_t cores, in vm_set_topology() argument
527 if ((sockets * cores * threads) > vm->maxcpus) in vm_set_topology()
529 vm->sockets = sockets; in vm_set_topology()
530 vm->cores = cores; in vm_set_topology()
531 vm->threads = threads; in vm_set_topology()
536 vm_cleanup(struct vm *vm, bool destroy) in vm_cleanup() argument
542 vm_xlock_memsegs(vm); in vm_cleanup()
543 pmap = vmspace_pmap(vm->vmspace); in vm_cleanup()
548 MPASS(cpuid_to_pcpu[i]->pc_curvmpmap != pmap); in vm_cleanup()
551 vm_assert_memseg_xlocked(vm); in vm_cleanup()
554 vgic_detach_from_vm(vm->cookie); in vm_cleanup()
556 for (i = 0; i < vm->maxcpus; i++) { in vm_cleanup()
557 if (vm->vcpu[i] != NULL) in vm_cleanup()
558 vcpu_cleanup(vm->vcpu[i], destroy); in vm_cleanup()
561 vmmops_cleanup(vm->cookie); in vm_cleanup()
563 vm_mem_cleanup(vm); in vm_cleanup()
565 vm_mem_destroy(vm); in vm_cleanup()
567 vmmops_vmspace_free(vm->vmspace); in vm_cleanup()
568 vm->vmspace = NULL; in vm_cleanup()
570 for (i = 0; i < vm->maxcpus; i++) in vm_cleanup()
571 free(vm->vcpu[i], M_VMM); in vm_cleanup()
572 free(vm->vcpu, M_VMM); in vm_cleanup()
573 sx_destroy(&vm->vcpus_init_lock); in vm_cleanup()
578 vm_destroy(struct vm *vm) in vm_destroy() argument
580 vm_cleanup(vm, true); in vm_destroy()
581 free(vm, M_VMM); in vm_destroy()
585 vm_reinit(struct vm *vm) in vm_reinit() argument
592 if (CPU_CMP(&vm->suspended_cpus, &vm->active_cpus) == 0) { in vm_reinit()
593 vm_cleanup(vm, false); in vm_reinit()
594 vm_init(vm, false); in vm_reinit()
604 vm_name(struct vm *vm) in vm_name() argument
606 return (vm->name); in vm_name()
613 return (vmmops_gla2gpa(vcpu->cookie, paging, gla, prot, gpa, is_fault)); in vm_gla2gpa_nofault()
696 vm_register_reg_handler(struct vm *vm, uint64_t iss, uint64_t mask, in vm_register_reg_handler() argument
701 for (i = 0; i < nitems(vm->special_reg); i++) { in vm_register_reg_handler()
702 if (vm->special_reg[i].esr_iss == 0 && in vm_register_reg_handler()
703 vm->special_reg[i].esr_mask == 0) { in vm_register_reg_handler()
704 vm->special_reg[i].esr_iss = iss; in vm_register_reg_handler()
705 vm->special_reg[i].esr_mask = mask; in vm_register_reg_handler()
706 vm->special_reg[i].reg_read = reg_read; in vm_register_reg_handler()
707 vm->special_reg[i].reg_write = reg_write; in vm_register_reg_handler()
708 vm->special_reg[i].arg = arg; in vm_register_reg_handler()
717 vm_deregister_reg_handler(struct vm *vm, uint64_t iss, uint64_t mask) in vm_deregister_reg_handler() argument
721 for (i = 0; i < nitems(vm->special_reg); i++) { in vm_deregister_reg_handler()
722 if (vm->special_reg[i].esr_iss == iss && in vm_deregister_reg_handler()
723 vm->special_reg[i].esr_mask == mask) { in vm_deregister_reg_handler()
724 memset(&vm->special_reg[i], 0, in vm_deregister_reg_handler()
725 sizeof(vm->special_reg[i])); in vm_deregister_reg_handler()
737 struct vm *vm; in vm_handle_reg_emul() local
742 vm = vcpu->vm; in vm_handle_reg_emul()
743 vme = &vcpu->exitinfo; in vm_handle_reg_emul()
744 vre = &vme->u.reg_emul.vre; in vm_handle_reg_emul()
746 for (i = 0; i < nitems(vm->special_reg); i++) { in vm_handle_reg_emul()
747 if (vm->special_reg[i].esr_iss == 0 && in vm_handle_reg_emul()
748 vm->special_reg[i].esr_mask == 0) in vm_handle_reg_emul()
751 if ((vre->inst_syndrome & vm->special_reg[i].esr_mask) == in vm_handle_reg_emul()
752 vm->special_reg[i].esr_iss) { in vm_handle_reg_emul()
754 vm->special_reg[i].reg_read, in vm_handle_reg_emul()
755 vm->special_reg[i].reg_write, in vm_handle_reg_emul()
756 vm->special_reg[i].arg); in vm_handle_reg_emul()
764 if ((vre->inst_syndrome & vmm_special_regs[i].esr_mask) == in vm_handle_reg_emul()
783 vm_register_inst_handler(struct vm *vm, uint64_t start, uint64_t size, in vm_register_inst_handler() argument
788 for (i = 0; i < nitems(vm->mmio_region); i++) { in vm_register_inst_handler()
789 if (vm->mmio_region[i].start == 0 && in vm_register_inst_handler()
790 vm->mmio_region[i].end == 0) { in vm_register_inst_handler()
791 vm->mmio_region[i].start = start; in vm_register_inst_handler()
792 vm->mmio_region[i].end = start + size; in vm_register_inst_handler()
793 vm->mmio_region[i].read = mmio_read; in vm_register_inst_handler()
794 vm->mmio_region[i].write = mmio_write; in vm_register_inst_handler()
803 vm_deregister_inst_handler(struct vm *vm, uint64_t start, uint64_t size) in vm_deregister_inst_handler() argument
807 for (i = 0; i < nitems(vm->mmio_region); i++) { in vm_deregister_inst_handler()
808 if (vm->mmio_region[i].start == start && in vm_deregister_inst_handler()
809 vm->mmio_region[i].end == start + size) { in vm_deregister_inst_handler()
810 memset(&vm->mmio_region[i], 0, in vm_deregister_inst_handler()
811 sizeof(vm->mmio_region[i])); in vm_deregister_inst_handler()
816 panic("%s: Invalid MMIO region: %lx - %lx", __func__, start, in vm_deregister_inst_handler()
823 struct vm *vm; in vm_handle_inst_emul() local
832 vm = vcpu->vm; in vm_handle_inst_emul()
833 hyp = vm->cookie; in vm_handle_inst_emul()
834 if (!hyp->vgic_attached) in vm_handle_inst_emul()
837 vme = &vcpu->exitinfo; in vm_handle_inst_emul()
838 vie = &vme->u.inst_emul.vie; in vm_handle_inst_emul()
839 paging = &vme->u.inst_emul.paging; in vm_handle_inst_emul()
841 fault_ipa = vme->u.inst_emul.gpa; in vm_handle_inst_emul()
844 for (i = 0; i < nitems(vm->mmio_region); i++) { in vm_handle_inst_emul()
845 if (vm->mmio_region[i].start <= fault_ipa && in vm_handle_inst_emul()
846 vm->mmio_region[i].end > fault_ipa) { in vm_handle_inst_emul()
847 vmr = &vm->mmio_region[i]; in vm_handle_inst_emul()
855 vmr->read, vmr->write, retu); in vm_handle_inst_emul()
864 vm_suspend(struct vm *vm, enum vm_suspend_how how) in vm_suspend() argument
871 if (atomic_cmpset_int(&vm->suspend, 0, how) == 0) { in vm_suspend()
872 VM_CTR2(vm, "virtual machine already suspended %d/%d", in vm_suspend()
873 vm->suspend, how); in vm_suspend()
877 VM_CTR1(vm, "virtual machine successfully suspended %d", how); in vm_suspend()
882 for (i = 0; i < vm->maxcpus; i++) { in vm_suspend()
883 if (CPU_ISSET(i, &vm->active_cpus)) in vm_suspend()
884 vcpu_notify_event(vm_vcpu(vm, i)); in vm_suspend()
893 struct vm *vm = vcpu->vm; in vm_exit_suspended() local
896 KASSERT(vm->suspend > VM_SUSPEND_NONE && vm->suspend < VM_SUSPEND_LAST, in vm_exit_suspended()
897 ("vm_exit_suspended: invalid suspend type %d", vm->suspend)); in vm_exit_suspended()
900 vmexit->pc = pc; in vm_exit_suspended()
901 vmexit->inst_length = 4; in vm_exit_suspended()
902 vmexit->exitcode = VM_EXITCODE_SUSPENDED; in vm_exit_suspended()
903 vmexit->u.suspended.how = vm->suspend; in vm_exit_suspended()
912 vmexit->pc = pc; in vm_exit_debug()
913 vmexit->inst_length = 4; in vm_exit_debug()
914 vmexit->exitcode = VM_EXITCODE_DEBUG; in vm_exit_debug()
920 struct vm *vm = vcpu->vm; in vm_activate_cpu() local
922 if (CPU_ISSET(vcpu->vcpuid, &vm->active_cpus)) in vm_activate_cpu()
925 CPU_SET_ATOMIC(vcpu->vcpuid, &vm->active_cpus); in vm_activate_cpu()
931 vm_suspend_cpu(struct vm *vm, struct vcpu *vcpu) in vm_suspend_cpu() argument
934 vm->debug_cpus = vm->active_cpus; in vm_suspend_cpu()
935 for (int i = 0; i < vm->maxcpus; i++) { in vm_suspend_cpu()
936 if (CPU_ISSET(i, &vm->active_cpus)) in vm_suspend_cpu()
937 vcpu_notify_event(vm_vcpu(vm, i)); in vm_suspend_cpu()
940 if (!CPU_ISSET(vcpu->vcpuid, &vm->active_cpus)) in vm_suspend_cpu()
943 CPU_SET_ATOMIC(vcpu->vcpuid, &vm->debug_cpus); in vm_suspend_cpu()
950 vm_resume_cpu(struct vm *vm, struct vcpu *vcpu) in vm_resume_cpu() argument
954 CPU_ZERO(&vm->debug_cpus); in vm_resume_cpu()
956 if (!CPU_ISSET(vcpu->vcpuid, &vm->debug_cpus)) in vm_resume_cpu()
959 CPU_CLR_ATOMIC(vcpu->vcpuid, &vm->debug_cpus); in vm_resume_cpu()
968 return (CPU_ISSET(vcpu->vcpuid, &vcpu->vm->debug_cpus)); in vcpu_debugged()
972 vm_active_cpus(struct vm *vm) in vm_active_cpus() argument
975 return (vm->active_cpus); in vm_active_cpus()
979 vm_debug_cpus(struct vm *vm) in vm_debug_cpus() argument
982 return (vm->debug_cpus); in vm_debug_cpus()
986 vm_suspended_cpus(struct vm *vm) in vm_suspended_cpus() argument
989 return (vm->suspended_cpus); in vm_suspended_cpus()
997 return (vcpu->stats); in vcpu_stats()
1003 * - If the vcpu thread is sleeping then it is woken up.
1004 * - If the vcpu is running on a different host_cpu then an IPI will be directed
1012 hostcpu = vcpu->hostcpu; in vcpu_notify_event_locked()
1013 if (vcpu->state == VCPU_RUNNING) { in vcpu_notify_event_locked()
1027 "with hostcpu %d", vcpu->state, hostcpu)); in vcpu_notify_event_locked()
1028 if (vcpu->state == VCPU_SLEEPING) in vcpu_notify_event_locked()
1042 vm_vmspace(struct vm *vm) in vm_vmspace() argument
1044 return (vm->vmspace); in vm_vmspace()
1048 vm_mem(struct vm *vm) in vm_mem() argument
1050 return (&vm->mem); in vm_mem()
1058 vfp_save_state(curthread, curthread->td_pcb); in restore_guest_fpustate()
1059 /* Ensure the VFP state will be re-loaded when exiting the guest */ in restore_guest_fpustate()
1064 vfp_restore(vcpu->guestfpu); in restore_guest_fpustate()
1082 vfp_store(vcpu->guestfpu); in save_guest_fpustate()
1102 while (vcpu->state != VCPU_IDLE) { in vcpu_set_state_locked()
1104 msleep_spin(&vcpu->state, &vcpu->mtx, "vmstat", hz); in vcpu_set_state_locked()
1107 KASSERT(vcpu->state != VCPU_IDLE, ("invalid transition from " in vcpu_set_state_locked()
1111 if (vcpu->state == VCPU_RUNNING) { in vcpu_set_state_locked()
1112 KASSERT(vcpu->hostcpu == curcpu, ("curcpu %d and hostcpu %d " in vcpu_set_state_locked()
1113 "mismatch for running vcpu", curcpu, vcpu->hostcpu)); in vcpu_set_state_locked()
1115 KASSERT(vcpu->hostcpu == NOCPU, ("Invalid hostcpu %d for a " in vcpu_set_state_locked()
1116 "vcpu that is not running", vcpu->hostcpu)); in vcpu_set_state_locked()
1121 * IDLE -> FROZEN -> IDLE in vcpu_set_state_locked()
1122 * FROZEN -> RUNNING -> FROZEN in vcpu_set_state_locked()
1123 * FROZEN -> SLEEPING -> FROZEN in vcpu_set_state_locked()
1125 switch (vcpu->state) { in vcpu_set_state_locked()
1142 vcpu->state = newstate; in vcpu_set_state_locked()
1144 vcpu->hostcpu = curcpu; in vcpu_set_state_locked()
1146 vcpu->hostcpu = NOCPU; in vcpu_set_state_locked()
1149 wakeup(&vcpu->state); in vcpu_set_state_locked()
1178 return (vmmops_getcap(vcpu->cookie, type, retval)); in vm_get_capability()
1187 return (vmmops_setcap(vcpu->cookie, type, val)); in vm_set_capability()
1190 struct vm *
1193 return (vcpu->vm); in vcpu_vm()
1199 return (vcpu->vcpuid); in vcpu_vcpuid()
1205 return (vcpu->cookie); in vcpu_get_cookie()
1209 vm_vcpu(struct vm *vm, int vcpuid) in vm_vcpu() argument
1211 return (vm->vcpu[vcpuid]); in vm_vcpu()
1232 state = vcpu->state; in vcpu_get_state()
1234 *hostcpu = vcpu->hostcpu; in vcpu_get_state()
1247 return (vmmops_getreg(vcpu->cookie, reg, retval)); in vm_get_register()
1257 error = vmmops_setreg(vcpu->cookie, reg, val); in vm_set_register()
1261 vcpu->nextpc = val; in vm_set_register()
1267 vm_get_cookie(struct vm *vm) in vm_get_cookie() argument
1269 return (vm->cookie); in vm_get_cookie()
1275 return (vmmops_exception(vcpu->cookie, esr, far)); in vm_inject_exception()
1279 vm_attach_vgic(struct vm *vm, struct vm_vgic_descr *descr) in vm_attach_vgic() argument
1281 return (vgic_attach_to_vm(vm->cookie, descr)); in vm_attach_vgic()
1285 vm_assert_irq(struct vm *vm, uint32_t irq) in vm_assert_irq() argument
1287 return (vgic_inject_irq(vm->cookie, -1, irq, true)); in vm_assert_irq()
1291 vm_deassert_irq(struct vm *vm, uint32_t irq) in vm_deassert_irq() argument
1293 return (vgic_inject_irq(vm->cookie, -1, irq, false)); in vm_deassert_irq()
1297 vm_raise_msi(struct vm *vm, uint64_t msg, uint64_t addr, int bus, int slot, in vm_raise_msi() argument
1301 return (vgic_inject_msi(vm->cookie, msg, addr)); in vm_raise_msi()
1312 if ((hypctx->tf.tf_esr & ESR_ELx_ISS_MASK) != 0) in vm_handle_smccc_call()
1315 vme->exitcode = VM_EXITCODE_SMCCC; in vm_handle_smccc_call()
1316 vme->u.smccc_call.func_id = hypctx->tf.tf_x[0]; in vm_handle_smccc_call()
1317 for (i = 0; i < nitems(vme->u.smccc_call.args); i++) in vm_handle_smccc_call()
1318 vme->u.smccc_call.args[i] = hypctx->tf.tf_x[i + 1]; in vm_handle_smccc_call()
1329 if (vgic_has_pending_irq(vcpu->cookie)) in vm_handle_wfi()
1340 msleep_spin(vcpu, &vcpu->mtx, "vmidle", hz); in vm_handle_wfi()
1352 struct vm *vm = vcpu->vm; in vm_handle_paging() local
1354 struct vm_map *map; in vm_handle_paging() local
1359 vme = &vcpu->exitinfo; in vm_handle_paging()
1361 pmap = vmspace_pmap(vcpu->vm->vmspace); in vm_handle_paging()
1362 addr = vme->u.paging.gpa; in vm_handle_paging()
1363 esr = vme->u.paging.esr; in vm_handle_paging()
1378 map = &vm->vmspace->vm_map; in vm_handle_paging()
1379 rv = vm_fault(map, vme->u.paging.gpa, ftype, VM_FAULT_NORMAL, NULL); in vm_handle_paging()
1389 struct vm *vm = vcpu->vm; in vm_handle_suspend() local
1396 CPU_SET_ATOMIC(vcpu->vcpuid, &vm->suspended_cpus); in vm_handle_suspend()
1401 * Since a VM may be suspended at any time including when one or in vm_handle_suspend()
1407 if (CPU_CMP(&vm->suspended_cpus, &vm->active_cpus) == 0) in vm_handle_suspend()
1411 msleep_spin(vcpu, &vcpu->mtx, "vmsusp", hz); in vm_handle_suspend()
1424 for (i = 0; i < vm->maxcpus; i++) { in vm_handle_suspend()
1425 if (CPU_ISSET(i, &vm->suspended_cpus)) { in vm_handle_suspend()
1426 vcpu_notify_event(vm_vcpu(vm, i)); in vm_handle_suspend()
1437 struct vm *vm = vcpu->vm; in vm_run() local
1444 vcpuid = vcpu->vcpuid; in vm_run()
1446 if (!CPU_ISSET(vcpuid, &vm->active_cpus)) in vm_run()
1449 if (CPU_ISSET(vcpuid, &vm->suspended_cpus)) in vm_run()
1452 pmap = vmspace_pmap(vm->vmspace); in vm_run()
1453 vme = &vcpu->exitinfo; in vm_run()
1455 evinfo.sptr = &vm->suspend; in vm_run()
1463 error = vmmops_run(vcpu->cookie, vcpu->nextpc, pmap, &evinfo); in vm_run()
1472 switch (vme->exitcode) { in vm_run()
1474 vcpu->nextpc = vme->pc + vme->inst_length; in vm_run()
1479 vcpu->nextpc = vme->pc + vme->inst_length; in vm_run()
1488 vcpu->nextpc = vme->pc; in vm_run()
1497 vcpu->nextpc = vme->pc + vme->inst_length; in vm_run()
1502 vcpu->nextpc = vme->pc; in vm_run()
1507 vcpu->nextpc = vme->pc; in vm_run()
1513 vcpu->nextpc = vme->pc; in vm_run()