git: 4642ec266c7e - stable/13 - x86: Do not attempt to calibrate the LAPIC timer if no APIC is present

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Wed, 29 Dec 2021 15:47:03 UTC
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=4642ec266c7e4f539d891e59f713628fe6281ea3

commit 4642ec266c7e4f539d891e59f713628fe6281ea3
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-12-28 22:44:57 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-12-29 15:39:41 +0000

    x86: Do not attempt to calibrate the LAPIC timer if no APIC is present
    
    Reported and tested by: Michael Butler <imb@protected-networks.net>
    Reviewed by:    jhb, kib
    Fixes:  62d09b46ad75 ("x86: Defer LAPIC calibration until after timecounters are available")
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 0ecda8d5ae896b229f13bfe73ffa3a7fc81cc550)
---
 sys/x86/x86/local_apic.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c
index 85f4ef1a9c6d..22dcfdef55fe 100644
--- a/sys/x86/x86/local_apic.c
+++ b/sys/x86/x86/local_apic.c
@@ -906,6 +906,12 @@ native_lapic_calibrate_timer(void)
 	struct lapic *la;
 	register_t intr;
 
+#ifdef DEV_ATPIC
+	/* Fail if the local APIC is not present. */
+	if (!x2apic_mode && lapic_map == NULL)
+		return;
+#endif
+
 	intr = intr_disable();
 	la = &lapics[lapic_id()];