roadmap PARTIAL

1062. The device control planes leave the kernel

(The number, title and slug are provisional.)

Reuse: the shape is the tree's own. Milestone 242 (xHCI) already splits a device this way, and milestone 811 (the boot services leave the kernel) supplies the grants. No outside code fits a capability split of nife's own kernel, so this lane searched only the tree.

The kernel holds only what must run at EL1 plus what a confinement argument needs (§4 (kernel shape)), and confinement means an IOMMU (§86 (whether an NVMe driver can leave the kernel)). A device's control plane is neither. On a machine with an IOMMU the IOMMU confines the device; on a machine without one nife trusts the driver wherever its control plane runs. So each control plane the kernel carries today moves to a userspace process, and the kernel keeps only the confinement: it binds the device's requester id to its DMA region and grants the device's pages.

Ruled 2026-11-10 (UTC). The order follows the dependencies, and each step is one pull request.

The work, in order

  1. e1000e to the xHCI shape, after milestone 811 (the boot services leave the kernel)'s step 6. The kernel confines the controller and grants all of BAR0 and the DMA run to a userspace control process. That process keeps BAR0's pages 0 and 5 (reset, MAC address, PHY, filters) and grants the queue pages to net_stack, the shape milestone 242 (xHCI) has for USB. kernel/src/e1000e.rs goes, and the kernel stops linking crates/e1000e. Waiting for 811's step 6 keeps the starter and the control plane from moving twice.
  2. The JH7110 clock and reset server. A userspace server holds the shared clock and reset window, which serves USB, PCIe, DMA, the security block and Ethernet. It answers the device-level verbs of §320 (the JH7110 clock and reset wire): the badge is the device, and a client brings up, reads and rates its own device's clocks and resets and never touches another's. No verb turns a device off. The verbs live in a contract crate both sides depend on (§311 (a contract is code, not prose)), at interface id 24. The names ship provisional. kernel/src/drivers/jh7110_clock_and_reset.rs shrinks to what the kernel's own JH7110 watchdog (milestone 593 (a wedged kernel resets itself)) needs to turn its clock on, and the entropy and Ethernet bring-ups ask the server instead. SD/MMC starters and step 5's PMIC route ask it too.
  3. The DesignWare GMAC control plane. Its clocks and resets come up through step 2's bring-up verb, and a userspace control process holds the channel and MAC pages. kernel/src/designware_ethernet.rs goes, and kernel/Cargo.toml stops naming the crate. radon proves it.
  4. The NVMe admin plane, as §86 states it: a userspace admin process holds BAR0 and the admin queues and grants the data-path driver its doorbell page and I/O queues. The admin half of kernel/src/non_volatile_memory_express.rs goes. The split keeps §86's option 4 addable. Built: #3427.
  5. The JH7110 PMIC route, as §251 (restarting the machine is a kernel object the progenitor hands out) states it. components/src/power_management_chip_route.rs holds the I2C5 controller's page as a DeviceFrame and writes the AXP15060, after its starter brings I2C5 up through the step 2 server (§320 (the JH7110 clock and reset wire)). reboot calls it, then REBOOT; the route bounds its wait. The kernel holds no I2C master. radon proves it.
  6. The x86 CMOS read, as §130 (how the userspace clock service reads the x86 CMOS RTC) states it: the clock service holds a PortRange over ports 0x70 and 0x71 and reads the CMOS itself. clock_contract::rtc::CMOS names the two ports the service reads, and the kernel reads no CMOS. Built: #3426.
  7. A virtio driver starts with a mediated or a direct grant (§23 (multi-queue DMA confinement)), as the next section designs it. Ruled 2026-11-10 (UTC). That section lists its four pull requests.

Every new program, process, crate and verb ships with a provisional name.

Step 7: a mediated or a direct virtio grant

Ruled 2026-11-10 (UTC). The starter that spawns a virtio driver grants its device in one of two ways, and the grant decides how the driver reaches the device. The kernel has no mode flag, no build feature and no boot parameter for it, and the choice can differ per device.

The direct grant applies to virtio-pci devices only while the runners keep virtio-mmio. On aarch64's virt the virtio-mmio slots sit 0x200 apart (VIRTUAL_IO_SLOT_STRIDE), so one 4 KiB page holds eight devices' registers, and no IOMMU fronts virtio-mmio on any machine nife runs on.

A new VirtualIo method that switches a device to direct, or a new object kind for a direct transport, would each add to the system call surface what a grant of frames already says, so the design uses neither.

What the starter carves out

pci::bring_up has already placed the function's BARs, enabled decoding and bus mastering, armed its interrupt and read its virtio capability list. For a direct grant the starter then does four things, in this order.

  1. It confines the function with iommu::confine over the driver's DMA region alone, before any queue exists. It maps no shadow page, because none exists.
  2. It maps, device-typed, the pages that hold the four virtio-pci structures the capability list names (common configuration, notify, ISR and device configuration, virtio 1.2 section 4.1.4), and nothing else of the BARs. A page that holds the function's MSI-X table or pending-bit array is never mapped, as PciXhciDevice::withheld keeps them from the xHCI driver, and a function whose structures share a page with either gets the mediated grant. The structures lie in the function's own BARs, so no mapped page holds another device's registers.
  3. It writes the startup page: one window for each run of register pages and one for the DMA region. The handoff carries what a window cannot: each structure's byte offset in its window, notify_off_multiplier, the MSI-X table entry the kernel armed (or none), and the region's bus address. That address is the physical one, because every domain is an identity map (kernel/src/iommu.rs). The window kinds and the packed handoff live in a new driver_process_contract::virtio module (provisional) that both sides use (§311 (a contract is code, not prose)).
  4. It grants the Interrupt capability, as it does for a mediated driver.

The region and its domain live as long as the function does, as the xHCI driver's region does. The starter allocates the region zeroed and never returns it to the allocator while the domain maps it, so a driver that dies with a queue running leaves a device that can reach only that region. A driver started on the same function resets the device first, by writing 0 to device_status (virtio 1.2 section 2.1). A mediated device keeps its own reset in virtio::unregister.

Why the IOMMU is enough

The direct driver writes every ring address the device reads. The domain maps only the driver's region, so a descriptor, ring or buffer aimed anywhere else faults at the IOMMU and never reaches memory (§20 (IOMMU-backed DMA isolation), §86 (whether an NVMe driver can leave the kernel)). The register pages give the driver nothing beyond its own function. The common configuration selects that function's features, queues and MSI-X table entries, and an entry the kernel did not arm stays masked, which is its reset state. Configuration space stays with the kernel, so the driver cannot move a BAR, change its requester id or reach the VIRTIO_PCI_CAP_PCI_CFG window.

One condition holds the argument up. A virtio device may treat a driver that declines VIRTIO_F_ACCESS_PLATFORM as one whose addresses are physical and untranslated (virtio 1.2 section 6). The runners attach every virtio-pci function with iommu_platform=on (§20). There QEMU sends the function's DMA through the IOMMU, and it refuses FEATURES_OK to a driver that declines the bit (reset_to_features_ok in kernel/src/virtual_io.rs records it). So a direct grant counts as confined only when the function offers ACCESS_PLATFORM and the active IOMMU owns its requester id (iommu::Scope::is_confining). Without both, nothing confines a direct driver, and nife trusts it as it trusts an NVMe driver on a machine without an IOMMU.

Interrupts

A direct driver takes the same line or vector a mediated one does.

A line routes to one driver (kernel/src/sched/interrupt_route.rs), so a direct driver meets the limit a mediated one meets, and milestone 1065 (MSI replaces the interrupt lines on aarch64 and riscv64) lifts it for both. Until that lands, a direct driver's test reads its used ring before it blocks, as the entropy driver does.

What stays in kernel/src/virtual_io.rs

All of it, for the mediated grant: both transports, register, setup_queue, notify, the validator adapter, the shadow page, the reset in unregister, release_owned_by and the test hooks. A direct function never reaches virtio::register, so the device table, its MAXIMUM_DEVICES and the shadow frames count mediated devices only. The Kani harnesses and the seven patches in crates/direct_memory_access_validator/falsifications prove the crate, not a boot, so both run unchanged, and notify still calls the validator, so kani-reach.yml holds.

Which grant, by default

Ruled 2026-11-11 (UTC). A starter gives the direct grant to a virtio-pci function the IOMMU confines, which takes all three of these:

Every other function gets the mediated grant, and so does every virtio-mmio device. §23 says where the validator runs and what it claims without an IOMMU. The rule lives in the starter, never in the kernel.

Prior art

nife differs in two ways. A starter chooses the grant per device when the driver starts, not once per boot or per binding. And a device the starter will not hand over keeps a mediated path whose validator has a Kani proof.

An example

The x86_64 runner attaches virtio-blk-pci,iommu_platform=on behind intel-iommu. A starter that grants it direct confines its requester id to the driver's DMA region and maps the pages of the four structures. QEMU places them at 0x0, 0x1000, 0x2000 and 0x3000 of BAR4, and the MSI-X table in BAR1. The starter reads the capability list instead. It lists the pages on the startup page and passes notify_off_multiplier 4 and MSI-X entry 0. The driver writes 0 to device_status, accepts VERSION_1 and ACCESS_PLATFORM, selects queue 0, writes ring addresses inside its region, enables the queue and sets DRIVER_OK. To submit a read it publishes the descriptor and stores the queue number at queue_notify_off * 4 in the notify page: one store, no system call. A descriptor aimed at kernel memory faults at the IOMMU, where the mediated grant refuses it at NOTIFY with DmaEscape.

Tests, proofs and starters

The surface

No system call, object kind or method changes: DeviceFrame, Interrupt and the startup page already exist. What is new is the driver_process_contract::virtio module (its window kinds and handoff, provisional) and a virtio-pci transport in userspace that drives the mapped pages.

Cost and effort

Not measured yet. A mediated NOTIFY costs a system call, the validation and a copy of the new descriptors. A direct one costs an uncached store from EL0. The last pull request measures both on a PCI disk with script/bench. The work is medium, and the line counts are guesses: about 120 for the starter's carve-out, 80 for the contract, 200 for the userspace transport and 200 of tests.

Order of work

  1. The contract: driver_process_contract::virtio, its window kinds and handoff, with tests.
  2. The starter's carve-out: the confinement, the four structures' pages, the withheld MSI-X pages, the ACCESS_PLATFORM and requester id checks, and the startup page, with unit tests.
  3. The driver's direct transport in userspace and the direct disk system test on all three architectures.
  4. The measurement.

Done when

  1. None of the files that steps 1, 3, 5 and 6 remove exists, the kernel's clock and reset driver serves only its watchdog, and kernel/Cargo.toml names neither e1000e nor designware_ethernet.
  2. The existing gates for each device pass on every architecture it runs on, with no test weakened. That means the e1000e, NVMe and virtio gates under QEMU, the clock tests on x86_64 with a wall clock, and radon's Ethernet and reboot bench boots.
  3. reboot on radon resets the board through the userspace route. Without it, radon's firmware hangs on REBOOT's SBI SRST.
  4. script/fastpath-footprint reports no change: none of these paths is hot.
  5. A virtio-pci driver runs on either grant, each starter grants as the default above states, and CI runs the direct and the mediated path on all three architectures.

Follow-on

Index row

The kernel still carries the control planes of e1000e, the GMAC, NVMe, the JH7110's clock and reset block and its PMIC, and reads the x86 CMOS itself. None of that must run at EL1, and none of it confines DMA, which is the IOMMU's job. This moves each one to a userspace process and takes about 1,500 kernel lines and two driver crates out of the trusted base. The virtio validator stays for a device granted mediated, and a starter may grant a virtio-pci device's registers directly behind the IOMMU.