* [PATCH] KVM: x86/mmu: Fix NX page unaccounting for TDP MMU pages
@ 2026-09-15 20:35 Carlos López
2026-09-15 20:45 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Carlos López @ 2026-09-15 20:35 UTC (permalink / raw)
To: kvm, seanjc, pbonzini
Cc: Carlos López, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
H. Peter Anvin, Vipin Sharma, James Houghton,
open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)
unaccount_nx_huge_page() unconditionally passes KVM_SHADOW_MMU to
untrack_possible_nx_huge_page(), which is incorrect, particularly on
the path from kvm_recover_nx_huge_pages(), which handles pages from
both MMUs. Fix this by retrieving the MMU type via is_tdp_mmu_page()
and passing it down.
Fixes: 6777885605e1 ("KVM: x86/mmu: Track possible NX huge pages separately for TDP vs. Shadow MMU")
Signed-off-by: Carlos López <clopez@suse.de>
---
arch/x86/kvm/mmu/mmu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 9788ff180374..61996669b6f6 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -866,9 +866,11 @@ void untrack_possible_nx_huge_page(struct kvm *kvm, struct kvm_mmu_page *sp,
static void unaccount_nx_huge_page(struct kvm *kvm, struct kvm_mmu_page *sp)
{
+ enum kvm_mmu_type mmu_type = is_tdp_mmu_page(sp) ? KVM_TDP_MMU : KVM_SHADOW_MMU;
+
sp->nx_huge_page_disallowed = false;
- untrack_possible_nx_huge_page(kvm, sp, KVM_SHADOW_MMU);
+ untrack_possible_nx_huge_page(kvm, sp, mmu_type);
}
static struct kvm_memory_slot *gfn_to_memslot_dirty_bitmap(struct kvm_vcpu *vcpu,
base-commit: 70c944caf570fda2d79baa71435589a8db39f048
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: x86/mmu: Fix NX page unaccounting for TDP MMU pages
2026-09-15 20:35 [PATCH] KVM: x86/mmu: Fix NX page unaccounting for TDP MMU pages Carlos López
@ 2026-09-15 20:45 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-09-15 20:45 UTC (permalink / raw)
To: Carlos López; +Cc: kvm
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] mmu: build failure on 32-bit x86 due to undeclared KVM_TDP_MMU
--
commit c2443a58667359b4d898625aee21d7fa954accfd
Author: Carlos López <clopez@suse.de>
KVM: x86/mmu: Fix NX page unaccounting for TDP MMU pages
This commit fixes unaccounting of NX huge pages for TDP MMU pages by passing
the correct MMU type to untrack_possible_nx_huge_page() instead of always
hardcoding KVM_SHADOW_MMU.
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index 9788ff1803740..61996669b6f6a 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
[ ... ]
> @@ -866,9 +866,11 @@ void untrack_possible_nx_huge_page(struct kvm *kvm, struct kvm_mmu_page *sp,
>
> static void unaccount_nx_huge_page(struct kvm *kvm, struct kvm_mmu_page *sp)
> {
> + enum kvm_mmu_type mmu_type = is_tdp_mmu_page(sp) ? KVM_TDP_MMU : KVM_SHADOW_MMU;
[Severity: Low]
Will this break the build on 32-bit x86 systems? KVM_TDP_MMU is only defined
when CONFIG_X86_64 is enabled. Unconditionally referencing it here in
unaccount_nx_huge_page() will result in an undeclared identifier error when
compiling KVM with CONFIG_X86_32=y.
> +
> sp->nx_huge_page_disallowed = false;
>
> - untrack_possible_nx_huge_page(kvm, sp, KVM_SHADOW_MMU);
> + untrack_possible_nx_huge_page(kvm, sp, mmu_type);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260915203511.1808028-1-clopez@suse.de?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-15 20:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-15 20:35 [PATCH] KVM: x86/mmu: Fix NX page unaccounting for TDP MMU pages Carlos López
2026-09-15 20:45 ` sashiko-bot
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.