Don't force a TLB flush when zapping SPTEs in invalid roots as vCPUs
can't be actively using invalid roots (zapping SPTEs in invalid roots is
necessary only to ensure KVM doesn't mark a page accessed/dirty after it
is freed by the primary MMU).
Link: https://lore.kernel.org/r/20240111020048.844847-3-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
 
                        continue;
 
                tdp_mmu_iter_set_spte(kvm, &iter, 0);
-               flush = true;
+
+               /*
+                * Zappings SPTEs in invalid roots doesn't require a TLB flush,
+                * see kvm_tdp_mmu_zap_invalidated_roots() for details.
+                */
+               if (!root->role.invalid)
+                       flush = true;
        }
 
        rcu_read_unlock();