Processes use separate four-level x86-64 page tables and share the kernel’s upper-half mappings. Threads within a process share its user address space. Pages are 4 KiB.
Address layout
| Region | Current layout |
|---|---|
User heap |
Begins after the loaded image; its break is bounded by |
User virtual ranges |
|
Physical direct map |
Physical address plus |
Kernel virtual ranges |
|
Kernel heap |
Starts at |
Kernel image |
Linked at |
Constants are in kernel/memory/constants.hpp. An address-range reservation is
separate from its page mappings and physical-frame ownership.
Stacks and mappings
User stacks reserve ten pages, including an unmapped guard page. One page is initially committed; missing-page faults grow the stack within its reservation. Kernel and interrupt stacks reserve nine pages each, with eight committed pages and a guard. Kernel stacks cannot depend on fault-time growth.
Fresh user pages are cleared before publication. Removing a mapping completes
remote TLB invalidation before its frame can be reused. RAM aliases retain frame
references; device mappings are non-owning and never return MMIO frames to the
RAM allocator. Internal stack/TLS reservations are released by task teardown,
not public g_unmap.
The bitmap allocator manages physical pages; virtual range pools manage address reservations. The kernel heap uses size-class buckets and coalesced larger sections. Fallible page allocation retains a recovery reserve, but critical kernel metadata exhaustion can still be fatal.