diff options
author | Like Xu <likexu@tencent.com> | 2022-06-01 05:19:24 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2022-06-08 19:06:17 +0200 |
commit | 6ef25aa0a961298278301ae1d88106c701eb73fa (patch) | |
tree | bd57de8db47e08927d016a4153d9f707a09dfe76 /arch/x86/kvm/pmu.h | |
parent | KVM: x86/pmu: Avoid exposing Intel BTS feature (diff) | |
download | linux-6ef25aa0a961298278301ae1d88106c701eb73fa.tar.xz linux-6ef25aa0a961298278301ae1d88106c701eb73fa.zip |
KVM: x86/pmu: Restrict advanced features based on module enable_pmu
Once vPMU is disabled, the KVM would not expose features like:
PEBS (via clear kvm_pmu_cap.pebs_ept), legacy LBR and ARCH_LBR,
CPUID 0xA leaf, PDCM bit and MSR_IA32_PERF_CAPABILITIES, plus
PT_MODE_HOST_GUEST mode.
What this group of features has in common is that their use
relies on the underlying PMU counter and the host perf_event as a
back-end resource requester or sharing part of the irq delivery path.
Signed-off-by: Like Xu <likexu@tencent.com>
Message-Id: <20220601031925.59693-2-likexu@tencent.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/pmu.h')
-rw-r--r-- | arch/x86/kvm/pmu.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/x86/kvm/pmu.h b/arch/x86/kvm/pmu.h index 2c5b3c9f5531..c1b61671ba1e 100644 --- a/arch/x86/kvm/pmu.h +++ b/arch/x86/kvm/pmu.h @@ -170,9 +170,11 @@ static inline void kvm_init_pmu_capability(void) * For Intel, only support guest architectural pmu * on a host with architectural pmu. */ - if ((is_intel && !kvm_pmu_cap.version) || !kvm_pmu_cap.num_counters_gp) { - memset(&kvm_pmu_cap, 0, sizeof(kvm_pmu_cap)); + if ((is_intel && !kvm_pmu_cap.version) || !kvm_pmu_cap.num_counters_gp) enable_pmu = false; + + if (!enable_pmu) { + memset(&kvm_pmu_cap, 0, sizeof(kvm_pmu_cap)); return; } |