mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Detlev Casanova <detlev.casanova@collabora.com>
To: "Joerg Roedel (AMD)" <joro@8bytes.org>,
	"Will Deacon" <will@kernel.org>,
	"Robin Murphy" <robin.murphy@arm.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Onur Özkan" <work@onurozkan.dev>,
	"Abdiel Janulgue" <abdiel.janulgue@gmail.com>,
	"Daniel Almeida" <daniel.almeida@collabora.com>
Cc: iommu@lists.linux.dev, rust-for-linux@vger.kernel.org,
	linux-kernel@vger.kernel.org, driver-core@lists.linux.dev,
	Nicolas Dufresne <nicolas.dufresne@collabora.com>
Subject: Re: [PATCH 0/6] rust: iommu: add a paging domain abstraction
Date: Mon, 16 Nov 2026 16:54:32 -0500	[thread overview]
Message-ID: <iSL9q6tCTCC93Iglr5SH1w@collabora.com> (raw)
In-Reply-To: <20261112-b4-iommu-domain-v1-0-c29e86788dda@collabora.com>

Hi !
On Thursday, 12 November 2026 12:00:07 EST Daniel Almeida wrote:
> 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.

Note that a domain is not attached to a device, but rather a device is 
attached to a domain.

Small difference but it influences how domains are applied to devices and what 
happens when a devices is detached from its domain.

A device must always be attached to a domain, so when the device is detached 
from a domain, it will be reattached to its default domain.

IIRC, you cannot detach the default domain (it returns an error).

Of course this doesn't prevent us to use domains for the encoder the core we 
want to use can be attached to the client-specific domain before starting a 
job. When idle, it goes back to its default domain (most likely empty).

I also belive the patchset still works, but I'll have a deeper look into 
Attachment and some rewording might be necessary to avoid being misleading.

Detlev.

> 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>





      parent reply	other threads:[~2026-11-16 21:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=iSL9q6tCTCC93Iglr5SH1w@collabora.com \
    --to=detlev.casanova@collabora.com \
    --cc=a.hindborg@kernel.org \
    --cc=abdiel.janulgue@gmail.com \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=driver-core@lists.linux.dev \
    --cc=gary@garyguo.net \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=nicolas.dufresne@collabora.com \
    --cc=ojeda@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=will@kernel.org \
    --cc=work@onurozkan.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®