diff options
author | 2019-01-20 01:07:16 +0000 | |
---|---|---|
committer | 2019-01-20 01:07:16 +0000 | |
commit | e86a2138c3c6e7bf69c70ce5fd4750b85b85becd (patch) | |
tree | a5e421ee0d4e2d842481d5c664f8d0ccf8d687f0 | |
parent | Implement rdmsr_safe (diff) | |
download | wireguard-openbsd-e86a2138c3c6e7bf69c70ce5fd4750b85b85becd.tar.xz wireguard-openbsd-e86a2138c3c6e7bf69c70ce5fd4750b85b85becd.zip |
Use rdmsr_safe in svm_handle_msr
Avoid reading possibly missing MSRs
ok guenther@
-rw-r--r-- | sys/arch/amd64/amd64/vmm.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sys/arch/amd64/amd64/vmm.c b/sys/arch/amd64/amd64/vmm.c index 0bf29bc513b..e9400f089f9 100644 --- a/sys/arch/amd64/amd64/vmm.c +++ b/sys/arch/amd64/amd64/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.223 2019/01/18 08:26:55 mlarkin Exp $ */ +/* $OpenBSD: vmm.c,v 1.224 2019/01/20 01:07:16 mlarkin Exp $ */ /* * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org> * @@ -5847,6 +5847,7 @@ svm_handle_msr(struct vcpu *vcpu) uint64_t insn_length, msr; uint64_t *rax, *rcx, *rdx; struct vmcb *vmcb = (struct vmcb *)vcpu->vc_control_va; + int i; /* XXX: Validate RDMSR / WRMSR insn_length */ insn_length = 2; @@ -5867,9 +5868,16 @@ svm_handle_msr(struct vcpu *vcpu) #endif /* VMM_DEBUG */ } } else { - msr = rdmsr(*rcx); - *rax = msr & 0xFFFFFFFFULL; - *rdx = msr >> 32; + i = rdmsr_safe(*rcx, &msr); + if (i == 0) { + *rax = msr & 0xFFFFFFFFULL; + *rdx = msr >> 32; + } else { + DPRINTF("%s: rdmsr for unsupported MSR 0x%llx\n", + __func__, *rcx); + *rax = 0; + *rdx = 0; + } } vcpu->vc_gueststate.vg_rip += insn_length; |