]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
fix: PMM total_memory overflow — MMAP reserved regions near 4GB inflated highest_addr
authorTulio A M Mendes <[email protected]>
Mon, 16 Feb 2026 22:08:36 +0000 (19:08 -0300)
committerTulio A M Mendes <[email protected]>
Mon, 16 Feb 2026 22:08:36 +0000 (19:08 -0300)
commit680a9f71b753c75e86d1adea42643e057abfcd46
tree3b0fd6c262d635b4eb9f80523e09ef32665fe029
parent93e8030e622922300557efa24600530521d8cec2
fix: PMM total_memory overflow — MMAP reserved regions near 4GB inflated highest_addr

Root cause: Multiboot2 MMAP includes a BIOS reserved region at
0xFFFC0000-0x100000000. The end address (0x100000000) overflows
uint32_t when stored in a uint64_t local variable, and (unsigned)
truncation yields 0 — hence '[PMM] total_memory bytes: 0x0'.

Fixes:
- Use uint32_t locals (32-bit x86 caps RAM at 512 MB anyway)
- Clamp MMAP end addresses to 0xFFFFFFFF before comparison
- Only track highest_avail from AVAILABLE regions, not reserved
- Use 'if' instead of 'else if' so both BASIC_MEMINFO and MMAP
  are processed in the same pass
- Print total_memory and freed_frames in decimal with MB suffix

Before: [PMM] total_memory bytes: 0x0
After:  [PMM] total_memory: 134086656 bytes (127 MB)

83/83 smoke tests pass, cppcheck clean.
src/arch/x86/pmm_boot.c