[PATCH 00/14] Add Rust PCI SR-IOV support
From: Zhi Wang
Date: Tue Sep 15 2026 - 16:57:59 EST
Rust PCI drivers need to enable and disable SR-IOV and share selected
PF-owned functionality with their VF drivers. The shared data must remain
valid while a VF driver is bound, including when the VF driver is in C.
This series builds on Peter Colberg's Rust PCI SR-IOV v3 series [1],
extending it with typed PF registration data and C FFI support. The
registration design follows Danilo Krummrich's Rust vGPU/VFIO PoC [2].
As the discussion on Rust/VFIO support is still ongoing [3], this series
supports both C and Rust sample VF drivers.
Add the PCI SR-IOV operations and callback, managed VF removal during PF
unbind, and typed PF registration data. A pinned registration publishes
the PF payload. Rust VFs borrow the typed data directly; C VFs use an
ABI-checked descriptor and generated C-to-Rust trampolines.
Include Rust and C VF samples and integrate the registration into
nova-core. Nova implements sriov_configure() and publishes PF-readiness
data before VFs are enabled. Document the sharing interface, its borrow
lifetimes and teardown ordering.
[1] https://lore.kernel.org/rust-for-linux/20260303-rust-pci-sriov-v3-0-4443c35f0c88@xxxxxxxxxx/
[2] https://lore.kernel.org/nova-gpu/DLCRZLO06SIO.LS7TWQXIPZSQ@xxxxxxxxxx/
[3] https://lore.kernel.org/nova-gpu/20260914121217.70fa0d93@xxxxxxxxxxx/
John Hubbard (1):
rust: pci: add is_virtfn(), to check for VFs
Peter Colberg (7):
PCI: add driver flag to opt into disabling SR-IOV on remove()
rust: pci: add {enable,disable}_sriov(), to control SR-IOV capability
rust: pci: add vtable attribute to pci::Driver trait
rust: pci: add bus callback sriov_configure(), to control SR-IOV from
sysfs
rust: pci: add is_physfn(), to check for PFs
rust: pci: add num_vf(), to return number of VFs
samples: rust: add Rust SR-IOV VF driver sample
Zhi Wang (6):
rust: pci: add typed SR-IOV PF registration data
rust: add C-to-Rust FFI descriptors and trampolines
rust: pci: add C FFI support to typed SR-IOV PF registration data
samples: rust: add C SR-IOV VF driver that calls into a Rust PF driver
gpu: nova-core: publish typed SR-IOV PF data for VF drivers
Documentation: rust: explain SR-IOV PF data sharing with VFs
Documentation/rust/index.rst | 1 +
Documentation/rust/pci-sriov-pf-data.rst | 330 +++++++++++++++++++++
MAINTAINERS | 4 +
drivers/gpu/nova-core/driver.rs | 34 ++-
drivers/pci/iov.c | 103 ++++++-
drivers/pci/pci-driver.c | 3 +-
drivers/pci/pci.h | 2 +
include/linux/pci.h | 44 +++
include/linux/rust_ffi.h | 88 ++++++
rust/bindings/bindings_helper.h | 5 +
rust/kernel/interop.rs | 5 +-
rust/kernel/interop/ffi.rs | 252 ++++++++++++++++
rust/kernel/pci.rs | 126 ++++++++
rust/kernel/pci/sriov.rs | 355 +++++++++++++++++++++++
rust/macros/ffi_vtable.rs | 148 ++++++++++
rust/macros/lib.rs | 90 ++++++
samples/rust/Kconfig | 26 ++
samples/rust/Makefile | 2 +
samples/rust/rust_dma.rs | 1 +
samples/rust/rust_driver_auxiliary.rs | 1 +
samples/rust/rust_driver_pci.rs | 1 +
samples/rust/rust_driver_sriov.h | 27 ++
samples/rust/rust_driver_sriov.rs | 270 +++++++++++++++++
samples/rust/rust_driver_sriov_c_vf.c | 61 ++++
24 files changed, 1972 insertions(+), 7 deletions(-)
create mode 100644 Documentation/rust/pci-sriov-pf-data.rst
create mode 100644 include/linux/rust_ffi.h
create mode 100644 rust/kernel/interop/ffi.rs
create mode 100644 rust/kernel/pci/sriov.rs
create mode 100644 rust/macros/ffi_vtable.rs
create mode 100644 samples/rust/rust_driver_sriov.h
create mode 100644 samples/rust/rust_driver_sriov.rs
create mode 100644 samples/rust/rust_driver_sriov_c_vf.c
base-commit: 34a8ecc902e907d7b0596a8d38b437e90eac0701