notes

The user address-space map

Every process on nife has the same low half, and several programs agree on where things go in it: the linker script, two loaders, std's runtime, the kernel's test harnesses and every fixture that shares a page. This page is the map they agree on, so a new page is placed by the map rather than by looking for a gap. Milestone 206 (a program image has under 896 KiB) drew it, under DECISIONS §171 (where a program image starts), option D, ruled by calef on 2026-09-26. The map is a crate, partsfoundry/address_space_layout, because it is a list of numbers several binaries agree on (AGENTS.md rule 7). This page explains it; the crate is the rule.

The map

band start end size what goes in it
NULL_GUARD 0x0000_0000 0x0020_0000 2 MiB nothing, ever
PAIR_PAGES 0x0020_0000 0x1000_0000 254 MiB pages one builder agrees with the one program it builds, and a program's private windows
RUNTIME_WINDOWS 0x1000_0000 0x4000_0000 768 MiB windows a loader or runtime places for a program: std's runtime pages, std's socket frames, a builder's scratch cursor, the initrd window, the swap image
HEAP 0x4000_0000 0x5000_0000 256 MiB the heap and nothing else
SERVICE_WINDOWS 0x5000_0000 0x6000_0000 256 MiB large windows a service contract names: the block channel, the C seam's grant pages, the screen aperture
IMAGE 0x6000_0000 0x7F00_0000 496 MiB the program's code and data
STACK 0x7F00_0000 0x7FFF_0000 16 MiB less 64 KiB the stack, growing down; its lowest page is never mapped
PROCESS_PAGES 0x7FFF_0000 0x8000_0000 64 KiB pages the kernel maps into every process unasked; the current-CPU page is the last

The bands tile the first 2 GiB with no gap. Above that the only resident is the timebase page on x86_64 and riscv64 (counter_frequency_contract::PAGE_VIRTUAL_ADDRESS), which predates the map.

A program image may be up to 496 MiB. ripgrep, measured at 2.61 MiB by milestone 121 (ripgrep on nife), fits with room for a hundred and ninety of it.

Where a new page goes

Ask in order, and stop at the first yes.

  1. Is it the program's code or data? IMAGE. A child built by hand from a stub puts its code page at IMAGE_BASE_VIRTUAL_ADDRESS too.
  2. Is it the stack? STACK, down from STACK_TOP_PAGE_VIRTUAL_ADDRESS.
  3. Does the kernel map it into every process without being asked? PROCESS_PAGES.
  4. Is it the heap? HEAP.
  5. Is it placed by a loader or a runtime for programs that did not choose the address? RUNTIME_WINDOWS, with a written siting argument in the protocol crate that owns it.
  6. Is it a large window a service contract names for several programs? SERVICE_WINDOWS.
  7. Otherwise it is a pair page: PAIR_PAGES. Two pairs never share an address space, so pairs reuse addresses freely.

Then write it with the band's function, so the compiler checks it:

const CTL_VA: u64 = address_space_layout::pair_page(0x60_0000);

pair_page, runtime_window and service_window return their argument unchanged and stop the build if it is outside the band or not page aligned. Every fixed window in fixtures/, components/, the kernel's harnesses and the progenitor was brought under one of the three when the map landed, 188 of them.

What checks the map

Two mechanisms, each where it is strongest. const asserts in the crate check the constant facts in every consumer's build. The bands tile the first 2 GiB in BANDS order, and each starts and ends on a page. The top of the map is a user address under aarch64's 48-bit split, x86_64's 47-bit split and Sv39's 38-bit one. Kani (partsfoundry/address_space_layout/src/verification.rs, run by script/verify) proves what quantifies over an address. Every address below 2 GiB lies in exactly one band and its whole page lies in that band. A lower address never sits in a later band. Each band function accepts every page of its band, returns it unchanged, and refuses every address its doc forbids. And check_image places exactly the images the image band holds. Each harness carries a falsification patch that the weekly sweep replays.

Why these numbers

What it costs in page tables

Counted, not measured. A program with no pair pages (the supervision tree's children, the benchmark's stub) needs as many tables as before. They are the root, one upper level, one table for the second gigabyte, one leaf table for the image, and one for the stack and the current-CPU page. Before, the image and stack shared a leaf table in the first gigabyte and the current-CPU page had its own. A program with pair pages pays one more table than it did, because it now touches both gigabytes. A std program pays one fewer, because its heap was already in the second gigabyte.

A too-large image says so

kernel::user::load checks the image against the band before it maps anything, with address_space_layout::check_image, and refuses with LoadError::Misplaced. The boot prints it as a sentence:

refused to load a user program: the program image is too large: it ends at 0x7f001000, past the
stack's base at 0x7f000000; an image may be at most 496 MiB

An image linked for the old layout at 0x40_0000 is refused as outside the band, naming the base to relink at. process_builder's loader makes the same check, but it reports every failure as Err(()), so there the check only makes the failure early and clean.

What changed with it

The counter frequency page's address

counter_frequency_contract::PAGE_VIRTUAL_ADDRESS is 0x0000_7000_0000_0000 on x86_64, seven-eighths of the low half's ceiling (SPLIT_SHIFT is 47, so the low half is every address under 0x0000_8000_0000_0000; see crates/page_tables/src/x86_64.rs). That leaves roughly 26 TiB of headroom below the boundary, with none of this tree's other conventions near it. RISC-V under Sv39 splits at bit 38 (crates/page_tables/src/sv39.rs), so an address at or above 0x40_0000_0000 is not a user address at all, and riscv64 takes 0x38_0000_0000 by the same seven-eighths rule.

The page is far above every other low-half address because it is mapped into every x86_64 and riscv64 process unconditionally, rather than opted into by one program's own wiring. Any low-MiB address might be exactly what some program's segments or some fixture's window wants. A first attempt at 0x60_0000 collided with fixtures/src/window.rs's CTL_VA, which a full-suite run under script/test --arch x86_64 caught as AlreadyMapped. That collision is why this map exists (milestone 206 (a program image has under 896 KiB), DECISIONS §171 (where a program image starts) option D). Under the map the page belongs in PROCESS_PAGES, beside the stack, sharing its page tables. The crate's test module pins that it stays above every band meanwhile.

BUGS