[PATCH v2 47/54] KVM: x86/pmu/svm: Set passthrough capability for vcpus

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

From: Sandipan Das <sandipan.das@amd.com>

Pass on the passthrough PMU setting from kvm->arch into kvm_pmu for each
vcpu. As long as the host supports PerfMonV2, the guest PMU version does
not matter.

Signed-off-by: Sandipan Das <sandipan.das@amd.com>
---
arch/x86/kvm/svm/pmu.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/x86/kvm/svm/pmu.c b/arch/x86/kvm/svm/pmu.c
index 447657513729..385478103f65 100644
--- a/arch/x86/kvm/svm/pmu.c
+++ b/arch/x86/kvm/svm/pmu.c
@@ -211,6 +211,7 @@ static void amd_pmu_refresh(struct kvm_vcpu *vcpu)
pmu->counter_bitmask[KVM_PMC_FIXED] = 0;
pmu->nr_arch_fixed_counters = 0;
bitmap_set(pmu->all_valid_pmc_idx, 0, pmu->nr_arch_gp_counters);
+ pmu->passthrough = vcpu->kvm->arch.enable_passthrough_pmu;

if (guest_cpuid_has(vcpu, X86_FEATURE_PERFCTR_CORE)) {
for (i = 0; i < pmu->nr_arch_gp_counters; i++) {
--
2.45.0.rc1.225.g2a3ae87e7f-goog