notes

The boot self-test's checks: what each proves, and why it is built that way

Name: provisional, minted 2026-10-23 (UTC) by comments/929-kernel-system-call-selftest.

The second rung of the boot ladder runs in two halves: kernel/src/self_test.rs checks the kernel's own internals, and components/src/boot_self_test.rs runs the checks that need a user program. boot-ladder.md has the contract: the verdict line, absent, the board profiles, and why a failure prints and the boot carries on. This note carries the design of the checks themselves, which the modules' doc comments link to. The checks are the claims the per-port tours made, run on every port (calef, 2026-10-19 UTC, on #2434), and absent is calef's ruling of 2026-10-20 (UTC) on #2447.

The two halves

The kernel runs exceptions, mapping, frames, timer, scheduler, preemption and device_interrupt, prints their lines and then boot_ladder::Heads::tour's. No check there spawns a user program or starts a service, so a kernel that leaves services to userspace keeps its self-test. The other eight, userspace, budget, supervised, teardown, block_device, clock, true_random_number_generator and entropy, run in boot_self_test, which the progenitor builds before the shell.

The verdict's mechanics

Injection

The feature self_test_injection makes one check in each half fail, exceptions in the kernel and userspace in the program, which reads it from the kernel's half. It also stops the counter the kernel's checks read, so cargo xtask boot-check --inject can watch the gate go red, and it requires both names. A verdict that has never been red is untested. The stopped counter is the fault that once hung timer forever, so every injected run also proves the waits are bounded. It is a cfg! rather than a #[cfg] block, so both arms compile on every build and the injector cannot rot unnoticed.

Bounded waits: Counter

Every wait is bounded by the free-running counter, which makes a number mean the same thing on a 62.5 MHz generic timer, a 10 MHz rdtime (4 MHz on the JH7110) and a TSC. On a broken machine the counter is the thing in doubt, so Counter reports a stall rather than wait on it. A spin calls a counter stopped after a million unchanged reads, far longer than the slowest counter's 250 ns period. A wait that yields calls it stopped after a hundred looks, because with preemption's spinners runnable each look can cost a whole tick; a million looks would be three hours.

The checks

A draw passes when it is ready, two full 32-byte buffers come back, they are not all zeros, and they differ. One draw proves only that something was returned: a stuck register file, a driver serving its buffer twice and a device that never started all present as a repeat.

The TRNG's numbers

The timings print in microseconds, because a tick is a different length on every board and the interesting half of the number is an IPC round trip. The rate comes from the device tree, so there is no constant to go stale. The bytes-per-second figure counts everything from the readiness report to the last byte: four entropy_contract round trips per draw, their context switches, the driver's poll loop and the device. It leaves out the spawn and bring-up, which print separately. So it is not comparable to a Linux hwrng figure, which reads an already-running kernel driver with no IPC in it.

STAT.R256 says whether the TRNG gives 256-bit answers. In 128-bit mode only RAND0..RAND3 carry one, so a driver assembling all eight words serves 16 real bytes in 32. The driver sets MODE.R256 because the width a JH7110 resets to is a build-time parameter of the silicon, and the read-back says whether it took; nothing has ever read it on hardware. An all-zero STAT is a register window that answered nothing, which the clock line explains.

BUGS