Skip to content

[1/3] aarch64: PCIe host-bridge (ECAM) transport - #92

Draft
maxandrews wants to merge 5 commits into
superradcompany:krunfrom
maxandrews:pr/pcie-ecam-host-bridge
Draft

[1/3] aarch64: PCIe host-bridge (ECAM) transport#92
maxandrews wants to merge 5 commits into
superradcompany:krunfrom
maxandrews:pr/pcie-ecam-host-bridge

Conversation

@maxandrews

Copy link
Copy Markdown

[1/3] aarch64: PCIe host-bridge (ECAM) transport

Introduces a feature-gated PCIe host bridge so an aarch64 libkrun guest can
enumerate a PCI Express bus. This is the foundation for VFIO device/GPU
passthrough, which lands in the two follow-up PRs of this stack.

What's in it

  • Ports Cloud Hypervisor's pci crate — ECAM (memory-mapped config) only, since
    aarch64 has no port I/O — adapted to libkrun's BusDevice model (which has no
    cross-vCPU Barrier return): PciConfiguration, PciBus, PciConfigMmio
    (ECAM), PciRoot host bridge, and the PciDevice trait.
  • fdt/aarch64.rs: emits a pci-host-ecam-generic node (ECAM reg + 32/64-bit
    ranges).
  • Registers the ECAM window on the MMIO bus + attaches the host bridge at 00:00.0.
  • New pci cargo feature (fanned out to msb_krun + vmm/devices), off by
    default
    — no change to existing builds.

Result: with --features pci, the guest enumerates an initially-empty PCIe bus
(host bridge at 0000:00:00.0, ECAM at the aperture defined in layout.rs).

Commits (5)

  1. aarch64: PCIe host-bridge memory-map constants (ECAM + 32/64-bit apertures)
  2. pci: port CH PCIe host-bridge (ECAM config, PciBus, PciConfiguration)
  3. pci: wire PCIe host bridge into aarch64 VMM (FDT node + ECAM on MMIO bus)
  4. pci: silence dead-code warning on DeviceIdState::Reserved
  5. pci: expose pci/vfio features on the msb_krun crate (src/krun)

Testing

Builds green with the pci feature; guest boots and enumerates the empty bus.

Stacked series (3 PRs, all against krun, reviewed/merged in order)

  1. this PR — PCIe host-bridge / ECAM transport
  2. VFIO device passthrough (config / BARs / DMA / KVM bind) — next
  3. MSI-X interrupt delivery + guest-driver enablement (→ nvidia-smi on a T4G)

Note: a historically-adjacent virtio-gpu Venus blob-mapping fix that sat at
the old branch base is excluded here — it's a separate track on
feat/gpu-venus-mapping-fixes. This series is rebased to contain only the
passthrough work.

🤖 Generated with Claude Code

maxandrews and others added 5 commits July 24, 2026 12:10
…tures)

CUDA_PASSTHROUGH Phase 1 step 0. QEMU-virt/Cloud-Hypervisor-compatible
windows, clear of the GIC and virtio-MMIO bands, valid for both boot modes.
ECAM 0x3000_0000 (1M), 32-bit MMIO 0x1000_0000 (512M), 64-bit MMIO
0x40_0000_0000 (256G). Foundation for the PCI transport + VFIO passthrough.
Phase 1 (steps 1-3 of CUDA_PASSTHROUGH_IMPL.md): a new src/devices/src/pci/
module ported from Cloud Hypervisor's pci crate, behind a new devices 'pci'
feature (+ a 'vfio' feature that depends on it). Trimmed of CH's serde snapshot
state, vm-migration hooks, live MsixConfig back-reference and vm-allocator BAR
hooks; byteorder replaced with native from_le_bytes. aarch64 is ECAM-only so
PciConfigIo is dropped, and PciConfigMmio is adapted to libkrun's BusDevice
(no cross-vCPU Barrier return).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqKBqYeUZbH9cmvs7G2qb7
…bus)

- fdt/aarch64: emit a pci-host-ecam-generic node (ECAM reg + 32/64-bit ranges)
  under the 'pci' feature.
- device_manager/mmio: register_pci() inserts PciConfigMmio at PCIE_ECAM_BASE.
- builder: attach_pci_root() creates the PciBus (host bridge at 00:00.0) with a
  no-op DeviceRelocation and registers the ECAM window; called during aarch64
  device setup. New StartMicrovmError::RegisterPciDevice.
- Cargo: 'pci' and 'vfio' feature fan-out across libkrun/vmm/devices crates.

Phase 1 (steps 1-3): guest should now enumerate an empty PCI bus.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqKBqYeUZbH9cmvs7G2qb7
msb builds msb_krun (src/krun), not the libkrun cdylib crate, so the pci/vfio
feature fan-out must exist here too.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqKBqYeUZbH9cmvs7G2qb7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant