Skip to content

Commit fcdffe9

Browse files
committed
KVM: x86/mmu: Don't do TLB flush when zappings SPTEs in invalid roots
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>
1 parent 8ca9836 commit fcdffe9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

arch/x86/kvm/mmu/tdp_mmu.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,13 @@ static bool tdp_mmu_zap_leafs(struct kvm *kvm, struct kvm_mmu_page *root,
811811
continue;
812812

813813
tdp_mmu_iter_set_spte(kvm, &iter, 0);
814-
flush = true;
814+
815+
/*
816+
* Zappings SPTEs in invalid roots doesn't require a TLB flush,
817+
* see kvm_tdp_mmu_zap_invalidated_roots() for details.
818+
*/
819+
if (!root->role.invalid)
820+
flush = true;
815821
}
816822

817823
rcu_read_unlock();

0 commit comments

Comments
 (0)