]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86/mmu: do not allow readers to acquire references to invalid roots
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 2 Mar 2022 13:51:05 +0000 (08:51 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 8 Mar 2022 14:31:50 +0000 (09:31 -0500)
commit0e267c6a8fe1f5cf75f151a5ab4d579a24f998b4
tree7fed2fb3b95db2290cadb58bf886b1a9d3c77225
parent996ac7129f8ccd54dea3b3ae1337a816b31df6d8
KVM: x86/mmu: do not allow readers to acquire references to invalid roots

Remove the "shared" argument of for_each_tdp_mmu_root_yield_safe, thus ensuring
that readers do not ever acquire a reference to an invalid root.  After this
patch, all readers except kvm_tdp_mmu_zap_invalidated_roots() treat
refcount=0/valid, refcount=0/invalid and refcount=1/invalid in exactly the
same way.  kvm_tdp_mmu_zap_invalidated_roots() is different but it also
does not acquire a reference to the invalid root, and it cannot see
refcount=0/invalid because it is guaranteed to run after
kvm_tdp_mmu_invalidate_all_roots().

Opportunistically add a lockdep assertion to the yield-safe iterator.

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