]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86/mmu: Avoid unnecessary page table allocation in kvm_tdp_mmu_map()
authorKai Huang <kai.huang@intel.com>
Thu, 29 Apr 2021 04:12:26 +0000 (16:12 +1200)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 3 May 2021 15:25:33 +0000 (11:25 -0400)
commit1091705120a0a253e5d36e184520595bf6b33173
tree8afc57deac51ab0d9038cb2eeacfa8e651e65337
parent08ac2f1907cab29b6c6a2714d88c949962b6541c
KVM: x86/mmu: Avoid unnecessary page table allocation in kvm_tdp_mmu_map()

In kvm_tdp_mmu_map(), while iterating TDP MMU page table entries, it is
possible SPTE has already been frozen by another thread but the frozen
is not done yet, for instance, when another thread is still in middle of
zapping large page.  In this case, the !is_shadow_present_pte() check
for old SPTE in tdp_mmu_for_each_pte() may hit true, and in this case
allocating new page table is unnecessary since tdp_mmu_set_spte_atomic()
later will return false and page table will need to be freed.  Add
is_removed_spte() check before allocating new page table to avoid this.

Signed-off-by: Kai Huang <kai.huang@intel.com>
Message-Id: <20210429041226.50279-1-kai.huang@intel.com>
Reviewed-by: Ben Gardon <bgardon@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/tdp_mmu.c