Skip to content

Commit 9ebc3f5

Browse files
Lai Jiangshansean-jc
authored andcommitted
KVM: x86/mmu: Use kvm_mmu_invalidate_addr() in kvm_mmu_invpcid_gva()
Use kvm_mmu_invalidate_addr() instead open calls to mmu->invlpg(). No functional change intended. Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com> Link: https://lore.kernel.org/r/20230216154115.710033-10-jiangshanlai@gmail.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent cd42853 commit 9ebc3f5

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

arch/x86/kvm/mmu/mmu.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5814,27 +5814,20 @@ EXPORT_SYMBOL_GPL(kvm_mmu_invlpg);
58145814
void kvm_mmu_invpcid_gva(struct kvm_vcpu *vcpu, gva_t gva, unsigned long pcid)
58155815
{
58165816
struct kvm_mmu *mmu = vcpu->arch.mmu;
5817-
bool tlb_flush = false;
5817+
unsigned long roots = 0;
58185818
uint i;
58195819

5820-
if (pcid == kvm_get_active_pcid(vcpu)) {
5821-
if (mmu->invlpg)
5822-
mmu->invlpg(vcpu, gva, mmu->root.hpa);
5823-
tlb_flush = true;
5824-
}
5820+
if (pcid == kvm_get_active_pcid(vcpu))
5821+
roots |= KVM_MMU_ROOT_CURRENT;
58255822

58265823
for (i = 0; i < KVM_MMU_NUM_PREV_ROOTS; i++) {
58275824
if (VALID_PAGE(mmu->prev_roots[i].hpa) &&
5828-
pcid == kvm_get_pcid(vcpu, mmu->prev_roots[i].pgd)) {
5829-
if (mmu->invlpg)
5830-
mmu->invlpg(vcpu, gva, mmu->prev_roots[i].hpa);
5831-
tlb_flush = true;
5832-
}
5825+
pcid == kvm_get_pcid(vcpu, mmu->prev_roots[i].pgd))
5826+
roots |= KVM_MMU_ROOT_PREVIOUS(i);
58335827
}
58345828

5835-
if (tlb_flush)
5836-
static_call(kvm_x86_flush_tlb_gva)(vcpu, gva);
5837-
5829+
if (roots)
5830+
kvm_mmu_invalidate_addr(vcpu, mmu, gva, roots);
58385831
++vcpu->stat.invlpg;
58395832

58405833
/*

0 commit comments

Comments
 (0)