Re: [PATCH 0/6] rust: iommu: add a paging domain abstraction
From: Daniel Almeida
Date: Tue Nov 17 2026 - 15:10:07 EST
Hi Jason,
> On 16 Nov 2026, at 16:38, Jason Gunthorpe <jgg@xxxxxxxx> 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