FAILED: patch "[PATCH] KVM: x86/mmu: Use split "zap all fast" helpers when" failed to apply to 6.12-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x db095727ff5739f4f46ee641ee6ef450032886db
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090923-sleep-shore-e015@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From db095727ff5739f4f46ee641ee6ef450032886db Mon Sep 17 00:00:00 2001
From: Sean Christopherson <[email protected]>
Date: Thu, 9 Jul 2026 13:49:39 -0700
Subject: [PATCH] KVM: x86/mmu: Use split "zap all fast" helpers when
invalidating memslot
Manually invoke the front half and back half of the "zap all fast" flow when invalidating a memslot so that mmu_lock is acquired at function scope
in kvm_arch_flush_shadow_memslot(). This will allow putting more code
inside the critical section without having to take mmu_lock twice in quick succession.
Opportunistically open code checking whether or not to do the fast zap, to discourage removing the local "zap_all" in a future cleanup, i.e. to ensure the SLOT_ZAP_ALL quirk is queried exactly once. Processing the front half but not the back half of the fast zap (if SLOT_ZAP_ALL were disabled concurrently) would result in KVM unnecessarily keeping invalid TDP MMU roots until the VM is destroyed.
No functional change intended.
arch/x86/kvm/mmu/mmu.c +11 -10
@@ -7573,12 +7573,6 @@ static void kvm_mmu_zap_memslot_pages_and_flush(struct kvm *kvm,kvm_mmu_remote_flush_or_zap (kvm, &invalid_list, flush); } -static inline bool kvm_memslot_flush_zap_all (struct kvm *kvm) -{ -return kvm->arch.vm_type ==KVM_X86_DEFAULT_VM && -kvm_check_has_quirk (kvm,KVM_X86_QUIRK_SLOT_ZAP_ALL ); -} -void kvm_arch_flush_shadow_memslot (struct kvm *kvm,struct kvm_memory_slot *slot) {
@@ -7589,16 +7583,23 @@ void kvm_arch_flush_shadow_memslot(struct kvm *kvm, .may_block = true, .attr_filter = KVM_FILTER_PRIVATE | KVM_FILTER_SHARED, }; +bool zap_all = kvm->arch.vm_type ==KVM_X86_DEFAULT_VM && +kvm_check_has_quirk (kvm,KVM_X86_QUIRK_SLOT_ZAP_ALL );bool flush; -if (kvm_memslot_flush_zap_all (kvm)) { -kvm_mmu_zap_all_fast (kvm); +write_lock (&kvm->mmu_lock); + +if (zap_all) { +__kvm_mmu_zap_all_fast_front_half (kvm); }else { -write_lock (&kvm->mmu_lock); flush =kvm_unmap_gfn_range (kvm, &range);kvm_mmu_zap_memslot_pages_and_flush (kvm, slot, flush); -write_unlock (&kvm->mmu_lock); } + +write_unlock (&kvm->mmu_lock); + +if (zap_all) +__kvm_mmu_zap_all_fast_back_half (kvm); }void kvm_mmu_invalidate_mmio_sptes (struct kvm *kvm,u64 gen)