summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgrehan <grehan@FreeBSD.org>2017-03-25 05:09:03 +0000
committergrehan <grehan@FreeBSD.org>2017-03-25 05:09:03 +0000
commit8f0fb5d1b92fb55a894bab8f8bdae126d829c1f9 (patch)
treea0abe2e0d44e86196b6b191b6ed1b582822d7ac3
parent5f66a0a5cff9df60880fe6cc194f755e2cd96409 (diff)
downloadFreeBSD-src-8f0fb5d1b92fb55a894bab8f8bdae126d829c1f9.zip
FreeBSD-src-8f0fb5d1b92fb55a894bab8f8bdae126d829c1f9.tar.gz
MFC r315361 and r315364: Hide MONITORX/MWAITX from guests.
r315361 Add the AMD MONITORX/MWAITX feature definition introduced in Bulldozer/Ryzen CPUs. r315364 Hide the AMD MONITORX/MWAITX capability. Otherwise, recent Linux guests will use these instructions, resulting in #UD exceptions since bhyve doesn't implement MONITOR/MWAIT exits. This fixes boot-time hangs in recent Linux guests on Ryzen CPUs (and probably Bulldozer aka AMD FX as well).
-rw-r--r--sys/amd64/vmm/x86.c3
-rw-r--r--sys/x86/include/specialreg.h1
-rw-r--r--sys/x86/x86/identcpu.c2
3 files changed, 5 insertions, 1 deletions
diff --git a/sys/amd64/vmm/x86.c b/sys/amd64/vmm/x86.c
index 525e1d9..61d99d5 100644
--- a/sys/amd64/vmm/x86.c
+++ b/sys/amd64/vmm/x86.c
@@ -176,6 +176,9 @@ x86_emulate_cpuid(struct vm *vm, int vcpu_id,
/* Don't advertise the OS visible workaround feature */
regs[2] &= ~AMDID2_OSVW;
+ /* Hide mwaitx/monitorx capability from the guest */
+ regs[2] &= ~AMDID2_MWAITX;
+
/*
* Hide rdtscp/ia32_tsc_aux until we know how
* to deal with them.
diff --git a/sys/x86/include/specialreg.h b/sys/x86/include/specialreg.h
index 3e04273..2cfe5b4 100644
--- a/sys/x86/include/specialreg.h
+++ b/sys/x86/include/specialreg.h
@@ -226,6 +226,7 @@
#define AMDID2_DBE 0x04000000
#define AMDID2_PTSC 0x08000000
#define AMDID2_PTSCEL2I 0x10000000
+#define AMDID2_MWAITX 0x20000000
/*
* CPUID instruction 1 eax info
diff --git a/sys/x86/x86/identcpu.c b/sys/x86/x86/identcpu.c
index fc32c8d..f419254 100644
--- a/sys/x86/x86/identcpu.c
+++ b/sys/x86/x86/identcpu.c
@@ -875,7 +875,7 @@ printcpuinfo(void)
"\033DBE" /* Data Breakpoint extension */
"\034PTSC" /* Performance TSC */
"\035PL2I" /* L2I perf count */
- "\036<b29>"
+ "\036MWAITX" /* MONITORX/MWAITX instructions */
"\037<b30>"
"\040<b31>"
);
OpenPOWER on IntegriCloud