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
Approved by: re@ (cperciva)

(cherry picked from commit 499171a98c)
(cherry picked from commit a1c63b8e29)
This commit is contained in:
Mina Galić 2023-02-27 19:58:45 -07:00 committed by Warner Losh
parent 572900bd93
commit 55639067a2

View File

@ -1027,7 +1027,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