KVM: x86/mmu: only perform eager page splitting on valid roots
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 2 Mar 2022 13:44:22 +0000 (08:44 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 8 Mar 2022 14:31:50 +0000 (09:31 -0500)
Eager page splitting is an optimization; it does not have to be performed on
invalid roots.  It is also the only case in which a reader might acquire
a reference to an invalid root, so after this change we know that readers
will skip both dying and invalid roots.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/tdp_mmu.c

index 30424fbceb5f370c06805b69d9f4d0adb656e2e6..d39593b9ac9e0da93f7c26c9d3c7d1c79433885f 100644 (file)
@@ -1464,7 +1464,7 @@ void kvm_tdp_mmu_try_split_huge_pages(struct kvm *kvm,
 
        kvm_lockdep_assert_mmu_lock_held(kvm, shared);
 
-       for_each_tdp_mmu_root_yield_safe(kvm, root, slot->as_id, shared) {
+       for_each_valid_tdp_mmu_root_yield_safe(kvm, root, slot->as_id, shared) {
                r = tdp_mmu_split_huge_pages_root(kvm, root, start, end, target_level, shared);
                if (r) {
                        kvm_tdp_mmu_put_root(kvm, root, shared);