OSDN Git Service

KVM: x86/pmu: Constrain the num of guest counters with kvm_pmu_cap
authorLike Xu <likexu@tencent.com>
Sat, 3 Jun 2023 01:10:55 +0000 (18:10 -0700)
committerSean Christopherson <seanjc@google.com>
Wed, 7 Jun 2023 00:31:44 +0000 (17:31 -0700)
commit1c2bf8a6b045a6ac4e75a7a07fde70db63e5a380
tree8bf7f1b2e759dd2f19e65aa636cb0f11a71aa8de
parentd338d8789e64b2d8ed2f82f9364c415d6efa118d
KVM: x86/pmu: Constrain the num of guest counters with kvm_pmu_cap

Cap the number of general purpose counters enumerated on AMD to what KVM
actually supports, i.e. don't allow userspace to coerce KVM into thinking
there are more counters than actually exist, e.g. by enumerating
X86_FEATURE_PERFCTR_CORE in guest CPUID when its not supported.

Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Like Xu <likexu@tencent.com>
[sean: massage changelog]
Link: https://lore.kernel.org/r/20230603011058.1038821-10-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/pmu.c