diff options
author | neel <neel@FreeBSD.org> | 2014-12-20 19:47:51 +0000 |
---|---|---|
committer | neel <neel@FreeBSD.org> | 2014-12-20 19:47:51 +0000 |
commit | 9abef2383d1b454a588587028568bb547b7a0842 (patch) | |
tree | ffdb78661c7e90d20b5503938d096094e65f5e40 /sys/amd64 | |
parent | 8f1c7a6d1b4a1e0d2dcaa215c661e13473b4bb9a (diff) | |
download | FreeBSD-src-9abef2383d1b454a588587028568bb547b7a0842.zip FreeBSD-src-9abef2383d1b454a588587028568bb547b7a0842.tar.gz |
Emulate writes to the IA32_MISC_ENABLE MSR.
PR: 196093
Reported by: db
Tested by: db
Discussed with: grehan
MFC after: 1 week
Diffstat (limited to 'sys/amd64')
-rw-r--r-- | sys/amd64/vmm/intel/vmx_msr.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/sys/amd64/vmm/intel/vmx_msr.c b/sys/amd64/vmm/intel/vmx_msr.c index 746ca73..f6bbf2a 100644 --- a/sys/amd64/vmm/intel/vmx_msr.c +++ b/sys/amd64/vmm/intel/vmx_msr.c @@ -376,9 +376,31 @@ vmx_rdmsr(struct vmx *vmx, int vcpuid, u_int num, uint64_t *val, bool *retu) int vmx_wrmsr(struct vmx *vmx, int vcpuid, u_int num, uint64_t val, bool *retu) { - int error = 0; - + uint64_t changed; + int error; + + error = 0; switch (num) { + case MSR_IA32_MISC_ENABLE: + changed = val ^ misc_enable; + /* + * If the host has disabled the NX feature then the guest + * also cannot use it. However, a Linux guest will try to + * enable the NX feature by writing to the MISC_ENABLE MSR. + * + * This can be safely ignored because the memory management + * code looks at CPUID.80000001H:EDX.NX to check if the + * functionality is actually enabled. + */ + changed &= ~(1UL << 34); + + /* + * Punt to userspace if any other bits are being modified. + */ + if (changed) + error = EINVAL; + + break; default: error = EINVAL; break; |