The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] KVM: Fix stale gfn_to_pfn() reference in kvm_invalidate_memslot() comment
@ 2026-05-08  6:01 Jun Miao
  2026-05-15 13:10 ` Sean Christopherson
  0 siblings, 1 reply; 2+ messages in thread
From: Jun Miao @ 2026-05-08  6:01 UTC (permalink / raw)
  To: pbonzini, seanjc; +Cc: linux-kernel, jun.miao

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)
 	 *	- kvm_is_visible_gfn (mmu_check_root)
 	 */
 	kvm_arch_flush_shadow_memslot(kvm, old);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: Fix stale gfn_to_pfn() reference in kvm_invalidate_memslot() comment
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2026-05-15 13:10 UTC (permalink / raw)
  To: Jun Miao; +Cc: pbonzini, linux-kernel

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
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-15 13:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox