mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4 0/2] KVM: Skip mmu_notifier invalidations for gmem-only slots
@ 2026-11-17  1:15 Sean Christopherson
  2026-11-17  1:15 ` [PATCH v4 1/2] KVM: Disallow prefetching PFNs (for SPTEs) via VMAs for gmem-only memslots Sean Christopherson
  2026-11-17  1:15 ` [PATCH v4 2/2] KVM: Skip gfn-based MMU notifier invalidations for guest_memfd-only memslots Sean Christopherson
  0 siblings, 2 replies; 8+ messages in thread
From: Sean Christopherson @ 2026-11-17  1:15 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Sean Christopherson, kvm, linux-kernel, Sashiko Bot,
	Lorenzo Stoakes, Naveen N Rao, Alexandru Elisei

Fix a lurking bug where KVM incorrectly prefetches SPTEs for gmem-only memslots
using fast GUP, i.e. VMAs, and then skip mmu_notifier invalidations for
gmem-only memslots (because as the name suggests, KVM MMUs are supposed to
only get PFNs for gmem-only memslots straight from guest_memfd).

v4:
 - Tack on a patch to disallow prefetching gmem-only memslots using a VMA.
   [Sashiko, Lorenzo]

v3:
 - https://lore.kernel.org/all/20261113164000.467175-1-seanjc@google.com
 - v1, but with a different changelog.

v2: https://lore.kernel.org/all/20260714160411.302386-1-alexandru.elisei@arm.com

v1: https://lore.kernel.org/all/20260615155244.183044-1-alexandru.elisei@arm.com

Alexandru Elisei (1):
  KVM: Skip gfn-based MMU notifier invalidations for guest_memfd-only
    memslots

Sean Christopherson (1):
  KVM: Disallow prefetching PFNs (for SPTEs) via VMAs for gmem-only
    memslots

 virt/kvm/kvm_main.c | 7 +++++++
 1 file changed, 7 insertions(+)


base-commit: d21eef2084a9af87ac2a783bc7c2b175ba114e4e
-- 
2.56.1.703.gf848ed807c-goog


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

* [PATCH v4 1/2] KVM: Disallow prefetching PFNs (for SPTEs) via VMAs for gmem-only memslots
  2026-11-17  1:15 [PATCH v4 0/2] KVM: Skip mmu_notifier invalidations for gmem-only slots Sean Christopherson
@ 2026-11-17  1:15 ` Sean Christopherson
  2026-11-17  2:41   ` Ackerley Tng
                     ` (2 more replies)
  2026-11-17  1:15 ` [PATCH v4 2/2] KVM: Skip gfn-based MMU notifier invalidations for guest_memfd-only memslots Sean Christopherson
  1 sibling, 3 replies; 8+ messages in thread
From: Sean Christopherson @ 2026-11-17  1:15 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Sean Christopherson, kvm, linux-kernel, Sashiko Bot,
	Lorenzo Stoakes, Naveen N Rao, Alexandru Elisei

Disallow prefetching SPTEs via fast GUP, i.e. by VMA lookup, for gmem-only
memslots as the whole point of gmem-only memslots is that KVM MMUs should
get PFNs *only* via the direct guest_memfd interface.  More importantly,
this will allow skipping/ignoring/eliding mmu_notifier invalidations for
gmem-only memslots, since it will be impossible for KVM MMUs to have any
mappings based on the to-be-invalidated VMA (as is intended).

Fixes: 576d035e2aef ("KVM: guest_memfd: Track guest_memfd mmap support in memslot")
Reported-by: Sashiko Bot <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/all/sashiko-outbox-213282@kernel.org
Reported-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Closes: https://lore.kernel.org/all/avdAIMDfgL_wy1rx@gremlin
Suggested-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 virt/kvm/kvm_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index cf4cb586f140..9938b753948c 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -3172,6 +3172,9 @@ int kvm_prefetch_pages(struct kvm_memory_slot *slot, gfn_t gfn,
 	unsigned long addr;
 	gfn_t entry = 0;
 
+	if (kvm_memslot_is_gmem_only(slot))
+		return -EINVAL;
+
 	addr = gfn_to_hva_many(slot, gfn, &entry);
 	if (kvm_is_error_hva(addr))
 		return -1;
-- 
2.56.1.703.gf848ed807c-goog


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

* [PATCH v4 2/2] KVM: Skip gfn-based MMU notifier invalidations for guest_memfd-only memslots
  2026-11-17  1:15 [PATCH v4 0/2] KVM: Skip mmu_notifier invalidations for gmem-only slots Sean Christopherson
  2026-11-17  1:15 ` [PATCH v4 1/2] KVM: Disallow prefetching PFNs (for SPTEs) via VMAs for gmem-only memslots Sean Christopherson
@ 2026-11-17  1:15 ` Sean Christopherson
  2026-11-17  2:44   ` Ackerley Tng
  2026-11-17 13:13   ` Lorenzo Stoakes (ARM)
  1 sibling, 2 replies; 8+ messages in thread
From: Sean Christopherson @ 2026-11-17  1:15 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Sean Christopherson, kvm, linux-kernel, Sashiko Bot,
	Lorenzo Stoakes, Naveen N Rao, Alexandru Elisei

From: Alexandru Elisei <alexandru.elisei@arm.com>

Don't invalidate gmem-only memslots when responding to MMU notifier
invalidations, as the entire point of gmem-only memslots is so that KVM
doesn't need a VMA to install mappings into KVM's MMU.  Specifically,
page faults are resolved by going straight to guest_memfd, using the gfn
and the associated memslot's gmem.file.  I.e. whether or not userspace
happens to have valid mappings to the same gmem instance is irrelevant,
as are any invalidations for those mappings.

Note!  The exception is KVM's gfn_to_pfn_cache implementation which isn't
yet wired up to pull pfns directly from guest_memfd, i.e. still relies on
userspace mappings/VMAs and thus need to be invalidated, e.g. to ensure KVM
doesn't retain a kernel mapping+pointer to PRIVATE memory.  However, as of
commit da260bcb56fe ("KVM: pfncache: use a dedicated invalidation sequence
for cache refresh"), GPC invalidation no longer relies on memslot lookups,
because GPCs also support HVA-based mappings.  I.e. KVM *must* be able to
detect and handle relevant MMU notifier invalidations even if there is *no*
memslot whatsoever.

In addition to the obvious performance benefits, avoiding unnecessary and
spurious SPTE zaps and TLB flushes will allow KVM to support features like
ARM's Statistical Profiling Extension (SPE)[1] and x86's Secure AVIC[2],
both of which rely on the pages *never* being unmapped from the stage-2
page tables.

Link: https://lore.kernel.org/all/20260903160623.315525-1-alexandru.elisei@arm.com [1]
Link: https://lore.kernel.org/all/cover.1783490022.git.naveen@kernel.org [2]
Cc: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Cc: Naveen N Rao (AMD) <naveen@kernel.org>
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
[sean: rewrite changelog to capture the new gpc behavior]
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 virt/kvm/kvm_main.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 9938b753948c..f0d95e8c37f4 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -601,6 +601,10 @@ static __always_inline kvm_mn_ret_t kvm_handle_hva_range(struct kvm *kvm,
 			unsigned long hva_start, hva_end;
 
 			slot = container_of(node, struct kvm_memory_slot, hva_node[slots->node_idx]);
+
+			if (kvm_slot_has_gmem(slot) && kvm_memslot_is_gmem_only(slot))
+				continue;
+
 			hva_start = max_t(unsigned long, range->start, slot->userspace_addr);
 			hva_end = min_t(unsigned long, range->end,
 					slot->userspace_addr + (slot->npages << PAGE_SHIFT));
-- 
2.56.1.703.gf848ed807c-goog


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

* Re: [PATCH v4 1/2] KVM: Disallow prefetching PFNs (for SPTEs) via VMAs for gmem-only memslots
  2026-11-17  1:15 ` [PATCH v4 1/2] KVM: Disallow prefetching PFNs (for SPTEs) via VMAs for gmem-only memslots Sean Christopherson
@ 2026-11-17  2:41   ` Ackerley Tng
  2026-11-17  2:41   ` Ackerley Tng
  2026-11-17 13:11   ` Lorenzo Stoakes (ARM)
  2 siblings, 0 replies; 8+ messages in thread
From: Ackerley Tng @ 2026-11-17  2:41 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini
  Cc: kvm, linux-kernel, Sashiko Bot, Lorenzo Stoakes, Naveen N Rao,
	Alexandru Elisei

Sean Christopherson <seanjc@google.com> writes:

> Disallow prefetching SPTEs via fast GUP, i.e. by VMA lookup, for gmem-only
> memslots as the whole point of gmem-only memslots is that KVM MMUs should
> get PFNs *only* via the direct guest_memfd interface.  More importantly,
> this will allow skipping/ignoring/eliding mmu_notifier invalidations for
> gmem-only memslots, since it will be impossible for KVM MMUs to have any
> mappings based on the to-be-invalidated VMA (as is intended).
>
> Fixes: 576d035e2aef ("KVM: guest_memfd: Track guest_memfd mmap support in memslot")
> Reported-by: Sashiko Bot <sashiko-bot@kernel.org>
> Closes: https://lore.kernel.org/all/sashiko-outbox-213282@kernel.org
> Reported-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> Closes: https://lore.kernel.org/all/avdAIMDfgL_wy1rx@gremlin
> Suggested-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
>  virt/kvm/kvm_main.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index cf4cb586f140..9938b753948c 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -3172,6 +3172,9 @@ int kvm_prefetch_pages(struct kvm_memory_slot *slot, gfn_t gfn,
>  	unsigned long addr;
>  	gfn_t entry = 0;
>
> +	if (kvm_memslot_is_gmem_only(slot))
> +		return -EINVAL;
> +
>  	addr = gfn_to_hva_many(slot, gfn, &entry);
>  	if (kvm_is_error_hva(addr))
>  		return -1;
> --
> 2.56.1.703.gf848ed807c-goog

FWIW, I also looked into kvm_read_guest*() after being pointed there by
AI. Those take a HVA, but don't take any kind of long term pin or have
any reliance on MMU notifiers, so those don't need extra guards.

Reviewed-by: Ackerley Tng <ackerleytng@google.com>

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

* Re: [PATCH v4 1/2] KVM: Disallow prefetching PFNs (for SPTEs) via VMAs for gmem-only memslots
  2026-11-17  1:15 ` [PATCH v4 1/2] KVM: Disallow prefetching PFNs (for SPTEs) via VMAs for gmem-only memslots Sean Christopherson
  2026-11-17  2:41   ` Ackerley Tng
@ 2026-11-17  2:41   ` Ackerley Tng
  2026-11-17 13:11   ` Lorenzo Stoakes (ARM)
  2 siblings, 0 replies; 8+ messages in thread
From: Ackerley Tng @ 2026-11-17  2:41 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini
  Cc: kvm, linux-kernel, Sashiko Bot, Lorenzo Stoakes, Naveen N Rao,
	Alexandru Elisei

Sean Christopherson <seanjc@google.com> writes:

> Disallow prefetching SPTEs via fast GUP, i.e. by VMA lookup, for gmem-only
> memslots as the whole point of gmem-only memslots is that KVM MMUs should
> get PFNs *only* via the direct guest_memfd interface.  More importantly,
> this will allow skipping/ignoring/eliding mmu_notifier invalidations for
> gmem-only memslots, since it will be impossible for KVM MMUs to have any
> mappings based on the to-be-invalidated VMA (as is intended).
>
> Fixes: 576d035e2aef ("KVM: guest_memfd: Track guest_memfd mmap support in memslot")
> Reported-by: Sashiko Bot <sashiko-bot@kernel.org>
> Closes: https://lore.kernel.org/all/sashiko-outbox-213282@kernel.org
> Reported-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> Closes: https://lore.kernel.org/all/avdAIMDfgL_wy1rx@gremlin
> Suggested-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
>  virt/kvm/kvm_main.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index cf4cb586f140..9938b753948c 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -3172,6 +3172,9 @@ int kvm_prefetch_pages(struct kvm_memory_slot *slot, gfn_t gfn,
>  	unsigned long addr;
>  	gfn_t entry = 0;
>
> +	if (kvm_memslot_is_gmem_only(slot))
> +		return -EINVAL;
> +
>  	addr = gfn_to_hva_many(slot, gfn, &entry);
>  	if (kvm_is_error_hva(addr))
>  		return -1;
> --
> 2.56.1.703.gf848ed807c-goog

FWIW, I also looked into kvm_read_guest*() after being pointed there by
AI. Those take a HVA, but don't take any kind of long term pin or have
any reliance on MMU notifiers, so those don't need extra guards.

Reviewed-by: Ackerley Tng <ackerleytng@google.com>

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

* Re: [PATCH v4 2/2] KVM: Skip gfn-based MMU notifier invalidations for guest_memfd-only memslots
  2026-11-17  1:15 ` [PATCH v4 2/2] KVM: Skip gfn-based MMU notifier invalidations for guest_memfd-only memslots Sean Christopherson
@ 2026-11-17  2:44   ` Ackerley Tng
  2026-11-17 13:13   ` Lorenzo Stoakes (ARM)
  1 sibling, 0 replies; 8+ messages in thread
From: Ackerley Tng @ 2026-11-17  2:44 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini
  Cc: kvm, linux-kernel, Sashiko Bot, Lorenzo Stoakes, Naveen N Rao,
	Alexandru Elisei

Sean Christopherson <seanjc@google.com> writes:

> From: Alexandru Elisei <alexandru.elisei@arm.com>
>
> Don't invalidate gmem-only memslots when responding to MMU notifier
> invalidations, as the entire point of gmem-only memslots is so that KVM
> doesn't need a VMA to install mappings into KVM's MMU.  Specifically,
> page faults are resolved by going straight to guest_memfd, using the gfn
> and the associated memslot's gmem.file.  I.e. whether or not userspace
> happens to have valid mappings to the same gmem instance is irrelevant,
> as are any invalidations for those mappings.
>
> Note!  The exception is KVM's gfn_to_pfn_cache implementation which isn't
> yet wired up to pull pfns directly from guest_memfd, i.e. still relies on
> userspace mappings/VMAs and thus need to be invalidated, e.g. to ensure KVM
> doesn't retain a kernel mapping+pointer to PRIVATE memory.  However, as of
> commit da260bcb56fe ("KVM: pfncache: use a dedicated invalidation sequence
> for cache refresh"), GPC invalidation no longer relies on memslot lookups,
> because GPCs also support HVA-based mappings.  I.e. KVM *must* be able to
> detect and handle relevant MMU notifier invalidations even if there is *no*
> memslot whatsoever.
>
> In addition to the obvious performance benefits, avoiding unnecessary and
> spurious SPTE zaps and TLB flushes will allow KVM to support features like
> ARM's Statistical Profiling Extension (SPE)[1] and x86's Secure AVIC[2],
> both of which rely on the pages *never* being unmapped from the stage-2
> page tables.
>
> Link: https://lore.kernel.org/all/20260903160623.315525-1-alexandru.elisei@arm.com [1]
> Link: https://lore.kernel.org/all/cover.1783490022.git.naveen@kernel.org [2]
> Cc: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> Cc: Naveen N Rao (AMD) <naveen@kernel.org>
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> [sean: rewrite changelog to capture the new gpc behavior]
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
>  virt/kvm/kvm_main.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 9938b753948c..f0d95e8c37f4 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -601,6 +601,10 @@ static __always_inline kvm_mn_ret_t kvm_handle_hva_range(struct kvm *kvm,
>  			unsigned long hva_start, hva_end;
>
>  			slot = container_of(node, struct kvm_memory_slot, hva_node[slots->node_idx]);
> +
> +			if (kvm_slot_has_gmem(slot) && kvm_memslot_is_gmem_only(slot))
> +				continue;
> +
>  			hva_start = max_t(unsigned long, range->start, slot->userspace_addr);
>  			hva_end = min_t(unsigned long, range->end,
>  					slot->userspace_addr + (slot->npages << PAGE_SHIFT));
> --
> 2.56.1.703.gf848ed807c-goog

Reviewed-by: Ackerley Tng <ackerleytng@google.com>

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

* Re: [PATCH v4 1/2] KVM: Disallow prefetching PFNs (for SPTEs) via VMAs for gmem-only memslots
  2026-11-17  1:15 ` [PATCH v4 1/2] KVM: Disallow prefetching PFNs (for SPTEs) via VMAs for gmem-only memslots Sean Christopherson
  2026-11-17  2:41   ` Ackerley Tng
  2026-11-17  2:41   ` Ackerley Tng
@ 2026-11-17 13:11   ` Lorenzo Stoakes (ARM)
  2 siblings, 0 replies; 8+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-17 13:11 UTC (permalink / raw)
  To: Sean Christopherson
  Cc: Paolo Bonzini, kvm, linux-kernel, Sashiko Bot, Naveen N Rao,
	Alexandru Elisei

On Mon, Nov 16, 2026 at 05:15:12PM -0800, Sean Christopherson wrote:
> Disallow prefetching SPTEs via fast GUP, i.e. by VMA lookup, for gmem-only
> memslots as the whole point of gmem-only memslots is that KVM MMUs should
> get PFNs *only* via the direct guest_memfd interface.  More importantly,
> this will allow skipping/ignoring/eliding mmu_notifier invalidations for
> gmem-only memslots, since it will be impossible for KVM MMUs to have any
> mappings based on the to-be-invalidated VMA (as is intended).
>
> Fixes: 576d035e2aef ("KVM: guest_memfd: Track guest_memfd mmap support in memslot")
> Reported-by: Sashiko Bot <sashiko-bot@kernel.org>
> Closes: https://lore.kernel.org/all/sashiko-outbox-213282@kernel.org
> Reported-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> Closes: https://lore.kernel.org/all/avdAIMDfgL_wy1rx@gremlin
> Suggested-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> Signed-off-by: Sean Christopherson <seanjc@google.com>

LGTM, thanks! :)

Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>

> ---
>  virt/kvm/kvm_main.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index cf4cb586f140..9938b753948c 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -3172,6 +3172,9 @@ int kvm_prefetch_pages(struct kvm_memory_slot *slot, gfn_t gfn,
>  	unsigned long addr;
>  	gfn_t entry = 0;
>
> +	if (kvm_memslot_is_gmem_only(slot))
> +		return -EINVAL;
> +
>  	addr = gfn_to_hva_many(slot, gfn, &entry);
>  	if (kvm_is_error_hva(addr))
>  		return -1;
> --
> 2.56.1.703.gf848ed807c-goog
>

--
Cheers, Lorenzo

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

* Re: [PATCH v4 2/2] KVM: Skip gfn-based MMU notifier invalidations for guest_memfd-only memslots
  2026-11-17  1:15 ` [PATCH v4 2/2] KVM: Skip gfn-based MMU notifier invalidations for guest_memfd-only memslots Sean Christopherson
  2026-11-17  2:44   ` Ackerley Tng
@ 2026-11-17 13:13   ` Lorenzo Stoakes (ARM)
  1 sibling, 0 replies; 8+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-17 13:13 UTC (permalink / raw)
  To: Sean Christopherson
  Cc: Paolo Bonzini, kvm, linux-kernel, Sashiko Bot, Naveen N Rao,
	Alexandru Elisei

On Mon, Nov 16, 2026 at 05:15:13PM -0800, Sean Christopherson wrote:
> From: Alexandru Elisei <alexandru.elisei@arm.com>
>
> Don't invalidate gmem-only memslots when responding to MMU notifier
> invalidations, as the entire point of gmem-only memslots is so that KVM
> doesn't need a VMA to install mappings into KVM's MMU.  Specifically,
> page faults are resolved by going straight to guest_memfd, using the gfn
> and the associated memslot's gmem.file.  I.e. whether or not userspace
> happens to have valid mappings to the same gmem instance is irrelevant,
> as are any invalidations for those mappings.
>
> Note!  The exception is KVM's gfn_to_pfn_cache implementation which isn't
> yet wired up to pull pfns directly from guest_memfd, i.e. still relies on
> userspace mappings/VMAs and thus need to be invalidated, e.g. to ensure KVM
> doesn't retain a kernel mapping+pointer to PRIVATE memory.  However, as of
> commit da260bcb56fe ("KVM: pfncache: use a dedicated invalidation sequence
> for cache refresh"), GPC invalidation no longer relies on memslot lookups,
> because GPCs also support HVA-based mappings.  I.e. KVM *must* be able to
> detect and handle relevant MMU notifier invalidations even if there is *no*
> memslot whatsoever.
>
> In addition to the obvious performance benefits, avoiding unnecessary and
> spurious SPTE zaps and TLB flushes will allow KVM to support features like
> ARM's Statistical Profiling Extension (SPE)[1] and x86's Secure AVIC[2],
> both of which rely on the pages *never* being unmapped from the stage-2
> page tables.
>
> Link: https://lore.kernel.org/all/20260903160623.315525-1-alexandru.elisei@arm.com [1]
> Link: https://lore.kernel.org/all/cover.1783490022.git.naveen@kernel.org [2]
> Cc: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> Cc: Naveen N Rao (AMD) <naveen@kernel.org>
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> [sean: rewrite changelog to capture the new gpc behavior]
> Signed-off-by: Sean Christopherson <seanjc@google.com>

LGTM, thanks Alex and Sean! :)

Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>

> ---
>  virt/kvm/kvm_main.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 9938b753948c..f0d95e8c37f4 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -601,6 +601,10 @@ static __always_inline kvm_mn_ret_t kvm_handle_hva_range(struct kvm *kvm,
>  			unsigned long hva_start, hva_end;
>
>  			slot = container_of(node, struct kvm_memory_slot, hva_node[slots->node_idx]);
> +
> +			if (kvm_slot_has_gmem(slot) && kvm_memslot_is_gmem_only(slot))
> +				continue;
> +
>  			hva_start = max_t(unsigned long, range->start, slot->userspace_addr);
>  			hva_end = min_t(unsigned long, range->end,
>  					slot->userspace_addr + (slot->npages << PAGE_SHIFT));
> --
> 2.56.1.703.gf848ed807c-goog
>

--
Cheers, Lorenzo

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

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

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17  1:15 [PATCH v4 0/2] KVM: Skip mmu_notifier invalidations for gmem-only slots Sean Christopherson
2026-11-17  1:15 ` [PATCH v4 1/2] KVM: Disallow prefetching PFNs (for SPTEs) via VMAs for gmem-only memslots Sean Christopherson
2026-11-17  2:41   ` Ackerley Tng
2026-11-17  2:41   ` Ackerley Tng
2026-11-17 13:11   ` Lorenzo Stoakes (ARM)
2026-11-17  1:15 ` [PATCH v4 2/2] KVM: Skip gfn-based MMU notifier invalidations for guest_memfd-only memslots Sean Christopherson
2026-11-17  2:44   ` Ackerley Tng
2026-11-17 13:13   ` Lorenzo Stoakes (ARM)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®