diff options
author | Dave Voutila <dv@cvs.openbsd.org> | 2021-11-22 12:55:41 +0000 |
---|---|---|
committer | Dave Voutila <dv@cvs.openbsd.org> | 2021-11-22 12:55:41 +0000 |
commit | e1d2a6abef22778a6bcc3d7204c540813eee3cbb (patch) | |
tree | d6c066596d3a6371231f562986687eaee16bcea5 /sys/arch | |
parent | ae88fbf42f8aa3621444c15e26d3ba337c6542d3 (diff) |
vmm(4): copyout guest state on VM_EXIT_NONE
Partly related to a bug reported by kn@. We should be copying out
the guest exit state (including registers) when we succesfully
return from the vcpu run loop even if we don't require an emulation
assist from userland/vmd(8). This condition was introduced when I
removed the use of yield() and instead exit the kernel if the
scheduler says we've hogged the cpu.
ok mlarkin@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/amd64/vmm.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/sys/arch/amd64/amd64/vmm.c b/sys/arch/amd64/amd64/vmm.c index 61cc95def08..2535558cce5 100644 --- a/sys/arch/amd64/amd64/vmm.c +++ b/sys/arch/amd64/amd64/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.294 2021/10/26 16:29:49 deraadt Exp $ */ +/* $OpenBSD: vmm.c,v 1.295 2021/11/22 12:55:40 dv Exp $ */ /* * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org> * @@ -4301,9 +4301,10 @@ vm_run(struct vm_run_params *vrp) rw_exit_write(&vmm_softc->vm_lock); } ret = 0; - } else if (ret == EAGAIN) { + } else if (ret == 0 || ret == EAGAIN) { /* If we are exiting, populate exit data so vmd can help. */ - vrp->vrp_exit_reason = vcpu->vc_gueststate.vg_exit_reason; + vrp->vrp_exit_reason = (ret == 0) ? VM_EXIT_NONE + : vcpu->vc_gueststate.vg_exit_reason; vrp->vrp_irqready = vcpu->vc_irqready; vcpu->vc_state = VCPU_STATE_STOPPED; @@ -4312,9 +4313,6 @@ vm_run(struct vm_run_params *vrp) ret = EFAULT; } else ret = 0; - } else if (ret == 0) { - vrp->vrp_exit_reason = VM_EXIT_NONE; - vcpu->vc_state = VCPU_STATE_STOPPED; } else { vrp->vrp_exit_reason = VM_EXIT_TERMINATED; vcpu->vc_state = VCPU_STATE_TERMINATED; |