notes

Proving riscv64's IOMMU driver from an aarch64 host

Name: ratified 2026-10-18 (calef, convention-rulings Rule 3).

An appendix to notes/kernel-proofs.md, which links here from its stub-list item 8. It is milestone 432 (the RISC-V IOMMU driver has no counterpart to the SMMU's proofs), built as option 1 of the proposal that measured it.

A correction first

kernel-proofs.md said riscv64 was unreachable, and that iommu.rs's own property "can be written and cannot be run". That was true of the cfg dispatch in arch/mod.rs. It was not true of the files the dispatch hides. A riscv64 file with no asm! and no riscv64-only sibling compiles unchanged on an aarch64 host. The lane/price-kani-kernel-reach lane measured this on 2026-09-24.

Native riscv64 proof is still out of reach. Stock Kani panics on a riscv64 host, and nothing here runs one.

How the file reaches the prover

kernel/src/arch/mod.rs holds mod riscv64 { mod iommu; } under cfg(all(kani, target_arch = "aarch64")). No #[path] is needed, because an inline module in a mod.rs resolves mod iommu; to arch/riscv64/iommu.rs on its own. The harness paths are the native ones, arch::riscv64::iommu::proofs::..., so script/falsifications derives their patch names with no special case.

It is aarch64 only on purpose. Exactly one verify host should run it, and whether x86_64 resolves the same names was not measured.

The caveat: crate::arch is the host's

Inside that module, crate::arch means aarch64. So iommu.rs's call to crate::arch::mmu::phys_to_virt silently resolves to aarch64's function. A harness that reached it would prove aarch64's code under riscv64's name. That is the stub that reads as coverage, which the parent note exists to prevent.

Only code that never calls through crate::arch is proved here. The three harnesses call five pure functions and nothing else: device_context, directory_limit, directory_position, non_leaf_entry and iodir_inval_ddt.

script/lint check 5b holds the line. It records each crate::arch path a file in the module names, with why no harness reaches it, and fails on a new one or a new file. It is a grep, not a call graph, so it cannot prove reachability. It forces the question at the moment it becomes live.

Extending the module to every asm-free riscv64 file was refused, in the proposal's option 2. mmu.rs and timer.rs call crate::arch throughout, so their proofs would be fictions.

The three properties

The SMMU's first property does not transfer. This driver writes whole 64-bit words, so there is no split for an address to lose half of. Milestone 432's block said finding the right property was most of the work.

the_iommu_is_handed_exactly_the_domain_the_kernel_built:

no_device_can_reach_another_devices_context:

the_root_entry_names_exactly_the_leaf:

Falsified before believed

The three patches are in kernel/falsifications/ and replay on an aarch64 host.

One leaves the one-level directory's stride under the two-level one: the leaf is right and the offset is rid * dc_bytes. It agrees with the right offset for every id below 64, and writes past the leaf for every id above.

One writes the leaf's address into the root entry as it is, rather than as a PPN at bit 10, so the IOMMU walks a frame four times the leaf's address.

The other gives iosatp the (pa >> 12) << 10 encoding that three neighbors in the same file use. It turns MODE red for a high enough root. The boot confinement test would probably catch it too; that was reasoned, not run.

Cost

On patagonia the new harnesses verify in 2.6 and 4.2 seconds. The whole cargo kani -p kernel run stays near 400 MB peak resident.

BUGS