Skip to content

Commit 7780938

Browse files
Sean Christophersonbonzini
authored andcommitted
KVM: x86: Rename ->tlb_flush() to ->tlb_flush_all()
Rename ->tlb_flush() to ->tlb_flush_all() in preparation for adding a new hook to flush only the current ASID/context. Opportunstically replace the comment in vmx_flush_tlb() that explains why it flushes all EPTP/VPID contexts with a comment explaining why it unconditionally uses INVEPT when EPT is enabled. I.e. rely on the "all" part of the name to clarify why it does global INVEPT/INVVPID. No functional change intended. Signed-off-by: Sean Christopherson <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 4a41e43 commit 7780938

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ struct kvm_x86_ops {
11031103
unsigned long (*get_rflags)(struct kvm_vcpu *vcpu);
11041104
void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags);
11051105

1106-
void (*tlb_flush)(struct kvm_vcpu *vcpu);
1106+
void (*tlb_flush_all)(struct kvm_vcpu *vcpu);
11071107
int (*tlb_remote_flush)(struct kvm *kvm);
11081108
int (*tlb_remote_flush_with_range)(struct kvm *kvm,
11091109
struct kvm_tlb_range *range);

arch/x86/kvm/mmu/mmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5179,7 +5179,7 @@ int kvm_mmu_load(struct kvm_vcpu *vcpu)
51795179
if (r)
51805180
goto out;
51815181
kvm_mmu_load_pgd(vcpu);
5182-
kvm_x86_ops.tlb_flush(vcpu);
5182+
kvm_x86_ops.tlb_flush_all(vcpu);
51835183
out:
51845184
return r;
51855185
}

arch/x86/kvm/svm/svm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3944,7 +3944,7 @@ static struct kvm_x86_ops svm_x86_ops __initdata = {
39443944
.get_rflags = svm_get_rflags,
39453945
.set_rflags = svm_set_rflags,
39463946

3947-
.tlb_flush = svm_flush_tlb,
3947+
.tlb_flush_all = svm_flush_tlb,
39483948
.tlb_flush_gva = svm_flush_tlb_gva,
39493949
.tlb_flush_guest = svm_flush_tlb,
39503950

arch/x86/kvm/vmx/vmx.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2838,18 +2838,16 @@ static void exit_lmode(struct kvm_vcpu *vcpu)
28382838

28392839
#endif
28402840

2841-
static void vmx_flush_tlb(struct kvm_vcpu *vcpu)
2841+
static void vmx_flush_tlb_all(struct kvm_vcpu *vcpu)
28422842
{
28432843
struct vcpu_vmx *vmx = to_vmx(vcpu);
28442844

28452845
/*
2846-
* Flush all EPTP/VPID contexts, as the TLB flush _may_ have been
2847-
* invoked via kvm_flush_remote_tlbs(). Flushing remote TLBs requires
2848-
* all contexts to be flushed, not just the active context.
2849-
*
2850-
* Note, this also ensures a deferred TLB flush with VPID enabled and
2851-
* EPT disabled invalidates the "correct" VPID, by nuking both L1 and
2852-
* L2's VPIDs.
2846+
* INVEPT must be issued when EPT is enabled, irrespective of VPID, as
2847+
* the CPU is not required to invalidate guest-physical mappings on
2848+
* VM-Entry, even if VPID is disabled. Guest-physical mappings are
2849+
* associated with the root EPT structure and not any particular VPID
2850+
* (INVVPID also isn't required to invalidate guest-physical mappings).
28532851
*/
28542852
if (enable_ept) {
28552853
ept_sync_global();
@@ -7765,7 +7763,7 @@ static struct kvm_x86_ops vmx_x86_ops __initdata = {
77657763
.get_rflags = vmx_get_rflags,
77667764
.set_rflags = vmx_set_rflags,
77677765

7768-
.tlb_flush = vmx_flush_tlb,
7766+
.tlb_flush_all = vmx_flush_tlb_all,
77697767
.tlb_flush_gva = vmx_flush_tlb_gva,
77707768
.tlb_flush_guest = vmx_flush_tlb_guest,
77717769

arch/x86/kvm/x86.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2690,10 +2690,10 @@ static void kvmclock_reset(struct kvm_vcpu *vcpu)
26902690
vcpu->arch.time = 0;
26912691
}
26922692

2693-
static void kvm_vcpu_flush_tlb(struct kvm_vcpu *vcpu)
2693+
static void kvm_vcpu_flush_tlb_all(struct kvm_vcpu *vcpu)
26942694
{
26952695
++vcpu->stat.tlb_flush;
2696-
kvm_x86_ops.tlb_flush(vcpu);
2696+
kvm_x86_ops.tlb_flush_all(vcpu);
26972697
}
26982698

26992699
static void kvm_vcpu_flush_tlb_guest(struct kvm_vcpu *vcpu)
@@ -8223,7 +8223,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
82238223
if (kvm_check_request(KVM_REQ_LOAD_MMU_PGD, vcpu))
82248224
kvm_mmu_load_pgd(vcpu);
82258225
if (kvm_check_request(KVM_REQ_TLB_FLUSH, vcpu))
8226-
kvm_vcpu_flush_tlb(vcpu);
8226+
kvm_vcpu_flush_tlb_all(vcpu);
82278227
if (kvm_check_request(KVM_REQ_HV_TLB_FLUSH, vcpu))
82288228
kvm_vcpu_flush_tlb_guest(vcpu);
82298229
if (kvm_check_request(KVM_REQ_REPORT_TPR_ACCESS, vcpu)) {

0 commit comments

Comments
 (0)