From 7ce183b28fb9145b45dda39386f0d564a44ddc56 Mon Sep 17 00:00:00 2001 From: Dave Voutila Date: Sun, 12 Jun 2022 19:48:13 +0000 Subject: vmm(4): remove vm teardown from vcpu run path Remove the calling of vm_teardown from the code path in vm_run after vmm has exited the vm/vcpu and is on its way back to userland/vmd(8). vmd(8) and other vmm(4) users should use the VMM_IOC_TERM ioctl(2) instead. Help testing from Mischa Peters, OK mlarkin@ --- sys/arch/amd64/amd64/vmm.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/sys/arch/amd64/amd64/vmm.c b/sys/arch/amd64/amd64/vmm.c index 323a77859ae..c9777982ce1 100644 --- a/sys/arch/amd64/amd64/vmm.c +++ b/sys/arch/amd64/amd64/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.312 2022/06/01 17:47:18 dv Exp $ */ +/* $OpenBSD: vmm.c,v 1.313 2022/06/12 19:48:12 dv Exp $ */ /* * Copyright (c) 2014 Mike Larkin * @@ -4488,22 +4488,8 @@ vm_run(struct vm_run_params *vrp) ret = vcpu_run_svm(vcpu, vrp); } - /* - * We can set the VCPU states here without CAS because once - * a VCPU is in state RUNNING or REQTERM, only the VCPU itself - * can switch the state. - */ atomic_dec_int(&vm->vm_vcpus_running); - if (vcpu->vc_state == VCPU_STATE_REQTERM) { - vrp->vrp_exit_reason = VM_EXIT_TERMINATED; - vcpu->vc_state = VCPU_STATE_TERMINATED; - if (vm->vm_vcpus_running == 0) { - rw_enter_write(&vmm_softc->vm_lock); - vm_teardown(vm); - rw_exit_write(&vmm_softc->vm_lock); - } - ret = 0; - } else if (ret == 0 || ret == EAGAIN) { + if (ret == 0 || ret == EAGAIN) { /* If we are exiting, populate exit data so vmd can help. */ vrp->vrp_exit_reason = (ret == 0) ? VM_EXIT_NONE : vcpu->vc_gueststate.vg_exit_reason; -- cgit v1.2.3