Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F163278730
D54773.id170037.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D54773.id170037.diff
View Options
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
@@ -314,6 +314,16 @@
static void lapic_calibrate_initcount(struct lapic *la);
+/*
+ * Calculate the max index of the present LVT entry from the value of
+ * the LAPIC version register.
+ */
+static int
+lapic_maxlvt(uint32_t version)
+{
+ return ((version & APIC_VER_MAXLVT) >> MAXLVTSHIFT);
+}
+
/*
* Use __nosanitizethread to exempt the LAPIC I/O accessors from KCSan
* instrumentation. Otherwise, if x2APIC is not available, use of the global
@@ -809,9 +819,12 @@
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();
@@ -834,7 +847,7 @@
la = &lapics[lapic_id()];
KASSERT(la->la_present, ("missing APIC structure"));
version = lapic_read32(LAPIC_VERSION);
- maxlvt = (version & APIC_VER_MAXLVT) >> MAXLVTSHIFT;
+ maxlvt = lapic_maxlvt(version);
/* Initialize the TPR to allow all interrupts. */
lapic_set_tpr(0);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jul 22, 4:35 PM (3 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35372393
Default Alt Text
D54773.id170037.diff (1 KB)
Attached To
Mode
D54773: x86/local_apic.c: Properly calculate the number of LVT entries
Attached
Detach File
Event Timeline
Log In to Comment