freenode
Kernel & Low-Level

Rust PCI drivers gain SR-IOV with typed PF data sharing

A kernel series lets Rust physical-function drivers publish lifetime-checked payloads that both Rust and C virtual-function drivers can borrow safely.

A patch series from Zhi Wang on the Linux kernel list extends Rust PCI support so drivers can enable Single Root I/O Virtualization (SR-IOV) and share selected physical-function (PF) state with virtual-function (VF) drivers, including VFs still written in C.

SR-IOV exposes multiple VFs from one PF. Rust drivers previously lacked a safe path to toggle the capability and hand VFs a narrow view of PF-owned data that stays valid for the VF's lifetime. Without ordered teardown, a VF could outlive its PF and touch freed private state; a C VF had only an opaque pointer and no ABI check.

The work builds on Peter Colberg's Rust PCI SR-IOV base and registration ideas from Danilo Krummrich. It adds a managed-SR-IOV driver flag so the core disables SR-IOV on PF unbind, links each VF to its PF, and unbinds VFs first. Rust PF drivers pin typed registration data in ordinary driver state and publish it only when no VFs are active. Rust VFs borrow that payload by type. C VFs use an ABI-token, version, and ops-size checked descriptor plus generated trampolines that recover a pinned Rust reference without exposing the full PF private structure.

Sample Rust and C VF modules exercise the same PF handler. Nova-core, the PF-side GPU driver, implements the sysfs SR-IOV configure callback and publishes a typed readiness marker before VFs come up. Kernel docs describe ownership, publication and teardown order, FFI versioning, and drain rules.

With broader Rust VFIO work still unsettled, the design deliberately serves mixed C and Rust VF consumers so existing C stacks can attach to Rust PFs during the transition.