[PATCH 0/1] Rust PCI capability infrastructure and SR-IOV support
From: Zhi Wang
Date: Thu Apr 09 2026 - 14:53:46 EST
This is a follow-up to the RFC v2 series [1], reworked on top of Gary's
io_projection patches [2] to use the Io/IoCapable/View infrastructure.
This patch has been used in Boot GSP with vGPU enabled series [3].
This patch introduces ExtCapability<T>, which implements the Io trait
for PCI extended capability regions. It delegates IoCapable to the
underlying ConfigSpace, so io_project!/io_read!/io_write! work directly
on capability register structs. ExtSriovRegs provides the #[repr(C)]
SR-IOV register layout, and ExtSriovCapability is a convenience alias.
Changes since RFC v2:
- Hardened calculate_ext_cap_size() against corrupt capability lists.
- Added // INVARIANT: comments at all ExtCapability construction sites
(make_ext_capability and cast_sized).
- Added #[inline] to small forwarding methods (find, read_vf_bar64)
Changes since RFC:
- Rebased on io_projection branch, using Gary's Io/IoCapable traits
- ExtCapability implements Io and delegates IoCapable to ConfigSpace
instead of duplicating config read/write logic
- Dropped the fallible I/O patch (now upstream in this tree)
- Added rust helper for PCI_EXT_CAP_NEXT() macro
- Replaced raw `as` casts with From conversions where possible
- Renamed SriovRegs/SriovCapability to ExtSriovRegs/ExtSriovCapability
[1] https://lore.kernel.org/rust-for-linux/20260225180449.1813833-1-zhiw@xxxxxxxxxx/
[2] https://lore.kernel.org/rust-for-linux/20260323153807.1360705-1-gary@xxxxxxxxxx/
[3] https://lore.kernel.org/rust-for-linux/20260313165336.935771-1-zhiw@xxxxxxxxxx/
Zhi Wang (1):
rust: pci: add extended capability and SR-IOV support
rust/helpers/pci.c | 5 +
rust/kernel/pci.rs | 7 ++
rust/kernel/pci/cap.rs | 256 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 268 insertions(+)
create mode 100644 rust/kernel/pci/cap.rs
base-commit: 016f794f04888a304322c746b0a7794888d86e21
--
2.51.0