[PATCH 0/6] rust: iommu: add a paging domain abstraction
From: Daniel Almeida
Date: Thu Nov 12 2026 - 12:24:50 EST
This series adds a Rust abstraction for IOMMU paging domains. A driver
can allocate a domain, attach it to its device, map pages into it, and
install a handler for its faults.
This will be used by the upcoming rkvenc driver that my colleagues
Detlev Casanova, Nicolas Dufresne and I are working on. More details on
this driver can be found by watching Nicolas Dufresne's talk at LPC 2026
[0].
As part of the security model, each client will have its own IOMMU
domain. This is needed as the submission model will let userspace set
most of the encoder's registers directly, so the kernel cannot check
every memory access that a job makes the encoder do. With a single
domain, one client could make the encoder read or write the memory of
another client.
With a domain per client, the encoder can only reach the memory of the
client whose job it is running, and any other access faults. The fault
handler added in patch 6 lets the driver identify the faulting client
and terminate its session.
Patches 1 and 2 prepare for Domain::map(). Patch 1 moves the protection
flags from the io-pgtable module to kernel::iommu, and patch 2 makes
SGTable::as_raw() visible to the crate.
Patch 3 adds Domain, a paging domain that is allocated for a bound
device and freed on drop. Domain::new() is unsafe: the caller must
ensure that the IOMMU driver behind its device sets a domain up fully
when it is allocated and allows concurrent use of it.
Patch 4 adds Domain::attach(), which returns an Attachment that
detaches the domain on drop. Devices that share their IOMMU group with
other devices are not supported.
Patch 5 adds Domain::map(), which maps pages at an IOVA chosen by the
caller and returns a Mapping that unmaps them on drop. The pages come
from a MapSource, initially a boxed SGTable that owns its pages.
Patch 6 adds Domain::with_fault_handler(), which allocates a domain
with a FaultHandler installed. One handler can serve several domains.
This is based on v7.4-rc1.
[0]: https://www.youtube.com/watch?v=75E15eHY7ac
---
Daniel Almeida (6):
rust: iommu: move the protection flags to the module root
rust: scatterlist: make SGTable::as_raw() visible to the crate
rust: iommu: add the paging domain abstraction
rust: iommu: add Domain::attach()
rust: iommu: add Domain::map()
rust: iommu: add Domain::with_fault_handler()
rust/kernel/iommu/domain.rs | 425 +++++++++++++++++++++++++++++++++++++++++++
rust/kernel/iommu/mod.rs | 18 ++
rust/kernel/iommu/pgtable.rs | 16 +-
rust/kernel/scatterlist.rs | 3 +-
4 files changed, 446 insertions(+), 16 deletions(-)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261111-b4-iommu-domain-f46a6e450c0d
Best regards,
--
Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>