notes

Booting the progenitor: the boot capability set

Name: provisional, minted 2026-10-23 (UTC) by comments/929-kernel-user-boot.

The kernel's last act at boot is user::boot_progenitor (kernel/src/user/progenitor_boot.rs). It loads the progenitor, measures it, builds its address space, grants it a fixed table of capabilities and starts it. From those capabilities and nothing else, crates/system_initializer builds the console server, the input driver, the line discipline and the shell out of the progenitor's own budget. This note carries the design of the kernel's half: the slot layout, why each grant has the rights it has, and which devices the kernel starts itself. How the progenitor loads its children is in the progenitor and loading.

What the kernel does, in order

  1. It reads the progenitor out of the archive and checks it against the trust root under its own name, before its address space exists (milestone 22 (trusted init) phase B.1). The progenitor is this board's boot program, so it is in the trust root like any boot program. Then it requires the program-measurement table the progenitor checks every load against (milestone 104 (the measurement continues past init)). The kernel holds both to the loader's two command-line words as well (milestone 695 (the kernel trusts two digests from the loader)).
  2. It builds the address space: the segments, a stack of PROGENITOR_STACK_PAGES, and the timebase page where the architecture has one. The whole initial ramdisk is mapped read-only at INITIAL_RAMDISK_VIRTUAL_ADDRESS, so the progenitor can parse the archive and load the rest by name. The archive's pages are mapped with map_physical, which records each mapping in this space's own log. That window is the largest in the tree (the aarch64 archive is a few thousand pages), so its log pages are budgeted at the call site with crate::revoke::log_pages_for. Each stack page is painted, so crate::progenitor_stack can say how deep the stack has been.
  3. It routes the UART receive interrupt to an endpoint, creates the thread, and grants the slots.
  4. It configures and starts the thread with three START words: the console UART's register shape (moho_abi::uart), the archive's length, and the file service's rights (0 for none).
  5. It arms the interrupts that must wait for the driver to run, and returns without blocking.

The UART's interrupt number comes from the machine's own description when it gave one, else QEMU virt's constant. The boot prints it with its source, because a wrong PLIC source once cost a boot on the JH7110 (the VisionFive 2, BUGS). On riscv64 it also prints the UART's register stride and access width. The stride is the one fact about this UART the userspace drivers cannot see for themselves, and a wrong one is a console that prints nothing.

The slot layout

The layout is the same on all three architectures. components/src/progenitor.rs's GRANTS table reads it.

slot what rights granted
0 the root building budget (12,288 pages) the root's, GRANT included always
1 the console device WRITE | GRANT always
2 the UART receive interrupt READ | GRANT always
3 the clock page READ | GRANT always
4 the inert-configuration page READ | GRANT always
5, 6 the file service endpoint and its client-window pool WRITE | GRANT with a filesystem
7 to 9 virtio-rng: transport, interrupt, DMA page GRANT on each with a virtio-rng
10, 11 the firmware-screen terminal: endpoint, output page GRANT on each with a UEFI screen and no GPU
12 the gpu's surface run READ | WRITE | GRANT with a virtio-gpu
13 to 15 virtio-net: transport, interrupt, DMA page GRANT on each with a virtio-net NIC
16 the instruction entropy service's request endpoint WRITE | GRANT with no virtio-rng
17 to 19 the gpu's transport, interrupt and DMA run GRANT on each with a virtio-gpu
20 to 22 the virtio keyboard's transport, interrupt, DMA page GRANT on each with a gpu and a keyboard
23 the machine statistics page READ | GRANT always
24 to 26 the kernel's log ring, cursor page, notification ring READ, the rest READ | WRITE; GRANT on each when allocated
27 a USB keyboard driver's attach endpoint WRITE | GRANT with an xHCI controller
28 the progenitor's own address space WRITE always
29, 30 a kernel-built network stack: Stack endpoint, lease endpoint all rights; READ with an e1000e or radon's port, and no virtio-net
31 the reboot object WRITE | GRANT always
32, 33 the disk tree's endpoint and client-window pool WRITE | GRANT with an NVMe disk beside a file service
34 the base digest page READ always
41 the board's PMIC route (milestone 1062 (the device control planes leave the kernel), step 5) WRITE | GRANT with a PMIC bus in the tree

The table has 64 slots (crate::cap::CAPABILITY_TABLE_SLOTS), and the ones above 41 are the progenitor's own to fill.

Why every slot is explicit

The progenitor reads its table positionally. A capability whose slot depends on what the machine turned out to have is wiring nobody can check by reading. So every grant names its slot (thread_control_block_insert_capability(.., Some(n))) rather than taking the first free one, and asserts where it landed (notes/abi.md section 4). First-free numbering would shift the virtio-rng trio down by two on the ordinary boot that has a virtio-rng and no disk. Each conditional group sits past the highest slot of every group before it, for the same reason.

An optional grant that is absent is an empty slot. The progenitor tells it apart by probing: invoke on an ungranted slot answers NoSuchSlot.

The pages granted on every boot are granted even when there is nothing to say. With no clock program in the archive, the clock page is a zeroed frame, which reads as clock_contract::state::UNKNOWN (a_zeroed_page_reads_as_unknown): the honest "the machine has no clock it believes". The configuration page is always the least-assuming defaults (UTC, C, dumb), the same ones the kernel's std harness uses (system_tests/src/user/std_service.rs). There is no shell-held configuration to pass instead yet; the shape it would take is design/roadmap/0047-navigation-and-naming/environment.md's "inheritance with visibility".

The rights, slot by slot

Arming the interrupts

Two hardware differences are #[cfg]-gated: the console device, above, and when an interrupt source is armed.

The virtio starters therefore hand back an interrupt that is routed but not enabled (VirtualIoBootGrant::intid), and the caller enables it beside the UART's.

The installed boot's confirmation

On x86_64, when a boot chooser started this boot, boot_progenitor calls install_service::confirm to say the boot worked (milestone 198 (a package manager)'s rung 2b). The position is the mechanism. The filesystem server granted just before has mounted the installed disk and reported ready, which is as late a criterion as the system can evaluate without a person. The installer stages in a transfer window of its own, so nothing else on the disk constrains when.

Which devices the kernel starts itself

Most device authority goes to the progenitor raw, and the progenitor builds the driver. The kernel starts a driver itself only where the progenitor could not build it as well.

The virtio-rng and virtio-net devices are only discovered and wired: a zeroed DMA frame with its own physical base written at DIRECT_MEMORY_ACCESS_REGION_BASE_PHYSICAL_ADDRESS_WORD_OFFSET, the interrupt routed, and the transport registered and confined to that frame. Only the MMIO transport is used, a first cut scoped to what an interactive boot needs; PCIe behind the IOMMU is follow-on work. The progenitor builds the entropy service and net_stack from the three capabilities, with crates/system_initializer's ELF loader, the tree's only one (milestone 96 (one init)).

A driver writes physical addresses into virtio descriptors, and no capability exposes one. The DMA page's base is therefore written into the page itself. The progenitor maps the granted frame briefly, reads the base back out once, and relays it as the driver's arg1, the way it relays fs_rights.

The refusal of a seed instruction that fails its first draw, and the screen handover's order, are in the device details.

The graphics grants

Nothing is built from the gpu and keyboard at boot (milestone 632 (graphics on demand), calef's 2026-09-30 ruling): the boot stays the minimal UART system, and graphics is launched from the swish prompt. The progenitor hands the grants to the shell, which holds them until a graphical_terminal session's spawn hands them back for the drivers to be built from, as it does with the statistics page.

The gpu is four capabilities and the keyboard three. DECISIONS §102 (a Frame names a run of pages) gives a PageFrame a page count, and milestone 142 (a text display good enough that people use it) made the gpu's region one run and one capability (display_service::wire_device). The driver gets the whole run and the terminal only the surface after its first page, which is the split display_service::start_terminal makes. Nothing lets a holder narrow a run, so the kernel mints both frame capabilities over the one region.

A keyboard is wired only beside a gpu, because a keyboard with no screen has no terminal to type into. With no virtio keyboard, a graphical session takes its keystrokes from the boot's UART line discipline (milestone 192 (a keyboard on real silicon)'s option A).

The ELF child builders

The test suite's six ELF child builders get a bare five-slot world of their own from user::spawn_elf_child_builder, which is not the boot path. The child builders has their slots and why the building budget is lent rather than spent.

The stack

PROGENITOR_STACK_PAGES is fourteen pages. Debug, the build script/swish-check and CI boot, is the deep one, because system_initializer::boot's frame stays live under the spawn service. The progenitor's stack has the measurements and the frames.