summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2012-11-09 16:00:30 +0000
committerkib <kib@FreeBSD.org>2012-11-09 16:00:30 +0000
commit3c8fa044cf34a658663e823843f0141de113049b (patch)
tree5331ab0a9a757655614bd39f1a1638b7431acce3
parent0221456a727a8389e531b9e19c3c6c15884953f8 (diff)
downloadFreeBSD-src-3c8fa044cf34a658663e823843f0141de113049b.zip
FreeBSD-src-3c8fa044cf34a658663e823843f0141de113049b.tar.gz
Do not try to enable new features in the %cr4 if running under
hypervisor. Apparently, hypervisors failed to filter out 'Standard Extended Features' report from CPUID, but deliver #gp when corresponding bit in %cr4 is toggled. This shall be reconsidered later, after hypervisors correct the bug. Reported and tested by: joel Reviewed by: avg MFC after: 2 weeks
-rw-r--r--sys/amd64/amd64/identcpu.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/sys/amd64/amd64/identcpu.c b/sys/amd64/amd64/identcpu.c
index 465316a..2517498 100644
--- a/sys/amd64/amd64/identcpu.c
+++ b/sys/amd64/amd64/identcpu.c
@@ -481,7 +481,7 @@ SYSINIT(hook_tsc_freq, SI_SUB_CONFIGURE, SI_ORDER_ANY, hook_tsc_freq, NULL);
void
identify_cpu(void)
{
- u_int regs[4];
+ u_int regs[4], cpu_stdext_disable;
do_cpuid(0, regs);
cpu_high = regs[0];
@@ -516,6 +516,20 @@ identify_cpu(void)
if (cpu_high >= 7) {
cpuid_count(7, 0, regs);
cpu_stdext_feature = regs[1];
+
+ /*
+ * Some hypervisors fail to filter out unsupported
+ * extended features. For now, disable the
+ * extensions, activation of which requires setting a
+ * bit in CR4, and which VM monitors do not support.
+ */
+ if (cpu_feature2 & CPUID2_HV) {
+ cpu_stdext_disable = CPUID_STDEXT_FSGSBASE |
+ CPUID_STDEXT_SMEP;
+ } else
+ cpu_stdext_disable = 0;
+ TUNABLE_INT_FETCH("hw.cpu_stdext_disable", &cpu_stdext_disable);
+ cpu_stdext_feature &= ~cpu_stdext_disable;
}
if (cpu_vendor_id == CPU_VENDOR_INTEL ||
OpenPOWER on IntegriCloud