Skip to content

Commit be399d8

Browse files
sean-jcPeter Zijlstra
authored andcommitted
KVM: arm64: Hide kvm_arm_pmu_available behind CONFIG_HW_PERF_EVENTS=y
Move the definition of kvm_arm_pmu_available to pmu-emul.c and, out of "necessity", hide it behind CONFIG_HW_PERF_EVENTS. Provide a stub for the key's wrapper, kvm_arm_support_pmu_v3(). Moving the key's definition out of perf.c will allow a future commit to delete perf.c entirely. Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20211111020738.2512932-16-seanjc@google.com
1 parent 7b51783 commit be399d8

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

arch/arm64/kernel/image-vars.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ KVM_NVHE_ALIAS(__stop___kvm_ex_table);
102102
KVM_NVHE_ALIAS(kvm_arm_hyp_percpu_base);
103103

104104
/* PMU available static key */
105+
#ifdef CONFIG_HW_PERF_EVENTS
105106
KVM_NVHE_ALIAS(kvm_arm_pmu_available);
107+
#endif
106108

107109
/* Position-independent library routines */
108110
KVM_NVHE_ALIAS_HYP(clear_page, __pi_clear_page);

arch/arm64/kvm/perf.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
#include <asm/kvm_emulate.h>
1313

14-
DEFINE_STATIC_KEY_FALSE(kvm_arm_pmu_available);
15-
1614
void kvm_perf_init(void)
1715
{
1816
kvm_register_perf_callbacks(NULL);

arch/arm64/kvm/pmu-emul.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <kvm/arm_pmu.h>
1515
#include <kvm/arm_vgic.h>
1616

17+
DEFINE_STATIC_KEY_FALSE(kvm_arm_pmu_available);
18+
1719
static void kvm_pmu_create_perf_event(struct kvm_vcpu *vcpu, u64 select_idx);
1820
static void kvm_pmu_update_pmc_chained(struct kvm_vcpu *vcpu, u64 select_idx);
1921
static void kvm_pmu_stop_counter(struct kvm_vcpu *vcpu, struct kvm_pmc *pmc);

include/kvm/arm_pmu.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313
#define ARMV8_PMU_CYCLE_IDX (ARMV8_PMU_MAX_COUNTERS - 1)
1414
#define ARMV8_PMU_MAX_COUNTER_PAIRS ((ARMV8_PMU_MAX_COUNTERS + 1) >> 1)
1515

16-
DECLARE_STATIC_KEY_FALSE(kvm_arm_pmu_available);
17-
18-
static __always_inline bool kvm_arm_support_pmu_v3(void)
19-
{
20-
return static_branch_likely(&kvm_arm_pmu_available);
21-
}
22-
2316
#ifdef CONFIG_HW_PERF_EVENTS
2417

2518
struct kvm_pmc {
@@ -36,6 +29,13 @@ struct kvm_pmu {
3629
struct irq_work overflow_work;
3730
};
3831

32+
DECLARE_STATIC_KEY_FALSE(kvm_arm_pmu_available);
33+
34+
static __always_inline bool kvm_arm_support_pmu_v3(void)
35+
{
36+
return static_branch_likely(&kvm_arm_pmu_available);
37+
}
38+
3939
#define kvm_arm_pmu_irq_initialized(v) ((v)->arch.pmu.irq_num >= VGIC_NR_SGIS)
4040
u64 kvm_pmu_get_counter_value(struct kvm_vcpu *vcpu, u64 select_idx);
4141
void kvm_pmu_set_counter_value(struct kvm_vcpu *vcpu, u64 select_idx, u64 val);
@@ -65,6 +65,11 @@ int kvm_arm_pmu_v3_enable(struct kvm_vcpu *vcpu);
6565
struct kvm_pmu {
6666
};
6767

68+
static inline bool kvm_arm_support_pmu_v3(void)
69+
{
70+
return false;
71+
}
72+
6873
#define kvm_arm_pmu_irq_initialized(v) (false)
6974
static inline u64 kvm_pmu_get_counter_value(struct kvm_vcpu *vcpu,
7075
u64 select_idx)

0 commit comments

Comments
 (0)