[PATCH] KVM: arm64: Do not free split_page_cache in kvm_arch_flush_shadow_all()
From: Aashish Sharma
Date: Tue Nov 24 2026 - 17:50:25 EST
kvm_arch_flush_shadow_all() is called from the MMU notifier ->release()
callback, which can run concurrently from __mmu_notifier_release() and
mmu_notifier_unregister(), as well as concurrently with VM ioctls
accessing split_page_cache under kvm->slots_lock. Calling
kvm_uninit_stage2_mmu() there invokes kvm_mmu_free_memory_cache()
without locking, which is not thread-safe and can double-free
split_page_cache.
Call kvm_free_stage2_pgd(&kvm->arch.mmu) directly instead.
kvm_arch_destroy_vm() already calls kvm_uninit_stage2_mmu() once after
mmu_notifier_unregister() completes and all VM references are gone
(see commit a3ca3bfd01b7 ("KVM: arm64: Destroy stage-2 page-table in
kvm_arch_destroy_vm()")).
Fixes: e7bf7a490c68 ("KVM: arm64: Split huge pages when dirty logging is enabled")
Cc: <stable@xxxxxxxxxxxxxxx> # 6.6.x: a3ca3bfd01b7: KVM: arm64: Destroy stage-2 page-table in kvm_arch_destroy_vm()
Cc: <stable@xxxxxxxxxxxxxxx> # 6.6.x
Signed-off-by: Aashish Sharma <aashish@xxxxxxxxxxxxxxxxx>
---
arch/arm64/kvm/nested.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c
index 4d83281a7a28..2440ad9fed87 100644
--- a/arch/arm64/kvm/nested.c
+++ b/arch/arm64/kvm/nested.c
@@ -1472,7 +1472,7 @@ void kvm_arch_flush_shadow_all(struct kvm *kvm)
if (!WARN_ON(atomic_read(&mmu->refcnt)))
kvm_free_stage2_pgd(mmu);
}
- kvm_uninit_stage2_mmu(kvm);
+ kvm_free_stage2_pgd(&kvm->arch.mmu);
}
/*
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
--
2.56.1.831.g720f3f5937-goog