2199 vm_thread_ctx_t vtc;
2200 int affinity_type = CPU_CURRENT;
2201
2202 if (vcpuid < 0 || vcpuid >= vm->maxcpus)
2203 return (EINVAL);
2204 if (!CPU_ISSET(vcpuid, &vm->active_cpus))
2205 return (EINVAL);
2206 if (CPU_ISSET(vcpuid, &vm->suspended_cpus))
2207 return (EINVAL);
2208
2209 pmap = vmspace_pmap(vm->vmspace);
2210 vcpu = &vm->vcpu[vcpuid];
2211 vme = &vcpu->exitinfo;
2212
2213 vcpu_ustate_change(vm, vcpuid, VU_EMU_KERN);
2214
2215 vtc.vtc_vm = vm;
2216 vtc.vtc_vcpuid = vcpuid;
2217 vtc.vtc_status = 0;
2218 installctx(curthread, &vtc, vmm_savectx, vmm_restorectx, NULL, NULL,
2219 NULL, vmm_freectx);
2220
2221 error = vm_entry_actions(vm, vcpuid, entry, vme);
2222 if (error != 0) {
2223 goto exit;
2224 }
2225
2226 restart:
2227 error = vm_loop_checks(vm, vcpuid, vme);
2228 if (error != 0) {
2229 goto exit;
2230 }
2231
2232 thread_affinity_set(curthread, affinity_type);
2233 /*
2234 * Resource localization should happen after the CPU affinity for the
2235 * thread has been set to ensure that access from restricted contexts,
2236 * such as VMX-accelerated APIC operations, can occur without inducing
2237 * cyclic cross-calls.
2238 *
2239 * This must be done prior to disabling kpreempt via critical_enter().
|
2199 vm_thread_ctx_t vtc;
2200 int affinity_type = CPU_CURRENT;
2201
2202 if (vcpuid < 0 || vcpuid >= vm->maxcpus)
2203 return (EINVAL);
2204 if (!CPU_ISSET(vcpuid, &vm->active_cpus))
2205 return (EINVAL);
2206 if (CPU_ISSET(vcpuid, &vm->suspended_cpus))
2207 return (EINVAL);
2208
2209 pmap = vmspace_pmap(vm->vmspace);
2210 vcpu = &vm->vcpu[vcpuid];
2211 vme = &vcpu->exitinfo;
2212
2213 vcpu_ustate_change(vm, vcpuid, VU_EMU_KERN);
2214
2215 vtc.vtc_vm = vm;
2216 vtc.vtc_vcpuid = vcpuid;
2217 vtc.vtc_status = 0;
2218 installctx(curthread, &vtc, vmm_savectx, vmm_restorectx, NULL, NULL,
2219 NULL, vmm_freectx, NULL);
2220
2221 error = vm_entry_actions(vm, vcpuid, entry, vme);
2222 if (error != 0) {
2223 goto exit;
2224 }
2225
2226 restart:
2227 error = vm_loop_checks(vm, vcpuid, vme);
2228 if (error != 0) {
2229 goto exit;
2230 }
2231
2232 thread_affinity_set(curthread, affinity_type);
2233 /*
2234 * Resource localization should happen after the CPU affinity for the
2235 * thread has been set to ensure that access from restricted contexts,
2236 * such as VMX-accelerated APIC operations, can occur without inducing
2237 * cyclic cross-calls.
2238 *
2239 * This must be done prior to disabling kpreempt via critical_enter().
|