diff --git a/sys/x86/include/apicreg.h b/sys/x86/include/apicreg.h --- a/sys/x86/include/apicreg.h +++ b/sys/x86/include/apicreg.h @@ -439,7 +439,12 @@ #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 --- a/sys/x86/x86/local_apic.c +++ b/sys/x86/x86/local_apic.c @@ -809,9 +809,13 @@ 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), ((version & APIC_VER_MAXLVT) >> + MAXLVTSHIFT) + 1); + for (i = 0; i < lvts_count; i++) lapic_early_mask_vec(&lvts[i]); elvt_count = amd_read_elvt_count();