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
This commit is contained in:
Mina Galić 2023-02-24 11:07:42 +00:00 committed by Warner Losh
parent 28111ddf9e
commit 499171a98c

View File

@ -953,7 +953,7 @@ lapic_calibrate_initcount_cpuid_vm(void)
/* Record divided frequency. */ /* Record divided frequency. */
count_freq = freq / lapic_timer_divisor; count_freq = freq / lapic_timer_divisor;
return (true); return (count_freq != 0);
} }
static uint64_t static uint64_t