Re: [PATCH v8 07/15] iommupt: Add map_pages op

Jason Gunthorpe
2026-03-02T00:42:01Z

On Mon, Mar 02, 2026 at 11:02:48AM +1100, Alexey Kardashevskiy wrote:
> > Regardless, I think if you go this path you have to stick to 4k IOPTEs
> > and avoid the HW engine. Maybe that is good enough to start.
>
> This is the current plan.

Okay..

So taking the Intel and arm stuff into account I suggest what we need
here is, in some broad strokes..

1) Guest memfd gives some phys_addr_t list of its underlying physical
2) It is marked up with shared/private splits in some way
3) iommufd has a special area 'synchronized guestmemfd'
4) When guestmemfd changes anything about its mapping it invokes an
synchronization callback that iommufd will register
5) iommupt provides a new primitive: synchronize IOPTEs with
phys_addr_t list
It scans the current IOPTEs and adjusts them to match the
phys_addr_t list. Splitting,unsplitting,mapping and unmapping as
required.
6) That primitive as some flag 'private is mapped' or 'private is
unmapped'
7) iommufd invokes this primivate from the guestmemfd callback

AMD sets the pgsize bitmap to 4k and 'private is mapped'
ARM leaves pgsize bitmap alone and does 'private is mapped' (?)
Intel leaves pgsize bitmap alone and does 'private is unmapped'

Does that work for everyone?

#5 may be a bit tricky to implement, but doable.

Jason