Skip to content

Commit 8a1300f

Browse files
committed
KVM: x86: Rename Hyper-V remote TLB hooks to match established scheme
Rename the Hyper-V hooks for TLB flushing to match the naming scheme used by all the other TLB flushing hooks, e.g. in kvm_x86_ops, vendor code, arch hooks from common code, etc. Reviewed-by: David Matlack <dmatlack@google.com> Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com> Link: https://lore.kernel.org/r/20230405003133.419177-2-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 40fa907 commit 8a1300f

7 files changed

Lines changed: 25 additions & 29 deletions

File tree

arch/x86/include/asm/kvm-x86-ops.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ KVM_X86_OP(set_rflags)
5454
KVM_X86_OP(get_if_flag)
5555
KVM_X86_OP(flush_tlb_all)
5656
KVM_X86_OP(flush_tlb_current)
57-
KVM_X86_OP_OPTIONAL(tlb_remote_flush)
58-
KVM_X86_OP_OPTIONAL(tlb_remote_flush_with_range)
57+
KVM_X86_OP_OPTIONAL(flush_remote_tlbs)
58+
KVM_X86_OP_OPTIONAL(flush_remote_tlbs_range)
5959
KVM_X86_OP(flush_tlb_gva)
6060
KVM_X86_OP(flush_tlb_guest)
6161
KVM_X86_OP(vcpu_pre_run)

arch/x86/include/asm/kvm_host.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,9 +1588,9 @@ struct kvm_x86_ops {
15881588

15891589
void (*flush_tlb_all)(struct kvm_vcpu *vcpu);
15901590
void (*flush_tlb_current)(struct kvm_vcpu *vcpu);
1591-
int (*tlb_remote_flush)(struct kvm *kvm);
1592-
int (*tlb_remote_flush_with_range)(struct kvm *kvm,
1593-
struct kvm_tlb_range *range);
1591+
int (*flush_remote_tlbs)(struct kvm *kvm);
1592+
int (*flush_remote_tlbs_range)(struct kvm *kvm,
1593+
struct kvm_tlb_range *range);
15941594

15951595
/*
15961596
* Flush any TLB entries associated with the given GVA.
@@ -1794,8 +1794,8 @@ void kvm_arch_free_vm(struct kvm *kvm);
17941794
#define __KVM_HAVE_ARCH_FLUSH_REMOTE_TLB
17951795
static inline int kvm_arch_flush_remote_tlb(struct kvm *kvm)
17961796
{
1797-
if (kvm_x86_ops.tlb_remote_flush &&
1798-
!static_call(kvm_x86_tlb_remote_flush)(kvm))
1797+
if (kvm_x86_ops.flush_remote_tlbs &&
1798+
!static_call(kvm_x86_flush_remote_tlbs)(kvm))
17991799
return 0;
18001800
else
18011801
return -ENOTSUPP;

arch/x86/kvm/kvm_onhyperv.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ static inline int hv_remote_flush_root_tdp(hpa_t root_tdp,
2929
return hyperv_flush_guest_mapping(root_tdp);
3030
}
3131

32-
int hv_remote_flush_tlb_with_range(struct kvm *kvm,
33-
struct kvm_tlb_range *range)
32+
int hv_flush_remote_tlbs_range(struct kvm *kvm, struct kvm_tlb_range *range)
3433
{
3534
struct kvm_arch *kvm_arch = &kvm->arch;
3635
struct kvm_vcpu *vcpu;
@@ -86,19 +85,19 @@ int hv_remote_flush_tlb_with_range(struct kvm *kvm,
8685
spin_unlock(&kvm_arch->hv_root_tdp_lock);
8786
return ret;
8887
}
89-
EXPORT_SYMBOL_GPL(hv_remote_flush_tlb_with_range);
88+
EXPORT_SYMBOL_GPL(hv_flush_remote_tlbs_range);
9089

91-
int hv_remote_flush_tlb(struct kvm *kvm)
90+
int hv_flush_remote_tlbs(struct kvm *kvm)
9291
{
93-
return hv_remote_flush_tlb_with_range(kvm, NULL);
92+
return hv_flush_remote_tlbs_range(kvm, NULL);
9493
}
95-
EXPORT_SYMBOL_GPL(hv_remote_flush_tlb);
94+
EXPORT_SYMBOL_GPL(hv_flush_remote_tlbs);
9695

9796
void hv_track_root_tdp(struct kvm_vcpu *vcpu, hpa_t root_tdp)
9897
{
9998
struct kvm_arch *kvm_arch = &vcpu->kvm->arch;
10099

101-
if (kvm_x86_ops.tlb_remote_flush == hv_remote_flush_tlb) {
100+
if (kvm_x86_ops.flush_remote_tlbs == hv_flush_remote_tlbs) {
102101
spin_lock(&kvm_arch->hv_root_tdp_lock);
103102
vcpu->arch.hv_root_tdp = root_tdp;
104103
if (root_tdp != kvm_arch->hv_root_tdp)

arch/x86/kvm/kvm_onhyperv.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
#define __ARCH_X86_KVM_KVM_ONHYPERV_H__
88

99
#if IS_ENABLED(CONFIG_HYPERV)
10-
int hv_remote_flush_tlb_with_range(struct kvm *kvm,
11-
struct kvm_tlb_range *range);
12-
int hv_remote_flush_tlb(struct kvm *kvm);
10+
int hv_flush_remote_tlbs_range(struct kvm *kvm, struct kvm_tlb_range *range);
11+
int hv_flush_remote_tlbs(struct kvm *kvm);
1312
void hv_track_root_tdp(struct kvm_vcpu *vcpu, hpa_t root_tdp);
1413
#else /* !CONFIG_HYPERV */
1514
static inline void hv_track_root_tdp(struct kvm_vcpu *vcpu, hpa_t root_tdp)

arch/x86/kvm/mmu/mmu.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,9 @@ static inline unsigned long kvm_mmu_get_guest_pgd(struct kvm_vcpu *vcpu,
270270
return mmu->get_guest_pgd(vcpu);
271271
}
272272

273-
static inline bool kvm_available_flush_tlb_with_range(void)
273+
static inline bool kvm_available_flush_remote_tlbs_range(void)
274274
{
275-
return kvm_x86_ops.tlb_remote_flush_with_range;
275+
return kvm_x86_ops.flush_remote_tlbs_range;
276276
}
277277

278278
void kvm_flush_remote_tlbs_range(struct kvm *kvm, gfn_t start_gfn,
@@ -284,8 +284,8 @@ void kvm_flush_remote_tlbs_range(struct kvm *kvm, gfn_t start_gfn,
284284
range.start_gfn = start_gfn;
285285
range.pages = nr_pages;
286286

287-
if (kvm_x86_ops.tlb_remote_flush_with_range)
288-
ret = static_call(kvm_x86_tlb_remote_flush_with_range)(kvm, &range);
287+
if (kvm_x86_ops.flush_remote_tlbs_range)
288+
ret = static_call(kvm_x86_flush_remote_tlbs_range)(kvm, &range);
289289

290290
if (ret)
291291
kvm_flush_remote_tlbs(kvm);
@@ -1498,7 +1498,7 @@ static bool kvm_set_pte_rmap(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
14981498
}
14991499
}
15001500

1501-
if (need_flush && kvm_available_flush_tlb_with_range()) {
1501+
if (need_flush && kvm_available_flush_remote_tlbs_range()) {
15021502
kvm_flush_remote_tlbs_gfn(kvm, gfn, level);
15031503
return false;
15041504
}
@@ -6623,7 +6623,7 @@ static bool kvm_mmu_zap_collapsible_spte(struct kvm *kvm,
66236623
PG_LEVEL_NUM)) {
66246624
kvm_zap_one_rmap_spte(kvm, rmap_head, sptep);
66256625

6626-
if (kvm_available_flush_tlb_with_range())
6626+
if (kvm_available_flush_remote_tlbs_range())
66276627
kvm_flush_remote_tlbs_sptep(kvm, sptep);
66286628
else
66296629
need_tlb_flush = 1;

arch/x86/kvm/svm/svm_onhyperv.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ static inline __init void svm_hv_hardware_setup(void)
3535
if (npt_enabled &&
3636
ms_hyperv.nested_features & HV_X64_NESTED_ENLIGHTENED_TLB) {
3737
pr_info(KBUILD_MODNAME ": Hyper-V enlightened NPT TLB flush enabled\n");
38-
svm_x86_ops.tlb_remote_flush = hv_remote_flush_tlb;
39-
svm_x86_ops.tlb_remote_flush_with_range =
40-
hv_remote_flush_tlb_with_range;
38+
svm_x86_ops.flush_remote_tlbs = hv_flush_remote_tlbs;
39+
svm_x86_ops.flush_remote_tlbs_range = hv_flush_remote_tlbs_range;
4140
}
4241

4342
if (ms_hyperv.nested_features & HV_X64_NESTED_DIRECT_FLUSH) {

arch/x86/kvm/vmx/vmx.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8432,9 +8432,8 @@ static __init int hardware_setup(void)
84328432
#if IS_ENABLED(CONFIG_HYPERV)
84338433
if (ms_hyperv.nested_features & HV_X64_NESTED_GUEST_MAPPING_FLUSH
84348434
&& enable_ept) {
8435-
vmx_x86_ops.tlb_remote_flush = hv_remote_flush_tlb;
8436-
vmx_x86_ops.tlb_remote_flush_with_range =
8437-
hv_remote_flush_tlb_with_range;
8435+
vmx_x86_ops.flush_remote_tlbs = hv_flush_remote_tlbs;
8436+
vmx_x86_ops.flush_remote_tlbs_range = hv_flush_remote_tlbs_range;
84388437
}
84398438
#endif
84408439

0 commit comments

Comments
 (0)