]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: x86/mmu: Zap invalid roots with mmu_lock holding for write at uninit
authorRick Edgecombe <rick.p.edgecombe@intel.com>
Thu, 18 Jul 2024 21:12:13 +0000 (14:12 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 23 Dec 2024 13:28:49 +0000 (08:28 -0500)
commit35be969d1ef2c99a98f4b788f7839e6ee5b51ff8
treee73507980a9a8c48b9c5a400235fea3e1a24c6e2
parent67b43038ce14d6b0673bdffb2052d879065c94ae
KVM: x86/mmu: Zap invalid roots with mmu_lock holding for write at uninit

Prepare for a future TDX patch which asserts that atomic zapping
(i.e. zapping with mmu_lock taken for read) don't operate on mirror roots.
When tearing down a VM, all roots have to be zapped (including mirror
roots once they're in place) so do that with the mmu_lock taken for write.

kvm_mmu_uninit_tdp_mmu() is invoked either before or after executing any
atomic operations on SPTEs by vCPU threads. Therefore, it will not impact
vCPU threads performance if kvm_tdp_mmu_zap_invalidated_roots() acquires
mmu_lock for write to zap invalid roots.

Co-developed-by: Yan Zhao <yan.y.zhao@intel.com>
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Message-ID: <20240718211230.1492011-2-rick.p.edgecombe@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/mmu.c
arch/x86/kvm/mmu/tdp_mmu.c
arch/x86/kvm/mmu/tdp_mmu.h