Re: [PATCH v2 0/4] Stop returning struct page from guest_memfd PFN lookup
"David Hildenbrand (Arm)" <[email protected]>
| Newsgroups | gmane.comp.emulators.kvm.devel,gmane.linux.kernel,gmane.linux.ports.arm.kernel |
|---|---|
| Message-ID | <[email protected]> |
On 8/18/26 11:15, Ackerley Tng wrote: > KVM currently expects kvm_gmem_get_pfn() to return a refcounted struct > page. Callers (such as x86 TDP MMU, arm64 Stage-2 fault handler, and SEV-SNP > VMSA / RMP handlers) hold this refcount across page fault handling. > > Holding a page refcount across fault handling is problematic for guest_memfd. > In-place memory conversions between confidential computing shared and private > states inspect folio refcounts to ensure exclusive ownership by guest_memfd. A > concurrent guest page fault taking a reference on the folio causes conversions > to fail due to an elevated refcount. Right. Won't we still, at least temporarily, grab a reference while looking up the folio in the page cache, or will we be preventing that concurrent race with locking? > > guest_memfd already notifies KVM of page invalidations, so users of guest_memfd > within KVM only need to respect the MMU invalidation protocol to safely rely on > guest_memfd to ensure page presence. Yes, the invalidation protocol is the crucial part. If we get that wrong, we're in holy CVE land. For GUP-fast, there was a similar discussion with MMU notifiers, but to this day, KVM actually grabs+drops references. [...] > Removing struct page from kvm_gmem_get_pfn() also moves KVM closer toward > supporting memory backends that are not backed by struct page. Agreed, they should not be messing with the struct page at all. -- Cheers, David