Re: [PATCH v3 2/6] KVM: guest_memfd: Remove partial hugepage handling from kvm_gmem_populate()
From: Sean Christopherson
Date: Thu Jan 15 2026 - 14:17:20 EST
On Thu, Jan 08, 2026, Michael Roth wrote:
> diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
> index fdaea3422c30..9dafa44838fe 100644
> --- a/virt/kvm/guest_memfd.c
> +++ b/virt/kvm/guest_memfd.c
> @@ -151,6 +151,15 @@ static struct folio *kvm_gmem_get_folio(struct inode *inode, pgoff_t index)
> mapping_gfp_mask(inode->i_mapping), policy);
> mpol_cond_put(policy);
>
> + /*
> + * External interfaces like kvm_gmem_get_pfn() support dealing
> + * with hugepages to a degree, but internally, guest_memfd currently
> + * assumes that all folios are order-0 and handling would need
> + * to be updated for anything otherwise (e.g. page-clearing
> + * operations).
> + */
> + WARN_ON_ONCE(folio_order(folio));
Gah, this is buggy. __filemap_get_folio_mpol() can return an ERR_PTR(). If that
happens, this WARN will dereference garbage and explode.
And of course I find it _just_ after sending thank yous, *sigh*.
I'll squash to this (after testing):
WARN_ON_ONCE(!IS_ERR(folio) && folio_order(folio));
avoiding a few emails isn't worth having a lurking bug.