diff options
author | Mike Larkin <mlarkin@cvs.openbsd.org> | 2018-07-11 12:55:02 +0000 |
---|---|---|
committer | Mike Larkin <mlarkin@cvs.openbsd.org> | 2018-07-11 12:55:02 +0000 |
commit | 6a0d4c3246f6c978c7f11097d582a75e88dbebc1 (patch) | |
tree | 0d639280ef9b56a9b724d4baeed52e3b595134d1 /sys/arch | |
parent | 9e63ae17d5cd7cf00ad8b2840e90c192ca7e9261 (diff) |
vmm(4): respect argument size when reading from undefined ports.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/amd64/vmm.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/sys/arch/amd64/amd64/vmm.c b/sys/arch/amd64/amd64/vmm.c index c405ade5a4f..6dc20d5545c 100644 --- a/sys/arch/amd64/amd64/vmm.c +++ b/sys/arch/amd64/amd64/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.211 2018/07/11 12:45:01 mlarkin Exp $ */ +/* $OpenBSD: vmm.c,v 1.212 2018/07/11 12:55:01 mlarkin Exp $ */ /* * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org> * @@ -5099,8 +5099,6 @@ svm_handle_inout(struct vcpu *vcpu) * * XXX something better than a hardcoded list here, maybe * configure via vmd via the device list in vm create params? - * - * XXX handle not eax target */ switch (vcpu->vc_exit.vei.vei_port) { case IO_ICU1 ... IO_ICU1 + 1: @@ -5119,8 +5117,20 @@ svm_handle_inout(struct vcpu *vcpu) default: /* Read from unsupported ports returns FFs */ if (vcpu->vc_exit.vei.vei_dir == 1) { - vcpu->vc_gueststate.vg_rax = 0xFFFFFFFF; - vmcb->v_rax = 0xFFFFFFFF; + switch(vcpu->vc_exit.vei.vei_size) { + case 1: + vcpu->vc_gueststate.vg_rax |= 0xFF; + vmcb->v_rax |= 0xFF; + break; + case 2: + vcpu->vc_gueststate.vg_rax |= 0xFFFF; + vmcb->v_rax |= 0xFFFF; + break; + case 4: + vcpu->vc_gueststate.vg_rax |= 0xFFFFFFFF; + vmcb->v_rax |= 0xFFFFFFFF; + break; + } } ret = 0; } @@ -5182,8 +5192,6 @@ vmx_handle_inout(struct vcpu *vcpu) * * XXX something better than a hardcoded list here, maybe * configure via vmd via the device list in vm create params? - * - * XXX handle not eax target */ switch (vcpu->vc_exit.vei.vei_port) { case IO_ICU1 ... IO_ICU1 + 1: @@ -5203,7 +5211,7 @@ vmx_handle_inout(struct vcpu *vcpu) /* Read from unsupported ports returns FFs */ if (vcpu->vc_exit.vei.vei_dir == VEI_DIR_IN) { if (vcpu->vc_exit.vei.vei_size == 4) - vcpu->vc_gueststate.vg_rax = 0xFFFFFFFF; + vcpu->vc_gueststate.vg_rax |= 0xFFFFFFFF; else if (vcpu->vc_exit.vei.vei_size == 2) vcpu->vc_gueststate.vg_rax |= 0xFFFF; else if (vcpu->vc_exit.vei.vei_size == 1) |