Memory Management
NØNOS implements a complete memory management subsystem.
Memory Layout
Virtual Address Space (x86_64)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
0xFFFFFFFF_FFFFFFFF ┐
│ Kernel Space
0xFFFFFFFF_80000000 ┤ (Higher Half)
│
├─ .text (RX) Code
├─ .rodata (RO) Constants
├─ .data (RW) Initialized data
├─ .bss (RW) Zero-initialized
├─ Heap (RW) Dynamic
└─ Stacks (RW) Per-task
0x00007FFF_FFFFFFFF ┐
│ User Space
0x00000000_00000000 ┘ (Reserved for future)Physical Memory
Frame Allocator
Manages 4KB physical frames
Bitmap tracks allocation state
Initialized from UEFI memory map
Memory Regions
Types from UEFI memory map:
Conventional
Available for allocation
Reserved
Hardware reserved
ACPI
ACPI tables
Framebuffer
GPU memory
Virtual Memory
Paging Structure
x86_64 4-level paging:
Page Sizes
4KB
Default
2MB
Large mappings
1GB
Huge mappings
Page Flags
Present
Page is mapped
Writable
Write access allowed
User
User-mode accessible
No-Execute
Code execution forbidden
Heap Allocator
Implementation
Linked-list allocator
#[global_allocator]attributeThread-safe with spinlock
Allocation Sizes
< 4KB
Heap allocator
≥ 4KB
Direct frame allocation
Stack Management
Kernel Stacks
64KB per task
Guard pages for overflow detection
Grows downward
Stack Layout
Security Features
W^X Enforcement
No page is both writable and executable:
Code pages: RX (read + execute)
Data pages: RW (read + write)
Rodata: RO (read only)
KASLR
Kernel Address Space Layout Randomization:
Randomized kernel base address
Randomized stack locations
Uses hardware entropy (RDRAND)
Guard Pages
Unmapped pages to catch:
Stack overflow
Buffer overflows
Memory APIs
Kernel Allocation
Page Mapping
Performance
Page fault
~1μs
Allocation (small)
~100ns
TLB flush
~50 cycles
Last updated
Was this helpful?


