Re: [PATCH v5 4/7] KVM: guest_memfd: Fold __kvm_gmem_prepare_folio() into its sole caller

From: Sean Christopherson

Date: Tue Jul 21 2026 - 14:07:47 EST


On Tue, Jul 14, 2026, Ackerley Tng wrote:
> Sean Christopherson <seanjc@xxxxxxxxxx> writes:
>
> >
> > [...snip...]
> >
> > @@ -97,11 +85,15 @@ static int kvm_gmem_prepare_folio(struct kvm *kvm, struct kvm_memory_slot *slot,
> > * The order will be passed when creating the guest_memfd, and
> > * checked when creating memslots.
> > */
> > - WARN_ON(!IS_ALIGNED(slot->gmem.pgoff, folio_nr_pages(folio)));
> > + WARN_ON_ONCE(!IS_ALIGNED(slot->gmem.pgoff, folio_nr_pages(folio)));
> > + gfn = ALIGN_DOWN(gfn, folio_nr_pages(folio));
> > index = kvm_gmem_get_index(slot, gfn);
> > - index = ALIGN_DOWN(index, folio_nr_pages(folio));
> >
> > - return __kvm_gmem_prepare_folio(kvm, slot, index, folio);
> > + return kvm_arch_gmem_prepare(kvm, gfn, folio_file_pfn(folio, index),
>
> Could this just be folio_pfn(folio) since this function is
> kvm_gmem_prepare_folio() and guest_memfd will always try to prepare the
> entire folio?

No? Maybe? For this patch, I'm just trying to shuffle code araound. Even for
this series, I'd prefer not to make any more semantic changes than are needed to
get to a sane state, and to prepare for in-place conversion. If there's a need
and/or a good reason to use folio_pfn(), by all means, send a patch.