freenode
Kernel & Low-Level

Linux kernel adds Rust PCI SR-IOV driver support

A new abstraction layer lets Rust physical- and virtual-function drivers configure SR-IOV and share PF-owned data safely until VF teardown finishes.

A fourth revision of patches led by Zhi Wang brings Single Root I/O Virtualization (SR-IOV) support to Rust PCI drivers in the Linux kernel.

SR-IOV lets a physical PCI function (PF) expose virtual functions (VFs) that hosts can assign to guests or other tenants. Rust drivers could already bind to PCI devices, but they lacked safe ways to enable and disable VFs and to hand selected PF-owned state to a separate VF driver, which may live in another module and outlive parts of the PF path. Without that, full SR-IOV device drivers in Rust were effectively blocked.

The series supplies those operations. Drivers implement paired enable and disable callbacks that receive pinned driver data and a short-lived token scoped to the request. A successful enable returns a guard that disables the VFs again if later setup fails; handing the guard off leaves them up, with final teardown owned by a registration object. That registration publishes a typed, pinned object from the PF so VF drivers can borrow it for as long as they remain bound. Drivers that share nothing can register a unit value instead. Enabling and querying VF counts use the u16 width the PCI core already stores, with conversions only at the C boundary.

The design builds on earlier Rust PCI SR-IOV work from Peter Colberg and a typed PF registration approach from Danilo Krummrich. John Hubbard contributed a helper to detect virtual functions. Sample PF and VF modules, split so the VF depends on the PF, demonstrate the interface against QEMU's 82576 emulation, including unload and rebind while the PF stays bound.

For projects writing high-performance network or accelerator drivers in Rust, the change closes a gap that C drivers have long taken for granted: configuring SR-IOV without unsafe lifetime games between PF and VF.