]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: x86/mmu: Demote the WARN on yielded in xxx_cond_resched() to KVM_MMU_WARN_ON
authorSean Christopherson <seanjc@google.com>
Thu, 31 Oct 2024 17:06:33 +0000 (10:06 -0700)
committerSean Christopherson <seanjc@google.com>
Tue, 5 Nov 2024 02:37:18 +0000 (18:37 -0800)
Convert the WARN in tdp_mmu_iter_cond_resched() that the iterator hasn't
already yielded to a KVM_MMU_WARN_ON() so the code is compiled out for
production kernels (assuming production kernels disable KVM_PROVE_MMU).

Checking for a needed reschedule is a hot path, and KVM sanity checks
iter->yielded in several other less-hot paths, i.e. the odds of KVM not
flagging that something went sideways are quite low.  Furthermore, the
odds of KVM not noticing *and* the WARN detecting something worth
investigating are even lower.

Link: https://lore.kernel.org/r/20241031170633.1502783-3-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/mmu/tdp_mmu.c

index 8170b16b91c373dcfb0c310897727383d6dc0033..ef44dcba1ecbc3eaa585e371b4c2b43a09684e83 100644 (file)
@@ -656,7 +656,7 @@ static inline bool __must_check tdp_mmu_iter_cond_resched(struct kvm *kvm,
                                                          struct tdp_iter *iter,
                                                          bool flush, bool shared)
 {
-       WARN_ON_ONCE(iter->yielded);
+       KVM_MMU_WARN_ON(iter->yielded);
 
        if (!need_resched() && !rwlock_needbreak(&kvm->mmu_lock))
                return false;