driver-domains

Design proposal: driver domains, and the DMA-confinement design space

Status: open idea. Not decided. It is the principled version of a hole we already closed in software (see notes/dma.md), and it would only be worth building alongside a real SMMU driver and a decision to run nife at EL2.

Owner: calef


What problem this is in the space of

Two problems that turn out to be the same problem:

  1. Confining a driver's DMA. A device is a second bus master. It does DMA against physical addresses and honors no page-table permissions, so a hostile driver that can aim the device can make it read or write any physical memory. The MMU, which confines everything else, does nothing here.
  2. Isolating a driver's faults at full strength. Milestone 8/9 already made a driver a process, so a driver bug is a crashed process. But a crashed driver today is not restarted, and a driver still shares the kernel's fate through any authority it holds (its interrupt, its MMIO, its DMA region).

Both are the question "how much can an untrusted driver hurt the rest of the system," and the strongest answer the industry has is: put the driver in its own virtual machine.

The three points in the design space

1. Software-mediated validation (what nife does today)

The kernel keeps the two DMA-critical powers (the queue's ring addresses and the notify) and validates every descriptor stays inside the driver's DMA region before the device sees it. See notes/dma.md. It closes the hole with no new hardware, at the cost of putting the virtio transport in the kernel. It is device-family-specific: the kernel understands the virtqueue layout, and a different device class (a NIC, say) would need its own validator.

Cheapest, works everywhere, least general.

2. An SMMU (ARM's IOMMU)

The hardware answer. The SMMU sits between devices and memory and translates every address a device emits through per-device (per-StreamID) tables the kernel programs. Point a driver's device at its own region and the SMMU confines it generically, with zero device knowledge in the kernel. This is what a real system does, and it is what DECISIONS ยง10 meant by "they had to bolt the isolation on afterwards with an IOMMU."

Not reachable from our current wiring: QEMU virt's SMMUv3 only covers the PCIe bus, so it would mean switching to virtio-pci and writing a PCIe enumerator and an SMMUv3 driver. Most general, real hardware, real work.

3. Driver domains (this proposal)

Run each driver in its own virtual machine, with nife as the hypervisor at EL2. The driver at guest EL1/EL0 talks to a device, and its DMA is confined by the SMMU's stage-2 tables that nife, as the hypervisor, programs for that domain. A compromised or crashed driver takes down its VM and nothing else; nife restarts the VM. This is the Xen "driver domain" / stub domain model, and the QubesOS "sys-net / sys-usb" model: the most dangerous, most bug-prone code (drivers) runs in disposable, DMA-confined boxes.

Most isolation, most infrastructure.

Why the driver-domain point is compelling

What it requires, and what blocks it

Where this sits relative to the microkernel philosophy

There is a real tension worth naming. A microkernel's whole thesis is a small privileged core. Becoming a hypervisor adds EL2 mechanism, a vGIC, stage-2 management, and a vCPU model to that core, which cuts against "small." The counter-argument, and the reason seL4 does exactly this, is that the added mechanism is general (it isolates any guest, not any specific device), so the privileged core stays conceptually simple even as it grows. It is still "isolate and route," now with VMs as the unit of isolation. Whether that trade is worth it for nife depends entirely on whether driver isolation at VM strength is a goal, or whether process-strength isolation plus software DMA validation is enough. For a learning OS, the latter has already taught the lesson; the former is a second, larger course.

Open questions

Verdict

Parked, and honestly the most interesting unbuilt direction in the project, but it is a milestone in its own right, not a fix. It only makes sense to reach for it once (a) there is a real SMMU driver, which is the same work option 2 needs, and (b) there is a reason to run nife at EL2 on bare metal. The software validation in notes/dma.md closed the actual hole; this is the principled shape the hole would take if the project decided driver isolation at VM strength was a goal worth its weight. If it is ever built, notes/dma.md's "the software version of the hypervisor's DMA-remapping role" becomes the real thing.