The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Jun Miao <jun.miao@intel.com>
Cc: pbonzini@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: Fix stale gfn_to_pfn() reference in kvm_invalidate_memslot() comment
Date: Fri, 15 May 2026 06:10:49 -0700	[thread overview]
Message-ID: <agcbWe8s9lmPuJwG@google.com> (raw)
In-Reply-To: <20260508060139.850444-1-jun.miao@intel.com>

On Fri, May 08, 2026, Jun Miao wrote:
> Commit 06cdaff80e50 ("KVM: Drop gfn_to_pfn() APIs now that all users are
> gone") removed gfn_to_pfn(), but kvm_invalidate_memslot() still references
> gfn_to_pfn() when describing how sp->gfn is validated for guest memory
> accesses.
> 
> Update the comment to reference __kvm_faultin_pfn(), which is the actual path
> involved here.
> 
> No functional change intended.
> 
> Fixes: 06cdaff80e50 ("KVM: Drop gfn_to_pfn() APIs now that all users are gone")
> Signed-off-by: Jun Miao <jun.miao@intel.com>
> ---
>  virt/kvm/kvm_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 89489996fbc1..f4b3ea970a78 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1818,7 +1818,7 @@ static void kvm_invalidate_memslot(struct kvm *kvm,
>  	/*
>  	 * From this point no new shadow pages pointing to a deleted, or moved,
>  	 * memslot will be created.  Validation of sp->gfn happens in:
> -	 *	- gfn_to_hva (kvm_read_guest, gfn_to_pfn)
> +	 *	- gfn_to_hva (kvm_read_guest, __kvm_faultin_pfn)

This isn't really accurate either.  On x86, INVALID memslots don't even reach
__kvm_faultin_pfn(), because they're filtered out early on by
kvm_mmu_faultin_pfn().

Rather than simply fix the stale function reference, I think we should rewrite
the comment to describe the mechanics of memslots in excruiating detail.  The
existing comment is painfully x86-centric, and IMO is unlikely to help anyone
actually understand how all of this works; or at least, is supposed to work :-)

>  	 *	- kvm_is_visible_gfn (mmu_check_root)
>  	 */
>  	kvm_arch_flush_shadow_memslot(kvm, old);
> -- 
> 2.43.0
> 

      reply	other threads:[~2026-05-15 13:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08  6:01 [PATCH] KVM: Fix stale gfn_to_pfn() reference in kvm_invalidate_memslot() comment Jun Miao
2026-05-15 13:10 ` Sean Christopherson [this message]

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=agcbWe8s9lmPuJwG@google.com \
    --to=seanjc@google.com \
    --cc=jun.miao@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox