aboutsummaryrefslogtreecommitdiff
path: root/arch/x86/kvm/pmu.c
diff options
context:
space:
mode:
authorGravatar Aaron Lewis <aaronlewis@google.com> 2022-12-20 16:12:30 +0000
committerGravatar Sean Christopherson <seanjc@google.com> 2023-01-24 10:06:10 -0800
commit6a5cba7bed35580effda9fb1872b274da47e6b23 (patch)
treeacd176cf254c9a1a2fe9dff712f28ef0de78e6c9 /arch/x86/kvm/pmu.c
parentKVM: PPC: Fix refactoring goof in kvmppc_e500mc_init() (diff)
downloadlinux-6a5cba7bed35580effda9fb1872b274da47e6b23.tar.gz
linux-6a5cba7bed35580effda9fb1872b274da47e6b23.tar.bz2
linux-6a5cba7bed35580effda9fb1872b274da47e6b23.zip
KVM: x86/pmu: Correct the mask used in a pmu event filter lookup
When checking if a pmu event the guest is attempting to program should be filtered, only consider the event select + unit mask in that decision. Use an architecture specific mask to mask out all other bits, including bits 35:32 on Intel. Those bits are not part of the event select and should not be considered in that decision. Fixes: 66bb8a065f5a ("KVM: x86: PMU Event Filter") Signed-off-by: Aaron Lewis <aaronlewis@google.com> Link: https://lore.kernel.org/r/20221220161236.555143-2-aaronlewis@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'arch/x86/kvm/pmu.c')
-rw-r--r--arch/x86/kvm/pmu.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
index d939d3b84e6f..f5b933eeb549 100644
--- a/arch/x86/kvm/pmu.c
+++ b/arch/x86/kvm/pmu.c
@@ -279,7 +279,8 @@ static bool check_pmu_event_filter(struct kvm_pmc *pmc)
goto out;
if (pmc_is_gp(pmc)) {
- key = pmc->eventsel & AMD64_RAW_EVENT_MASK_NB;
+ key = pmc->eventsel & (kvm_pmu_ops.EVENTSEL_EVENT |
+ ARCH_PERFMON_EVENTSEL_UMASK);
if (bsearch(&key, filter->events, filter->nevents,
sizeof(__u64), cmp_u64))
allow_event = filter->action == KVM_PMU_EVENT_ALLOW;