]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: x86/mmu: WARN if old _or_ new SPTE is REMOVED in non-atomic path
authorSean Christopherson <seanjc@google.com>
Sat, 26 Feb 2022 00:15:29 +0000 (00:15 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 8 Mar 2022 14:31:53 +0000 (09:31 -0500)
WARN if the new_spte being set by __tdp_mmu_set_spte() is a REMOVED_SPTE,
which is called out by the comment as being disallowed but not actually
checked.  Keep the WARN on the old_spte as well, because overwriting a
REMOVED_SPTE in the non-atomic path is also disallowed (as evidence by
lack of splats with the existing WARN).

Fixes: b219723c11b8 ("KVM: x86/mmu: Flush TLBs after zap in TDP MMU PF handler")
Cc: Ben Gardon <bgardon@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Ben Gardon <bgardon@google.com>
Message-Id: <20220226001546.360188-12-seanjc@google.com>
Reviewed-by: Mingwei Zhang <mizhang@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/tdp_mmu.c

index 371b6a1087368648057786130432df1cc76c904c..41175ee7e1110494e345eb0826b227f5484c43b0 100644 (file)
@@ -626,13 +626,13 @@ static inline void __tdp_mmu_set_spte(struct kvm *kvm, struct tdp_iter *iter,
        lockdep_assert_held_write(&kvm->mmu_lock);
 
        /*
-        * No thread should be using this function to set SPTEs to the
+        * No thread should be using this function to set SPTEs to or from the
         * temporary removed SPTE value.
         * If operating under the MMU lock in read mode, tdp_mmu_set_spte_atomic
         * should be used. If operating under the MMU lock in write mode, the
         * use of the removed SPTE should not be necessary.
         */
-       WARN_ON(is_removed_spte(iter->old_spte));
+       WARN_ON(is_removed_spte(iter->old_spte) || is_removed_spte(new_spte));
 
        kvm_tdp_mmu_write_spte(iter->sptep, new_spte);