Skip to content

Commit a6d41c0

Browse files
comment about MAX_CPUS
1 parent 27a4feb commit a6d41c0

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/idt.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,19 @@
1515

1616
#define MSI_VECTORS 256
1717
#define FIRST_MSI_VECTOR 64
18-
#define MSI_WORDS (MSI_VECTORS / 64U)
18+
#define MSI_WORDS (MSI_VECTORS / 64)
19+
20+
/**
21+
* @note MAX_CPUS is set to 256 (not the expected physical core count).
22+
*
23+
* Local APIC IDs are 8-bit fields (0–255) and are not guaranteed to be
24+
* sequential, zero-based, or densely packed. Some systems leave gaps
25+
* in the LAPIC ID space or assign non-zero IDs to the bootstrap CPU.
26+
*
27+
* By sizing arrays to 256, we can index directly by LAPIC ID without
28+
* needing an LAPIC->OS CPU remapping table. This avoids subtle bugs on
29+
* odd hardware at the cost of a small amount of extra memory.
30+
*/
1931
#define MAX_CPUS 256
2032

2133
/* Precompute reserved mask for the first word */

0 commit comments

Comments
 (0)