Re: [PATCH v2 0/4] Stop returning struct page from guest_memfd PFN lookup
Sean Christopherson <[email protected]>
| Newsgroups | gmane.linux.kernel,gmane.comp.emulators.kvm.devel,gmane.linux.ports.arm.kernel |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Aug 18, 2026, David Hildenbrand (Arm) wrote: > 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? The latter. What I want to aim for is that if the relevant guest_memfd range has never been mmap()'d and there are no memory failures, then conversion is guaranteed to not fail due to elevated refcounts. Or to put it a different way, I want KVM's ABI to be that pausing vCPU is *NOT* required to perform an in-place conversion.