roadmap BUILT

304. cargo kani -p kernel only ever compiled one architecture, and it was the runner's

The premise, re-measured rather than inherited

The proposal's claim was that arch/mod.rs selects its subtree with #[cfg(target_arch = ...)], that Kani compiles for the host, and that therefore the prover saw arch/aarch64/ and nothing else. AGENTS.md asks whether the premise is true before anything is built on it, and this tree has carried a wrong premise through every gate before, so it was checked with a probe rather than by reading.

Two deliberately-failing harnesses, one appended to arch/riscv64/mod.rs and one to arch/x86_64/mod.rs, then the suite on the dev Mac (aarch64-apple-darwin):

$ cargo kani -p kernel -Z unstable-options --ignore-global-asm --output-format=terse
Manual Harness Summary:
Complete - 4 successfully verified harnesses, 0 failures, 4 total.

Four harnesses, zero failures, with two harnesses present that assert false. Neither subtree was compiled at all. The premise is exactly true.

What it actually took, which was more than a row and a label

The proposal priced the mechanism as "a script/verify row and a runner label, both of which already exist in other shapes", and named one prerequisite: aarch64-cpu going behind a target cfg. That prerequisite was already done (2026-08-31, recorded in kernel/Cargo.toml's own comment), so the proposal was one item lighter than it thought and one item heavier than it knew.

arch/x86_64/ did not compile under Kani, and the reason was a toolchain skew rather than anything about the code. On cordoba, the project's x86_64 Linux box, with the same Kani 0.67.0:

error[E0133]: call to unsafe function `core::arch::x86_64::__cpuid` is unsafe and requires unsafe block
  --> kernel/src/arch/x86_64/isa.rs:49:17

Four of those, in isa.rs and mod.rs. __cpuid is a safe function on the toolchain this tree pins, which is why every call site read it bare and said so in a comment. It was an unsafe fn until upstream changed it, and Kani bundles its own rustc, ten months behind ours (kani-0.67.0 pins nightly-2025-11-21, rustc 1.93.0). The repo's own nightly compiles the same crate for x86_64-unknown-linux-gnu with no errors at all, which is how the skew was attributed rather than guessed at.

So arch/x86_64/ was out of the prover's reach for two independent reasons, and the proposal knew about one. The fix is isa::cpuid and isa::cpuid_count, two private helpers that wrap the intrinsic in an unsafe block the old toolchain needs and an #[allow(unused_unsafe)] the new one needs. That allow is an exception and is labeled as one where a reader meets it, per AGENTS.md's ladder: it is load-bearing for the prover and a foot gun for anyone who reads it as "this call wants auditing". It comes out when Kani's pin passes the change.

What the prover sees now

host arch/ subtree compiled harnesses run
aarch64 (dev Mac, ubuntu-24.04-arm runners) arch/aarch64/ 4: two in system_call.rs, two in arch/aarch64/iommu.rs
x86_64 (cordoba, the new ubuntu-24.04 runner) arch/x86_64/ 4: the same two in system_call.rs, two new in arch/x86_64/irq.rs
riscv64 nothing nothing here; milestone 589 reaches it

Six distinct harnesses in kernel, up from four. No harness went red on a newly-reachable architecture, which is the question this lane was sent to answer: the two portable system_call.rs properties pass on x86_64 exactly as they do on aarch64, so nothing there was quietly architecture-specific. That is a clean result and a small one, because the portable harnesses were the only pre-existing candidates. The two arch/aarch64/iommu.rs harnesses cannot run on an x86_64 host for the same cfg reason this milestone is about, and are not expected to.

riscv64 is out of this milestone's reach: GitHub offers no riscv64 image, stock Kani has no cross-target flag, and radon is a lab board, not a runner. Milestone 589 (Kani can prove riscv64 from the hosts we already have) reaches it, because CBMC checks riscv64 goto programs on any host: a carried Kani patch proves the kernel row for riscv64 from the arm64 runner.

The finding, which is worth more than the plumbing

Pointing a model checker at arch/x86_64/irq.rs for the first time produced a red harness, and the defect is real rather than an artifact of the harness.

an_owned_gsi_routes_inside_the_io_apic_band failed, with the counterexample base = 127, entries = 129, gsi = 255. redirection_index(255) returns Some(128), so this IO APIC owns that global interrupt; gsi_vector(255) is GSI_VECTOR_BASE.wrapping_add(255) = 0x2f, which is inside the local APIC's own vector band. enable passes that vector straight to route_gsi.

The plausible-hardware version of the same case is worse and needs nothing exotic: a second IO APIC owning global interrupts from 200, with the 24 redirection entries every real part has, admits GSI 210. gsi_vector(210) wraps to vector 2, the NMI.

MAX_REDIRECTION_ENTRIES's own doc claims this cannot happen. It is wrong about which quantity it bounds: it caps the entry count, not the GSI. The thing actually standing between a firmware-supplied GSI and a bad vector is route_gsi's panic, which is a dead kernel rather than a guarantee. Nothing has hit it because this kernel records one IO APIC and QEMU's q35 gives it base zero, where the flat map is exact.

It is recorded and not fixed, deliberately. The correct vector is GSI_VECTOR_BASE + redirection_index(gsi) rather than + gsi, and that costs gsi_vector its const fn, its total signature, and the "flat and reversible" property three doc comments in irq.rs and one in exceptions.rs rest on. That is a public-function signature change and a policy decision about multi-IO-APIC machines the kernel does not otherwise support, which is an architect's fork rather than this lane's. It leaves here in the two shapes AGENTS.md allows: a BUGS entry in irq.rs's module header, where a reader meets the feature, and design/roadmap/proposals/the-gsi-vector-map-wraps-on-a-second-io-apic.md.

The two new harnesses, and what falsified them

Both are in kernel/src/arch/x86_64/irq.rs, beside the code, under the stub list notes/kernel-proofs.md already enumerates. Both are about numbers firmware chose, which is the strongest case in this tree for a bounded model checker. A vector is an index into the IDT, so getting one wrong does not misroute an interrupt, it runs the page-fault handler.

Falsified twice, on cordoba, and the asymmetry is the honest half. Raising MAX_REDIRECTION_ENTRIES by one turns both red. Loosening redirection_index's own bound from index < entries to index <= entries turns only the second red, correctly: the first never calls the guard.

Both are recorded attested rather than replayable, and the reason is this milestone's own subject one level out. script/falsifications --sweep kernel runs a named harness on whatever host it is on, so a replayable record for an x86_64 harness would fail the sweep on the dev Mac and on every CI runner but the new one. That has been true of the arch.aarch64.iommu patches since milestone 255 wrote them, facing the other way, and went unnoticed because every machine here was aarch64. It is now in script/falsifications' BUGS.

Cost, measured

What this does not close

Follow-on

Index row

the prover compiled one architecture's arch/ and it was whichever the runner happened to be, so two thirds of the architecture layer was unreachable for a cfg rather than for an asm! block. the kernel row is now proved on an x86_64 host as well, which took four unsafe blocks Kani's ten-month-old bundled rustc still wants. The first proof ever pointed at arch/x86_64/ found a GSI that routes onto the NMI