]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
fix: KVA_IOAPIC VA collision with BSS — move from 0xC0201000 to 0xC0401000
authorTulio A M Mendes <[email protected]>
Tue, 17 Feb 2026 00:45:26 +0000 (21:45 -0300)
committerTulio A M Mendes <[email protected]>
Tue, 17 Feb 2026 00:45:26 +0000 (21:45 -0300)
Root cause: multiboot_copy (64KB static buffer) starts at VA 0xC0200FE0,
spanning pages 0xC0200000-0xC0210000. KVA_IOAPIC at 0xC0201000 mapped
IOAPIC MMIO over the BSS page containing the multiboot2 cmdline tag data.
After arch_platform_setup, reading bi->cmdline returned IOAPIC register
data (zeros) instead of the original cmdline string.

Symptom: [CMDLINE] "" regardless of GRUB menu entry selected.
Classic Heisenbug — adding a debug kprintf before IOAPIC init read the
correct data, masking the corruption.

Fix: move KVA_IOAPIC to 0xC0401000 (next to LAPIC at 0xC0400000),
well past _end at 0xC0265728. Updated VA map comment to reflect
current BSS extent (~0xC0266000).

include/arch/x86/kernel_va_map.h

index b5c3505cd666b357dff7293d6725e28cba3d8111..3ab77b2675dc5654577915dd19a3ce77b7837a75 100644 (file)
@@ -10,8 +10,7 @@
  *
  * Layout (sorted by VA):
  *
- *   0xC0000000 .. ~0xC0203000  Kernel .text/.data/.bss (variable)
- *   0xC0201000                 IOAPIC MMIO (1 page)
+ *   0xC0000000 .. ~0xC0266000  Kernel .text/.data/.bss (variable)
  *   0xC0280000                 vDSO shared page (1 page)
  *   0xC0300000 .. 0xC030FFFF   ACPI temp window (16 pages)
  *   0xC0320000                 ATA DMA PRDT (1 page)
@@ -22,6 +21,7 @@
  *   0xC0352000 .. 0xC0361FFF   E1000 TX buffers (16 pages)
  *   0xC0362000 .. 0xC0371FFF   E1000 RX buffers (16 pages)
  *   0xC0400000                 LAPIC MMIO (1 page)
+ *   0xC0401000                 IOAPIC MMIO (1 page)
  *   0xC8000000 ..              Kernel stacks (guard + 8KB per thread)
  *   0xD0000000 ..              Kernel heap (10 MB)
  *   0xDC000000 ..              Initrd / generic phys mapping (up to 64 MB)
@@ -29,7 +29,7 @@
  */
 
 /* IOAPIC (arch/x86/ioapic.c) */
-#define KVA_IOAPIC          0xC0201000U
+#define KVA_IOAPIC          0xC0401000U
 
 /* vDSO shared page (kernel/vdso.c) */
 #define KVA_VDSO            0xC0280000U