From: Like Xu Date: Mon, 9 May 2022 10:22:02 +0000 (+0800) Subject: KVM: x86/pmu: Ignore pmu->global_ctrl check if vPMU doesn't support global_ctrl X-Git-Tag: baikal/mips/sdk5.9~47 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=9dacc72789fb8beffd19f8b2e6b954f038f5d292;p=kernel.git KVM: x86/pmu: Ignore pmu->global_ctrl check if vPMU doesn't support global_ctrl [ Upstream commit 4e83d1d616f7b8eca0441569e4af13bb96e07c94 ] MSR_CORE_PERF_GLOBAL_CTRL is introduced as part of Architecture PMU V2, as indicated by Intel SDM 19.2.2 and the intel_is_valid_msr() function. So in the absence of global_ctrl support, all PMCs are enabled as AMD does. Signed-off-by: Like Xu Message-Id: <20220509102204.62389-1-likexu@tencent.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c index c66edf93e4a82..f9054e7ec89ed 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -104,6 +104,9 @@ static bool intel_pmc_is_enabled(struct kvm_pmc *pmc) { struct kvm_pmu *pmu = pmc_to_pmu(pmc); + if (pmu->version < 2) + return true; + return test_bit(pmc->idx, (unsigned long *)&pmu->global_ctrl); }