]> 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)
commitfd8418531d8be238f2d55d54daf4a325d5725818
treefe46b8695d159585b35769f64c1f06ac81962a16
parent1f8255ffef42e8ebe176a1bfcd19ccd93f4c4971
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