]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
KVM: x86/mmu: WARN if TDP MMU's set_tdp_spte() sees multiple GFNs
authorSean Christopherson <seanjc@google.com>
Fri, 26 Feb 2021 01:03:26 +0000 (17:03 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 26 Feb 2021 13:36:09 +0000 (08:36 -0500)
WARN if set_tdp_spte() is invoked with multipel GFNs.  It is specifically
a callback to handle a single host PTE being changed.  Consuming the
@end parameter also eliminates the confusing 'unused' parameter.

Cc: Ben Gardon <bgardon@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210226010329.1766033-3-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/tdp_mmu.c

index 3290e53fb850de9336566f080ac5b96f3c3b86af..020f2e573f44de63cdd81714e343b4de823f9ef1 100644 (file)
@@ -1022,7 +1022,7 @@ int kvm_tdp_mmu_test_age_hva(struct kvm *kvm, unsigned long hva)
  * Returns non-zero if a flush is needed before releasing the MMU lock.
  */
 static int set_tdp_spte(struct kvm *kvm, struct kvm_memory_slot *slot,
-                       struct kvm_mmu_page *root, gfn_t gfn, gfn_t unused,
+                       struct kvm_mmu_page *root, gfn_t gfn, gfn_t end,
                        unsigned long data)
 {
        struct tdp_iter iter;
@@ -1033,7 +1033,7 @@ static int set_tdp_spte(struct kvm *kvm, struct kvm_memory_slot *slot,
 
        rcu_read_lock();
 
-       WARN_ON(pte_huge(*ptep));
+       WARN_ON(pte_huge(*ptep) || (gfn + 1) != end);
 
        new_pfn = pte_pfn(*ptep);