git: 7d327e4ce6e0 - stable/15 - x86/local_apic.c: Properly calculate the number of LVT entries
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 25 Jan 2026 00:24:44 UTC
The branch stable/15 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=7d327e4ce6e0e62ad7be87527d565bdb93ef92dc
commit 7d327e4ce6e0e62ad7be87527d565bdb93ef92dc
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-01-19 11:55:36 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-01-25 00:23:34 +0000
x86/local_apic.c: Properly calculate the number of LVT entries
(cherry picked from commit 709a53c8b20b5770f7e2f117d4799b5617479976)
---
sys/x86/include/apicreg.h | 7 ++++++-
sys/x86/x86/local_apic.c | 7 +++++--
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/sys/x86/include/apicreg.h b/sys/x86/include/apicreg.h
index 1252647fbab3..4cc9cabdad9e 100644
--- a/sys/x86/include/apicreg.h
+++ b/sys/x86/include/apicreg.h
@@ -439,7 +439,12 @@ typedef struct IOAPIC ioapic_t;
#define APIC_EXTF_SEIO_CAP 0x00000002
#define APIC_EXTF_IER_CAP 0x00000001
-/* LVT table indices */
+/*
+ * LVT table indices.
+ * Must be ordered following the appearance of the LVT entries in
+ * series the LAPIC versions, which is reported by LAPIC_VERSION
+ * MAXLVT field.
+ */
#define APIC_LVT_LINT0 0
#define APIC_LVT_LINT1 1
#define APIC_LVT_TIMER 2
diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c
index 68f42c9eed0b..b444142d5481 100644
--- a/sys/x86/x86/local_apic.c
+++ b/sys/x86/x86/local_apic.c
@@ -819,9 +819,12 @@ lapic_early_mask_vec(const struct lvt *l)
static void
lapic_early_mask_vecs(void)
{
- int elvt_count, i;
+ int elvt_count, lvts_count, i;
+ uint32_t version;
- for (i = 0; i < APIC_LVT_MAX; i++)
+ version = lapic_read32(LAPIC_VERSION);
+ lvts_count = min(nitems(lvts), lapic_maxlvt(version) + 1);
+ for (i = 0; i < lvts_count; i++)
lapic_early_mask_vec(&lvts[i]);
elvt_count = amd_read_elvt_count();