git: 0ecda8d5ae89 - main - x86: Do not attempt to calibrate the LAPIC timer if no APIC is present

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 28 Dec 2021 22:54:50 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=0ecda8d5ae896b229f13bfe73ffa3a7fc81cc550

commit 0ecda8d5ae896b229f13bfe73ffa3a7fc81cc550
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-12-28 22:44:57 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-12-28 22:47:49 +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")
    MFC after:      3 days
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D33669
---
 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 1264eeaaf7b8..23b780b121e1 100644
--- a/sys/x86/x86/local_apic.c
+++ b/sys/x86/x86/local_apic.c
@@ -913,6 +913,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()];