From: Daniel Almeida <daniel.almeida@collabora.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: "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>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Abdiel Janulgue" <abdiel.janulgue@gmail.com>,
iommu@lists.linux.dev, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org, driver-core@lists.linux.dev,
"Detlev Casanova" <detlev.casanova@collabora.com>,
"Nicolas Dufresne" <nicolas.dufresne@collabora.com>
Subject: Re: [PATCH 0/6] rust: iommu: add a paging domain abstraction
Date: Tue, 17 Nov 2026 17:09:11 -0300 [thread overview]
Message-ID: <3EB4C2ED-B699-4532-A562-68B78F6E29C6@collabora.com> (raw)
In-Reply-To: <20261116193821.GC2452510@ziepe.ca>
Hi Jason,
> On 16 Nov 2026, at 16:38, Jason Gunthorpe <jgg@ziepe.ca> wrote:
>
> On Thu, Nov 12, 2026 at 02:00:07PM -0300, 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.
>>
>> 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.
>
> How do you plan to get the paging domain in the first place?
We plan to alloc a paging domain when a video encoder session is created. Then
we call iommu_attach_device() before a job runs, and detach back to the default
domain after it finishes so the next job can attach its own session's domain.
This is so each session is isolated from each other.
>
> Using paging domains directly is very complicated, I'm not excite d to
> see DRM trying to do this at all. IMHO there are many unanswered
> questions how it could even do this safely.
In a very simplified way, this is not unlike how GPU drivers currently work. In
fact, from a cursory look, this seems to be how rocket (the NPU driver) works
too. Since we are merely porting the same ideas to video codec hardware, I am a bit
surprised by your discontentment.
(Note, though, that I have never worked on IOMMU drivers, so it is possible that
I am missing some context or some history here, in which case, sorry.)
In any case, we need this isolation due to the submission model used.
Most Vulkan drivers know their hardware pretty well, so a level of abstraction
on top of it like V4L2 is unnecessary. Therefore, in order to achieve a leaner
kernel driver, userspace programs most of the encoder's registers directly, so
the kernel cannot validate every address a job makes the encoder access.
Instead of validating, we rely on each session having its own address space, so
a job from session X can only reach memory that was mapped for session X, and
so misbehaving sessions cannot affect one another. You cannot read or write
buffers from another session unless the buffer is explicitly shared.
Again, this is pretty similar to GPU drivers, where a VM_BIND ioctl can bind
a given buffer range to an address range in a specific address space.
> It would be better to come with a user so we can try to understand
> what you are even planning.
We do have a user, it is just work in progress. We will likely post an
RFC soon (i.e.: next few weeks I assume).
>
>> Patch 6 adds Domain::with_fault_handler(), which allocates a domain
>> with a FaultHandler installed. One handler can serve several domains.
>
> You intend to use fault handler?? That's even more esoteric.
>
> Jason
The fault handler is used in the same way it is used in GPU drivers: to kill
sessions if they fault. This way the driver can simply refuse further work from
a misbehaving client, for example. It is also the natural place to enqueue a
reset if the codec hardware is frozen as a result of the fault.
What in this model is fundamentally incompatible with how you expect paging
domains to be used? In other words, what exactly do you mean when you say:
> IMHO there are many unanswered questions how it could even do this safely.
-- Daniel
next prev parent reply other threads:[~2026-11-17 20:10 UTC|newest]
Thread overview: 12+ 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-17 20:09 ` Daniel Almeida [this message]
2026-11-17 20:20 ` Jason Gunthorpe
2026-11-16 21:54 ` Detlev Casanova
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=3EB4C2ED-B699-4532-A562-68B78F6E29C6@collabora.com \
--to=daniel.almeida@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=detlev.casanova@collabora.com \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--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®