roadmap PARTIAL

890. riscv64 and x86_64 join the shared boot path

(The title and slug are provisional.)

calef, 2026-10-12 (UTC), ruling on §284 (the kernel crate root splits into child modules, one per boot): "We should treat them as temporary."

calef, 2026-10-19 (UTC), on the three per-port tours: "3". No per-port tours. Each claim the tours make becomes a check in self_test::run on every port where it applies, as milestone 268 (every architecture boots the same way) did for mapping and scheduler, and the tours and their port files go. The TOUR line and boot stage 11, which serial_console and the hang watcher read, get a new source in the same change.

Reuse: not applicable; this moves and deletes kernel code and adds none.

The problem

kernel_main in kernel/src/boot.rs hands x86_64 and riscv64 to their own boots, kernel/src/x86_64_boot.rs and kernel/src/riscv64_boot.rs, and only aarch64 continues through bring_up_machine and the shared path after it. Each port's boot is a chain of phase functions that brings up its own traps, memory, scheduler and interrupts, runs its own demonstrations, and ends at its own hand-over (x86_hand_over, riscv_hand_over). That is two copies of the boot's portable middle, written per port because the arch layer beneath the shared path was not built for either port when its boot was written.

calef's ruling makes both files temporary: each is its port's route until it joins the shared path, and the parity work shrinks it toward the CPU bring-up that belongs under kernel/src/arch/. Nothing yet tracks that work.

What it would take

Measured at the head of milestone 876 (the kernel crate root is split along its seams): x86_64_boot.rs holds six phase functions and x86_hand_over; riscv64_boot.rs holds nine, four timing helpers and riscv_hand_over. A lane would, per port:

  1. Sort each phase into what bring_up_machine already does portably, what is CPU bring-up and goes under arch/<port>/, and what is a demonstration the milestone tour already carries.
  2. Make the shared path take the port, so kernel_main stops branching on the architecture.
  3. Delete the port's boot file once it is empty, and the two hand-overs once the shared path's hand-over serves all three.

DECISIONS §19 (architectural parity is a tenet) is the reason. The riscv64 boot's middle stages are the only proof this tree has of them on real silicon (notes/visionfive2.md), so a lane keeps every transcript line serial_console reads, or moves its claim into the shared path first.

What the premises turned out to be

Checked against main at ee1f946ad before anything moved.

What was built: riscv64 runs the shared bring-up

The first slice, chosen because riscv64 shares the device tree and every portable step with aarch64. Which port goes first is reversible and nobody has acted on it.

The order on riscv64 changes in one way that matters: interrupts come on after the scheduler, as on aarch64, rather than before memory. The old order needed interrupts masked around sched::init for exactly that reason (riscv64_boot.rs, before this milestone), and the mask is gone with it.

What was built: the PLIC, and riscv64's tail

What was built: x86_64 runs the shared bring-up and tail

The order on x86_64 changes the way riscv64's did: interrupts come on after the scheduler, the IO APIC after the fine map, and the PIT's window runs with the scheduler up and the tick not yet armed.

What was built: the tours are the self-test's checks

calef, 2026-10-20 (UTC), on how a check reports a machine without its device: "Agreed", to a third outcome, absent. The condition: each serial_console board profile names the checks that may not be absent on that board, and reads such an absence as a failure.

Every claim the three tours made, and where each one is now:

Claim Tours that made it Now
Never-yield threads are preempted aarch64, riscv64 preemption, all three: one spinner more than cores online, none starved
A user-level program reaching a kernel address is killed; the kernel survives aarch64 (outlaw), riscv64 (outlaw, address space), x86_64 (a hand-built child) userspace, all three
A process spends its untyped and the kernel allocates nothing aarch64 (memory region) budget, all three; the process is killed and its region destroyed
A spawned kernel thread runs x86_64 (kernel task) scheduler
A user-level driver reads a file off a virtio disk, woken by its interrupt aarch64 (MMIO and PCIe); riscv64 (discovery) blockdev, all three; absent without a disk
A device's interrupt line reaches the CPU x86_64 (the PIT, in arch::irq::init); riscv64 (the UART, given a keystroke) deviceirq; absent on aarch64 and riscv64, where the hand-over's input driver proves the line
The machine's entropy source serves a client x86_64 (RDSEED), riscv64 (JH7110 TRNG) entropy, all three; absent with no TRNG or seed instruction
The JH7110's clock controller ungates the TRNG riscv64 clock; absent off a JH7110
The JH7110 TRNG's draws, timed riscv64 trng; absent off a JH7110
The boot's middle stages finished (boot_ladder::TOUR) riscv64 kernel_main, all three, after the verdict; the checks note stages 3 to 16 and 17 is finished
A faulting ring-3 thread's death reaches its supervisor; two rounds of children leak no frames x86_64 supervised and teardown, all three (milestone 944 (the self-test proves a supervised death and a teardown that leaks nothing))
A bare riscv64 ELF initrd runs riscv64 Gone: every boot carries an archive
Reports: image bounds, initial ramdisk, boot file aarch64, x86_64 The machine description's
An idle console server aarch64 Gone with console_service

Absences board profiles forbid: radon entropy, trng and clock; xenon entropy and deviceirq. The emulator profile, which boot-check and the soak use, forbids none. SELF_TEST_CHECKS_EARLIER (provisional) records the five-check list's length, so a captured log or an older image still reads green. milestone_tour.rs, riscv64_boot.rs, boot_demos.rs and console_service.rs are gone.

The xenon boot, and the screen half that remains

xenon is the one machine whose firmware places the APICs, the framebuffer and the BAR window for real. With no monitor attached it boots main to the prompt: the io apic, device irq and smp lines, every tour line, and echo hello echoing (bench/xenon-2026-10-21/README-890.md). With its monitor attached the hand-over panics before the prompt, the framebuffer driver did not come up (0xdead000000000002) (pull request #2528). One boot with the monitor, after that lands, closes the x86_64 half.

The radon boot: to the prompt, and every keystroke

radon netbooted twice on 2026-10-21 (UTC) from this milestone's branch, and both boots proved, on the JH7110:

bench/radon-2026-10-21/README-890.md lists every byte typed and what each boot ran.

Why radon took one keystroke per boot

The trap handler claimed source 32, cleared its enable bit on the claiming context, then wrote the completion. The PLIC specification ignores a completion for a source its target does not enable, and the JH7110's PLIC does, so its gateway waited for a completion it had already been sent and forwarded nothing more. QEMU's PLIC completes whatever it is given, so every gate passed.

The bench probe that showed it printed the UART's and the PLIC's state every 5 s, then completed source 32 on each context that enabled it (bench/radon-2026-10-21/890-plic-probe.log). After one keystroke a second sat in the UART, lsr=0x61 (data ready) and iir=0xc4 (receive data available), with the source enabled at priority 1 and pending=false. Each probe completion let exactly one more byte through.

The fix makes the claim the mask: the gateway holds a claimed source until its completion, so the handler leaves the source enabled, records the claiming context (arch::irq::hold_claim), and the driver's Irq ACK completes it there. drivers/plic.rs has no disable. The masked-line test's replayable falsification is an ACK that forgets its claim.

How userspace learns the UART's shape

The JH7110's UART registers are four bytes apart with 32-bit access (reg-shift = <2>, reg-io-width = <4>); QEMU's are one byte apart. The kernel passes the tree's shape as the progenitor's first start word, and the progenitor passes it to console and input (moho_abi::uart::RegisterShape). The console's wait for THRE is bounded at one second, so a wrong shape kills it with a load fault at the LSR offset it polled (stval 0x14 or 0x5). The timer tick tests for a stalled log drainer once a second (kernel_log::stall_tick), so that kill report reaches the wire.

Done when

  1. kernel/src/x86_64_boot.rs and kernel/src/riscv64_boot.rs are gone, or hold only what arch/<port>/ cannot.
  2. kernel_main has no cfg(target_arch) branch to a per-port boot.
  3. script/test, script/swish-check and the board's serial_console stages pass on all three.

Exit criteria, as built

criterion state
1 Done. riscv64_boot.rs and x86_64_boot.rs are gone.
2 Done. kernel_main's cfg(target_arch) lines are each port's banner and riscv64's console register shape; hand_over's one is x86_64's install offer.
3 Under QEMU, both ports: see each pull request's gate table. radon's half is the boot above; xenon's lacks only its boot with a monitor.

BUGS

Follow-on

Index row

Two of the three architectures boot through code that only they run, so a fix to the boot's middle lands three times or drifts. This brings riscv64 and x86_64 onto the path aarch64 takes, one slice at a time, until neither per-port boot file is left. Both ports run the shared bring-up and tail under QEMU, x86_64 through memory::init's PVH and ACPI front end, and the per-port tours are the self-test's checks on all three. radon runs both slices through the hand-over, its console now uses the UART's real stride, its prompt takes every keystroke, and xenon's boot with a monitor remains.