summaryrefslogtreecommitdiffstats
path: root/sys/x86
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2011-04-14 17:50:26 +0000
committerjkim <jkim@FreeBSD.org>2011-04-14 17:50:26 +0000
commit38dc7c42e64b68aff5cd2f89803997efc8ba01e4 (patch)
tree705b5be386433d0dc7fa64f2b4ef32957d3ba0f4 /sys/x86
parent17965a03aabd44c44fbb007f459c11fa89ba3b54 (diff)
downloadFreeBSD-src-38dc7c42e64b68aff5cd2f89803997efc8ba01e4.zip
FreeBSD-src-38dc7c42e64b68aff5cd2f89803997efc8ba01e4.tar.gz
Work around an emulator problem where virtual CPU advertises TSC is P-state
invariant and APERF/MPERF MSRs exist but these MSRs never tick. When we calculate effective frequency from cpu_est_clockrate(), it caused panic of division-by-zero. Now we test whether these MSRs actually increase to avoid such foot-shooting. Reported by: dim Tested by: dim
Diffstat (limited to 'sys/x86')
-rw-r--r--sys/x86/x86/tsc.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c
index 04e936a..c08f4ad 100644
--- a/sys/x86/x86/tsc.c
+++ b/sys/x86/x86/tsc.c
@@ -183,8 +183,18 @@ probe_tsc_freq(void)
if (cpu_high >= 6) {
do_cpuid(6, regs);
- if ((regs[2] & CPUID_PERF_STAT) != 0)
- tsc_perf_stat = 1;
+ if ((regs[2] & CPUID_PERF_STAT) != 0) {
+ /*
+ * XXX Some emulators expose host CPUID without actual
+ * support for these MSRs. We must test whether they
+ * really work.
+ */
+ wrmsr(MSR_MPERF, 0);
+ wrmsr(MSR_APERF, 0);
+ DELAY(10);
+ if (rdmsr(MSR_MPERF) > 0 && rdmsr(MSR_APERF) > 0)
+ tsc_perf_stat = 1;
+ }
}
if (tsc_skip_calibration) {
OpenPOWER on IntegriCloud