mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/6] rust: iommu: add a paging domain abstraction
@ 2026-11-12 17:00 Daniel Almeida
  2026-11-12 17:00 ` [PATCH 1/6] rust: iommu: move the protection flags to the module root Daniel Almeida
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Daniel Almeida @ 2026-11-12 17:00 UTC (permalink / raw)
  To: Joerg Roedel (AMD),
	Will Deacon, Robin Murphy, Miguel Ojeda, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, Abdiel Janulgue
  Cc: iommu, rust-for-linux, linux-kernel, driver-core,
	Detlev Casanova, Nicolas Dufresne

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@collabora.com>


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-11-16 21:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-12 17:00 [PATCH 0/6] rust: iommu: add a paging domain abstraction Daniel Almeida
2026-11-12 17:00 ` [PATCH 1/6] rust: iommu: move the protection flags to the module root Daniel Almeida
2026-11-12 17:00 ` [PATCH 2/6] rust: scatterlist: make SGTable::as_raw() visible to the crate Daniel Almeida
2026-11-12 17:00 ` [PATCH 3/6] rust: iommu: add the paging domain abstraction Daniel Almeida
2026-11-12 17:00 ` [PATCH 4/6] rust: iommu: add Domain::attach() Daniel Almeida
2026-11-16 21:54   ` Detlev Casanova
2026-11-12 17:00 ` [PATCH 5/6] rust: iommu: add Domain::map() Daniel Almeida
2026-11-12 17:00 ` [PATCH 6/6] rust: iommu: add Domain::with_fault_handler() Daniel Almeida
2026-11-16 19:38 ` [PATCH 0/6] rust: iommu: add a paging domain abstraction Jason Gunthorpe
2026-11-16 21:54 ` Detlev Casanova

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®