* Re: [RFC PATCH 0/9] mm: Memory providers for guest_memfd and iommufd
[not found] ` <CAEvNRgEseLO+LbkwXrEit0H2LH5Wx-srSvHEMpt0=upPL3tF=g@mail.gmail.com>
@ 2026-10-14 9:57 ` Fred Griffoul
2026-10-14 21:47 ` Ackerley Tng
0 siblings, 1 reply; 2+ messages in thread
From: Fred Griffoul @ 2026-10-14 9:57 UTC (permalink / raw)
To: Paolo Bonzini, Sean Christopherson, Marc Zyngier, Oliver Upton,
Catalin Marinas, Andrew Morton, David Hildenbrand, Alexander Viro,
Christian Brauner, Jan Kara, Jason Gunthorpe, Kevin Tian,
Joerg Roedel, Will Deacon, Robin Murphy, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H . Peter Anvin,
Jonathan Corbet, Shuah Khan, Shuah Khan, Ackerley Tng
Cc: David Woodhouse, Aneesh Kumar K . V, Lorenzo Stoakes,
Liam R . Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Joey Gouly, Suzuki K Poulose,
Zenghui Yu, Steffen Eiden, linux-kernel, kvm, kvmarm,
linux-arm-kernel, iommu, linux-fsdevel, linux-mm, linux-kselftest,
linux-doc
Ackerley Tng <ackerleytng@google.com> writes:
> When the provider wants to revoke the page, the notifications/function
> calls flow this way, the last [ENTITY] in the chain actually does the
> zapping.
>
> + [PROVIDER] -> [KVM]
> + [PROVIDER] -> [DMABUF] -> [IOMMU]
> + [PROVIDER] -> [GUEST_MEMFD] -> [USERSPACE] (AFAICT this was not
> implemented in the RFC.)
Thanks for going through it. I have just posted v2:
https://lore.kernel.org/all/20261014093733.90312-1-griffoul@gmail.com/
It changes two of these chains. dma-buf is gone: iommufd attaches to
the provider file itself, through a small interface in mm. And
guest_memfd now maps the file into userspace from the provider's
frames, so a revoke also zaps the VMM's mapping:
[PROVIDER] -> [GUEST_MEMFD] -> [KVM], [USERSPACE]
[PROVIDER] -> [IOMMU]
> IIUC guest_memfd conversions was not illustrated in the RFC: what
> happens on a shared -> private conversion?
There are none yet. Only VMs of type KVM_X86_DEFAULT_VM can use a
provider, so all their memory is shared.
> Does your provider need to know if some memory was transitioned between
> shared/private states? The provider can be notified too, if
> necessary. If not, then isn't guest_memfd doing all the coordination
> better than going via the provider?
Our provider does not need to know, and I agree: once there is private
memory, guest_memfd converts the pages, so it should tell the others
what to zap.
I think the two models meet there, and the v2 cover letter now says so.
The iommufd side of v2 does not pin and keeps no references: it asks for
the frame behind each page, treats a page with no frame as a hole, and
maps again on a revoke. guest_memfd can offer that for its own file:
shared pages return their frames, private pages are holes, and
guest_memfd revokes a range whenever it converts it, in either
direction. That is your [GUEST_MEMFD] -> [IOMMU], and it should work for
folio-backed guest_memfd without memfd_pin_folios() or refcounts, as
long as guest_memfd also revokes a range before it frees its folios.
The one difference is that v2 also lets iommufd map a provider file
directly. Going through guest_memfd would add nothing without private
memory: it would only pass each revoke on. And memory that only devices
use, such as MMIO, does not go through guest_memfd at all. Both paths
would use the same iommufd code.
> Does the revocation model work for you? If it helps, I can rebuild the
> sample provider to illustrate how the revocation can be done.
Yes, the revocation model works for us. v2 replaces David's sample
with one that moves, donates and makes pages read-only, and a selftest
that checks the guest, the device and the VMM's mapping after each
change. It may be a good base if you want to try guest_memfd as the
provider for iommufd on top of it.
> 4. [DIRECTMAP] Kernel direct map.
Agreed, that is separate. The memory we have in mind is a range hidden
from the host with memmap=, so it is not in the direct map.
Thanks,
Fred
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFC PATCH 0/9] mm: Memory providers for guest_memfd and iommufd
2026-10-14 9:57 ` [RFC PATCH 0/9] mm: Memory providers for guest_memfd and iommufd Fred Griffoul
@ 2026-10-14 21:47 ` Ackerley Tng
0 siblings, 0 replies; 2+ messages in thread
From: Ackerley Tng @ 2026-10-14 21:47 UTC (permalink / raw)
To: Fred Griffoul, Paolo Bonzini, Sean Christopherson, Marc Zyngier,
Oliver Upton, Catalin Marinas, Andrew Morton, David Hildenbrand,
Alexander Viro, Christian Brauner, Jan Kara, Jason Gunthorpe,
Kevin Tian, Joerg Roedel, Will Deacon, Robin Murphy,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H . Peter Anvin, Jonathan Corbet, Shuah Khan, Shuah Khan
Cc: David Woodhouse, Aneesh Kumar K . V, Lorenzo Stoakes,
Liam R . Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Joey Gouly, Suzuki K Poulose,
Zenghui Yu, Steffen Eiden, linux-kernel, kvm, kvmarm,
linux-arm-kernel, iommu, linux-fsdevel, linux-mm, linux-kselftest,
linux-doc
Fred Griffoul <griffoul@gmail.com> writes:
> Ackerley Tng <ackerleytng@google.com> writes:
>
>> When the provider wants to revoke the page, the notifications/function
>> calls flow this way, the last [ENTITY] in the chain actually does the
>> zapping.
>>
>> + [PROVIDER] -> [KVM]
>> + [PROVIDER] -> [DMABUF] -> [IOMMU]
>> + [PROVIDER] -> [GUEST_MEMFD] -> [USERSPACE] (AFAICT this was not
>> implemented in the RFC.)
>
> Thanks for going through it. I have just posted v2:
>
> https://lore.kernel.org/all/20261014093733.90312-1-griffoul@gmail.com/
>
> It changes two of these chains. dma-buf is gone: iommufd attaches to
> the provider file itself, through a small interface in mm. And
> guest_memfd now maps the file into userspace from the provider's
> frames, so a revoke also zaps the VMM's mapping:
>
> [PROVIDER] -> [GUEST_MEMFD] -> [KVM], [USERSPACE]
> [PROVIDER] -> [IOMMU]
>
Thanks :)
>> IIUC guest_memfd conversions was not illustrated in the RFC: what
>> happens on a shared -> private conversion?
>
> There are none yet. Only VMs of type KVM_X86_DEFAULT_VM can use a
> provider, so all their memory is shared.
>
To borrow David's words, the part about this that makes me itch is
conversion. We have to support conversions. Even if it doesn't merge in
the first patch series, we have to have line of sight to how conversions
would work.
Conversion requests originate from the guest and then the host handles
the guest request by making calling an ioctl on guest_memfd. Hopefully
this part doesn't change with alternative provider support.
Suppose guest_memfd still gets the conversion request first, in RFCv2,
to reach all the mappings in various page tables, it would have to be
+ [GUEST_MEMFD] -> [KVM], [USERSPACE]
+ [GUEST_MEMFD] -> [PROVIDER] -> [IOMMU]
since guest_memfd must ensure no IOMMU mappings to guest private pages?
There's that extra step through the [PROVIDER]...
>> Does your provider need to know if some memory was transitioned between
>> shared/private states? The provider can be notified too, if
>> necessary. If not, then isn't guest_memfd doing all the coordination
>> better than going via the provider?
>
> Our provider does not need to know, and I agree: once there is private
> memory, guest_memfd converts the pages, so it should tell the others
> what to zap.
>
> I think the two models meet there, and the v2 cover letter now says so.
> The iommufd side of v2 does not pin and keeps no references: it asks for
> the frame behind each page, treats a page with no frame as a hole, and
> maps again on a revoke. guest_memfd can offer that for its own file:
> shared pages return their frames, private pages are holes, and
> guest_memfd revokes a range whenever it converts it, in either
> direction. That is your [GUEST_MEMFD] -> [IOMMU], and it should work for
> folio-backed guest_memfd without memfd_pin_folios() or refcounts, as
> long as guest_memfd also revokes a range before it frees its folios.
>
This part makes sense, if I'm understanding you correctly.
> The one difference is that v2 also lets iommufd map a provider file
> directly. Going through guest_memfd would add nothing without private
> memory: it would only pass each revoke on. And memory that only devices
> use, such as MMIO, does not go through guest_memfd at all. Both paths
> would use the same iommufd code.
>
>> Does the revocation model work for you? If it helps, I can rebuild the
>> sample provider to illustrate how the revocation can be done.
>
> Yes, the revocation model works for us. v2 replaces David's sample
> with one that moves, donates and makes pages read-only, and a selftest
> that checks the guest, the device and the VMM's mapping after each
> change. It may be a good base if you want to try guest_memfd as the
> provider for iommufd on top of it.
>
Thanks, I will prototype what I have in mind too to make sure things
work as I think they will :)
>> 4. [DIRECTMAP] Kernel direct map.
>
> Agreed, that is separate. The memory we have in mind is a range hidden
> from the host with memmap=, so it is not in the direct map.
>
> Thanks,
> Fred
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-14 21:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260720111259.122911-1-dwmw2@infradead.org>
[not found] ` <20261006183235.16576-1-griffoul@gmail.com>
[not found] ` <CAEvNRgEseLO+LbkwXrEit0H2LH5Wx-srSvHEMpt0=upPL3tF=g@mail.gmail.com>
2026-10-14 9:57 ` [RFC PATCH 0/9] mm: Memory providers for guest_memfd and iommufd Fred Griffoul
2026-10-14 21:47 ` Ackerley Tng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox