aboutsummaryrefslogtreecommitdiff
path: root/arch/x86/kvm/cpuid.c
diff options
context:
space:
mode:
authorGravatar Like Xu <likexu@tencent.com> 2022-01-11 15:38:23 +0800
committerGravatar Paolo Bonzini <pbonzini@redhat.com> 2022-01-17 12:56:03 -0500
commit4732f2444acd9b7eabc744f20eb5cc9694c0bfbd (patch)
tree66dab7a1b1d173842630ce98a8e67a63f0fc2291 /arch/x86/kvm/cpuid.c
parentKVM: selftests: Test KVM_SET_CPUID2 after KVM_RUN (diff)
downloadlinux-4732f2444acd9b7eabc744f20eb5cc9694c0bfbd.tar.gz
linux-4732f2444acd9b7eabc744f20eb5cc9694c0bfbd.tar.bz2
linux-4732f2444acd9b7eabc744f20eb5cc9694c0bfbd.zip
KVM: x86: Making the module parameter of vPMU more common
The new module parameter to control PMU virtualization should apply to Intel as well as AMD, for situations where userspace is not trusted. If the module parameter allows PMU virtualization, there could be a new KVM_CAP or guest CPUID bits whereby userspace can enable/disable PMU virtualization on a per-VM basis. If the module parameter does not allow PMU virtualization, there should be no userspace override, since we have no precedent for authorizing that kind of override. If it's false, other counter-based profiling features (such as LBR including the associated CPUID bits if any) will not be exposed. Change its name from "pmu" to "enable_pmu" as we have temporary variables with the same name in our code like "struct kvm_pmu *pmu". Fixes: b1d66dad65dc ("KVM: x86/svm: Add module param to control PMU virtualization") Suggested-by : Jim Mattson <jmattson@google.com> Signed-off-by: Like Xu <likexu@tencent.com> Message-Id: <20220111073823.21885-1-likexu@tencent.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/cpuid.c')
-rw-r--r--arch/x86/kvm/cpuid.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 7eb046d907c6..a7c280d2113b 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -845,10 +845,10 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
perf_get_x86_pmu_capability(&cap);
/*
- * Only support guest architectural pmu on a host
- * with architectural pmu.
+ * The guest architecture pmu is only supported if the architecture
+ * pmu exists on the host and the module parameters allow it.
*/
- if (!cap.version)
+ if (!cap.version || !enable_pmu)
memset(&cap, 0, sizeof(cap));
eax.split.version_id = min(cap.version, 2);