On Tue, Jun 24, 2025 at 06:23:54PM +1000, Alexey Kardashevskiy wrote: > Now, I am rebasing my RFC on top of this patchset and it fails in > kvm_gmem_has_safe_refcount() as IOMMU holds references to all these > folios in my RFC. > > So what is the expected sequence here? The userspace unmaps a DMA > page and maps it back right away, all from the userspace? The end > result will be the exactly same which seems useless. And IOMMU TLB > is going to be flushed on a page conversion anyway (the RMPUPDATE > instruction does that). All this is about AMD's x86 though. The iommu should not be using the VMA to manage the mapping. It should be directly linked to the guestmemfd in some way that does not disturb its operations. I imagine there would be some kind of invalidation callback directly to the iommu. Presumably that invalidation call back can include a reason for the invalidation (addr change, shared/private conversion, etc) I'm not sure how we will figure out which case is which but guestmemfd should allow the iommu to plug in either invalidation scheme.. Probably invalidation should be a global to the FD thing, I imagine that once invalidation is established the iommu will not be incrementing page refcounts. Jason