aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMina Galić <freebsd@igalic.co>2023-02-24 11:07:42 +0000
committerWarner Losh <imp@FreeBSD.org>2023-02-25 16:47:40 +0000
commit499171a98c8813e4dc6e085461d5c47750efa555 (patch)
tree8a30a8aa5cb48edc6d9cf1b55d85016dca79f6de
parent28111ddf9ee6d14eea6941a66168f2aeb361746d (diff)
apic: prevent divide by zero in CPU frequency init
If a CPU for some reason returns 0 as CPU frequency, we currently panic on the resulting divide by zero when trying to initialize the CPU(s) via APIC. When this happens, we'll fallback to measuring the frequency instead. PR: 269767 Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/664
-rw-r--r--sys/x86/x86/local_apic.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c
index 609635bdad3d..22392901b731 100644
--- a/sys/x86/x86/local_apic.c
+++ b/sys/x86/x86/local_apic.c
@@ -953,7 +953,7 @@ lapic_calibrate_initcount_cpuid_vm(void)
/* Record divided frequency. */
count_freq = freq / lapic_timer_divisor;
- return (true);
+ return (count_freq != 0);
}
static uint64_t