[PATCH v2 18/54] KVM: x86/pmu: Add a helper to check if passthrough PMU is enabled

Mingwei Zhang
2024-05-06T05:31:00Z

Add a helper to check if passthrough PMU is enabled for convenience as it
is vendor neutral.

Signed-off-by: Mingwei Zhang <mizhang@google.com>
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
---
arch/x86/kvm/pmu.h | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/arch/x86/kvm/pmu.h b/arch/x86/kvm/pmu.h
index cf93be5e7359..56ba0772568c 100644
--- a/arch/x86/kvm/pmu.h
+++ b/arch/x86/kvm/pmu.h
@@ -48,6 +48,11 @@ struct kvm_pmu_ops {

void kvm_pmu_ops_update(const struct kvm_pmu_ops *pmu_ops);

+static inline bool is_passthrough_pmu_enabled(struct kvm_vcpu *vcpu)
+{
+ return vcpu_to_pmu(vcpu)->passthrough;
+}
+
static inline bool kvm_pmu_has_perf_global_ctrl(struct kvm_pmu *pmu)
{
/*
--
2.45.0.rc1.225.g2a3ae87e7f-goog