aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbdelkader Boudih <freebsd@seuros.com>2026-06-17 14:49:52 +0000
committerAdrian Chadd <adrian@FreeBSD.org>2026-06-17 14:49:52 +0000
commit021a190c88fc41f981a79fe6822bdafbcda14e99 (patch)
treec02b3c162a56e2eac1e2d403403126d29f0d2dca
parentf981fa12b760a5f0983eeec8065a4dec5295ab24 (diff)
est: prevent divide-by-zero in est_msr_info
When hw.est.msr_info=1 is set, est_msr_info() extracts the bus clock from MSR_PERF_STATUS upper bits. On secondary CPUs, the MSR may contain zero in the frequency ratio field, causing a divide-by-zero panic. Observed in pre Skylake Intel cpu. Reviewed by: adrian Differential Revision: https://reviews.freebsd.org/D57614
-rw-r--r--sys/x86/cpufreq/est.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/x86/cpufreq/est.c b/sys/x86/cpufreq/est.c
index 82f35934aa99..804de162ec60 100644
--- a/sys/x86/cpufreq/est.c
+++ b/sys/x86/cpufreq/est.c
@@ -1181,11 +1181,15 @@ est_msr_info(device_t dev, uint64_t msr, freq_info **freqs, size_t *freqslen)
/* Figure out the bus clock. */
freq = atomic_load_acq_64(&tsc_freq) / 1000000;
id = msr >> 32;
+ if ((id >> 8) == 0)
+ return (EOPNOTSUPP);
bus = freq / (id >> 8);
device_printf(dev, "Guessed bus clock (high) of %d MHz\n", bus);
if (!bus_speed_ok(bus)) {
/* We may be running on the low frequency. */
id = msr >> 48;
+ if ((id >> 8) == 0)
+ return (EOPNOTSUPP);
bus = freq / (id >> 8);
device_printf(dev, "Guessed bus clock (low) of %d MHz\n", bus);
if (!bus_speed_ok(bus))