summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormlarkin <mlarkin@openbsd.org>2017-08-20 05:14:16 +0000
committermlarkin <mlarkin@openbsd.org>2017-08-20 05:14:16 +0000
commitc714cbb5a8c5fb0bffe6cd2c940f10501573c153 (patch)
treeadd22709c8da213aa581662ee02122b2183e5d16
parentfix a mem range calculation error that made vmm reject otherwise valid (diff)
downloadwireguard-openbsd-c714cbb5a8c5fb0bffe6cd2c940f10501573c153.tar.xz
wireguard-openbsd-c714cbb5a8c5fb0bffe6cd2c940f10501573c153.zip
vmm: don't mangle %rax on OUT instructions if vmd(8) modified the exit
information data.
-rw-r--r--sys/arch/amd64/amd64/vmm.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/arch/amd64/amd64/vmm.c b/sys/arch/amd64/amd64/vmm.c
index 746fa9f1c46..5262b37b949 100644
--- a/sys/arch/amd64/amd64/vmm.c
+++ b/sys/arch/amd64/amd64/vmm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmm.c,v 1.166 2017/08/20 04:56:41 mlarkin Exp $ */
+/* $OpenBSD: vmm.c,v 1.167 2017/08/20 05:14:16 mlarkin Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
@@ -3658,8 +3658,9 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *vrp)
if (vrp->vrp_continue) {
switch (vcpu->vc_gueststate.vg_exit_reason) {
case VMX_EXIT_IO:
- vcpu->vc_gueststate.vg_rax =
- vcpu->vc_exit.vei.vei_data;
+ if (vcpu->vc_exit.vei.vei_dir == VEI_DIR_IN)
+ vcpu->vc_gueststate.vg_rax =
+ vcpu->vc_exit.vei.vei_data;
break;
case VMX_EXIT_HLT:
break;
@@ -5687,9 +5688,11 @@ vcpu_run_svm(struct vcpu *vcpu, struct vm_run_params *vrp)
if (vrp->vrp_continue) {
switch (vcpu->vc_gueststate.vg_exit_reason) {
case SVM_VMEXIT_IOIO:
- vcpu->vc_gueststate.vg_rax =
- vcpu->vc_exit.vei.vei_data;
- vmcb->v_rax = vcpu->vc_gueststate.vg_rax;
+ if (vcpu->vc_exit.vei.vei_dir == VEI_DIR_IN) {
+ vcpu->vc_gueststate.vg_rax =
+ vcpu->vc_exit.vei.vei_data;
+ vmcb->v_rax = vcpu->vc_gueststate.vg_rax;
+ }
}
}