Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Mar 2023 17:10:20 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 55639067a29b - releng/13.2 - apic: prevent divide by zero in CPU frequency init
Message-ID:  <202303021710.322HAKf0028229@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch releng/13.2 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=55639067a29b1250f7ba7dfc012723a843c5f91c

commit 55639067a29b1250f7ba7dfc012723a843c5f91c
Author:     Mina Galić <freebsd@igalic.co>
AuthorDate: 2023-02-28 02:58:45 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-03-02 17:09:47 +0000

    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 499171a98c8813e4dc6e085461d5c47750efa555)
    (cherry picked from commit a1c63b8e29e832d9ada7c252e7e80ce8b94aeb41)
---
 sys/x86/x86/local_apic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c
index 4ab4e78f20e7..482b0ebd81bc 100644
--- a/sys/x86/x86/local_apic.c
+++ b/sys/x86/x86/local_apic.c
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202303021710.322HAKf0028229>