notes

Scoping a PCIe transport (and virtio-pci)

Built (2026-07-27): all four phases. DECISIONS ยง18 records the decisions (INTx first, one driver behind a kernel-side transport seam, mmio stays on aarch64); notes/pcie.md is the after-the-build companion. One premise of this scope died on contact with the machine: parity C was never actually blocked on PCIe (see the correction in notes/riscv-parity-scope.md), so the transport was built on its own justification below, and C completed over both transports. The rest of this note is the scope as written before the build.

Parity workstream C stalled because QEMU's riscv virt does not put a virtio-blk device on the virtio-mmio slots; it uses PCIe, the transport real hardware uses. This scopes a PCIe root complex and a virtio-pci transport as its own workstream. It is bigger than a virtio detail: a PCI enumerator is the door to NVMe, real NICs, and anything past a handful of hand-placed MMIO devices, and it is table stakes for "runs real workloads."

It is portable. Both QEMU virt boards expose a pci-host-ecam-generic host bridge; only the ECAM base, the BAR windows, and the interrupt routing differ, and all three come from the device tree. So this subsystem proves itself on aarch64 and RISC-V from one implementation, the way the capability core does.

What does not change: the virtqueues, the descriptor/available/used rings, the DMA against physical addresses, and therefore the whole DMA-confinement design (the kernel-owned shadow ring, the address validator). PCIe is an enumeration-and-addressing layer under the same virtio you have. The concentrated new work is PCI config-space enumeration and virtio-pci capability parsing.

Concrete addresses (QEMU riscv virt, from the DTB pci@30000000):

ECAM config space   0x3000_0000, size 0x1000_0000   (256 buses x 4 KB per function)
32-bit MMIO window   0x4000_0000, size 0x4000_0000   (where BARs are assigned)
64-bit MMIO window   0x4_0000_0000                    (large BARs)
INTx -> PLIC          interrupts 0x20..0x23 (32..35), by (device, pin) via interrupt-map
host bridge          compatible = "pci-host-ecam-generic", bus-range 0..255

Effort is session-sized: S = part of a session, M = one to two, L = several.


Phases

P1. PCI config space + enumeration: M, low-medium risk.

P2. BARs + virtio-pci capability parsing: M, medium risk.

P3. Interrupt routing (INTx via the PLIC): S-M, medium risk.

P4. Wire virtio-pci to the driver and the DMA confinement: L, medium-high risk.


Decisions to raise before building

  1. INTx vs MSI-X. Recommend INTx first (matches the PLIC/Interrupt-cap model; MSI-X is a later enhancement).
  2. One driver, two transports, or two drivers. Recommend a thin transport abstraction so the virtqueue/DMA/confinement logic and the userspace block driver are shared between mmio and pci. This keeps the intricate, security-critical code (the validator, the shadow ring) in one place.
  3. Keep virtio-mmio? aarch64's mmio path works and its tests pass; no need to migrate it. PCIe becomes the RISC-V disk path and a demonstrated portable subsystem. Both could eventually use PCIe, but there is no reason to disturb a working, tested mmio path to do it.

Sequence and dependencies

P1 (enumerate) -> P2 (BARs + caps) -> P3 (INTx) -> P4 (transport + driver)

Strictly linear: each phase needs the previous. P1-P3 are the new PCI machinery (bounded, well specified). P4 is where it meets the existing virtio and is the largest, because it introduces the transport seam and adapts the confinement. Overall size is comparable to the SMP workstream: a real subsystem, not a tweak.

Relation to other work