decisions DECIDED

284. The kernel crate root splits into child modules, one per boot

Raised 2026-10-12 (UTC) as the cut that milestone 876 (the kernel crate root is split along its seams) says is calef's call before a line moves. Written by lane milestone/876-the-kernel-crate-root-is-split-along-its-seams. (Section number provisional until the merge queue lands it.)

It blocked the merge and nothing else. One question was raised, with a recommendation, and calef answered it. Every module name is provisional and is left to his naming pass.

The ruling

Question calef's words What it decides
Do the two per-architecture boots live at the crate root or under kernel/src/arch/<port>/? "We should treat them as temporary.", 2026-10-12 (UTC), recorded on PR #1965 A, the recommendation: the crate root.

The consequence is the reason. kernel/src/x86_64_boot.rs and kernel/src/riscv64_boot.rs are temporary. Each is its port's route until it joins the shared path in kernel/src/boot.rs, and the parity work shrinks each toward the CPU bring-up that does belong under kernel/src/arch/. They are not an architecture layer, so they do not move there. Each file's module doc says so. The work itself is proposed as design/roadmap/proposals/riscv64-and-x86-64-join-the-shared-boot-path.md.

What is already decided, and so not asked

The cut

Children of the crate root, each taking use super::*. An item a sibling calls is pub(super), which in a child of the crate root is the crate, so nothing widens. kernel_main, DTB and device_tree keep their paths through pub use. Names provisional.

file holds lines
lib.rs crate docs and attributes, mod lines, system_test_access, re-exports 293
boot.rs kernel_main, DTB, device_tree, bring_up_machine, interrupts_init, run_test_suite and its hook, run_measurement_boot 432
x86_64_boot.rs x86_64_boot, its six phases, x86_hand_over 768
riscv64_boot.rs riscv64_boot, its phases, micros, micros_between, bytes_per_second, mode_note, riscv_hand_over 1,093
milestone_tour.rs milestone_tour, tour_preemption, tour_el0, image_for_virtio 260
machine_description.rs print_machine_description, stack_top 206
tests.rs the seven boot self-tests, still crate::tests 124

lib.rs was 2,984 lines on main at 17b23264e, and 3,086 with the phase split in place. The two per-architecture boots carry their cfg(target_arch) on the declaration in lib.rs.

The question, as raised: do the two boots live at the crate root, or under kernel/src/arch/<port>/?

AGENTS.md rule 1 says all architecture-specific code lives under kernel/src/arch/, and names assembly, asm!, system registers and CPU-specific behavior. x86_64_boot and riscv64_boot run only on their architecture, so a reader can fairly expect them there.

What they hold, measured on this branch:

file asm! arch:: sched:: user:: drivers::
x86_64_boot.rs 0 93 9 7 0
riscv64_boot.rs 0 52 23 22 3

What arch/ reaches up into today: of 70 files across the three ports, 5 name sched (the trap and timer paths), 4 name drivers, and one names user, in a riscv64 MMU test.

Prior art, read on 2026-10-12 (UTC):

system where the per-architecture boot lives what it does there
Linux, init/main.c setup_arch, under arch/ CPU and memory setup. start_kernel, rest_init and kernel_init, which start the first user process, are generic in init/.
seL4, src/arch/arm/kernel/boot.c init_kernel and try_init_kernel, under src/arch/ CPU and platform setup, and it also builds the root task itself, calling generic helpers such as create_initial_thread and create_root_cnode.
Redox, src/arch/x86_shared/start.rs kstart and start, under src/arch/ CPU, paging, devices, then crate::startup::kmain, which is generic.

Alternatives

The block also gave a third reason for the crate root: helpers/lint_arch_parity.py skips files under arch/. That reason does not hold. A module declared cfg(target_arch = "x86_64") is checked against x86_64 alone, which the compiler already proves, so the lint adds nothing for either file wherever it lives.

The recommendation holds at equal cost: the two placements are the same move with different paths. It is about layering, not effort. It is reversible: if calef answers arch/, the two files move and nothing else changes, since no path outside the crate names them.

What it does not decide

BUGS