All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Michael Roth <michael.roth@amd.com>
Cc: kvm@vger.kernel.org, linux-coco@lists.linux.dev,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org,
	thomas.lendacky@amd.com, pbonzini@redhat.com,  vbabka@suse.cz,
	ashish.kalra@amd.com, liam.merwick@oracle.com,  david@redhat.com,
	vannapurve@google.com, ackerleytng@google.com, aik@amd.com,
	 ira.weiny@intel.com, yan.y.zhao@intel.com, pankaj.gupta@amd.com,
	 Kai Huang <kai.huang@intel.com>
Subject: Re: [PATCH v3 2/6] KVM: guest_memfd: Remove partial hugepage handling from kvm_gmem_populate()
Date: Thu, 15 Jan 2026 11:17:18 -0800	[thread overview]
Message-ID: <aWk9PusYNW0iADuD@google.com> (raw)
In-Reply-To: <20260108214622.1084057-3-michael.roth@amd.com>

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.

  parent reply	other threads:[~2026-01-15 19:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-08 21:46 [PATCH v3 0/6] KVM: guest_memfd: Rework preparation/population flows in prep for in-place conversion Michael Roth
2026-01-08 21:46 ` [PATCH v3 1/6] KVM: SVM: Fix a missing kunmap_local() in sev_gmem_post_populate() Michael Roth
2026-01-08 21:46 ` [PATCH v3 2/6] KVM: guest_memfd: Remove partial hugepage handling from kvm_gmem_populate() Michael Roth
2026-01-12  9:39   ` Yan Zhao
2026-01-15 19:17   ` Sean Christopherson [this message]
2026-01-15 20:42     ` Michael Roth
2026-01-08 21:46 ` [PATCH v3 3/6] KVM: guest_memfd: Remove preparation tracking Michael Roth
2026-01-08 21:46 ` [PATCH v3 4/6] KVM: SEV: Document/enforce page-alignment for KVM_SEV_SNP_LAUNCH_UPDATE Michael Roth
2026-01-08 21:46 ` [PATCH v3 5/6] KVM: TDX: Document alignment requirements for KVM_TDX_INIT_MEM_REGION Michael Roth
2026-01-12  9:40   ` Yan Zhao
2026-01-08 21:46 ` [PATCH v3 6/6] KVM: guest_memfd: GUP source pages prior to populating guest memory Michael Roth
2026-01-12  9:41   ` Yan Zhao
2026-01-13 19:21   ` Sean Christopherson
2026-01-13 21:35     ` Michael Roth
2026-01-13 22:06       ` Sean Christopherson
2026-01-14  0:04     ` Yan Zhao
2026-01-15 18:03 ` [PATCH v3 0/6] KVM: guest_memfd: Rework preparation/population flows in prep for in-place conversion Sean Christopherson
2026-01-15 21:07   ` Sean Christopherson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aWk9PusYNW0iADuD@google.com \
    --to=seanjc@google.com \
    --cc=ackerleytng@google.com \
    --cc=aik@amd.com \
    --cc=ashish.kalra@amd.com \
    --cc=david@redhat.com \
    --cc=ira.weiny@intel.com \
    --cc=kai.huang@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=liam.merwick@oracle.com \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=michael.roth@amd.com \
    --cc=pankaj.gupta@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=thomas.lendacky@amd.com \
    --cc=vannapurve@google.com \
    --cc=vbabka@suse.cz \
    --cc=yan.y.zhao@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.