KVM: x86/pmu: Prevent the PMU from counting disallowed events
authorAaron Lewis <aaronlewis@google.com>
Tue, 7 Mar 2023 14:13:56 +0000 (14:13 +0000)
committerSean Christopherson <seanjc@google.com>
Fri, 7 Apr 2023 16:24:16 +0000 (09:24 -0700)
commitdfdeda67ea2dac57d2d7506d65cfe5a0878ad285
treecf88035aea3e9860e1cca9e3d500c345776e7185
parent4fa5843d81fdce9ba7e03f8a666e2f8e592aec2b
KVM: x86/pmu: Prevent the PMU from counting disallowed events

When counting "Instructions Retired" (0xc0) in a guest, KVM will
occasionally increment the PMU counter regardless of if that event is
being filtered. This is because some PMU events are incremented via
kvm_pmu_trigger_event(), which doesn't know about the event filter. Add
the event filter to kvm_pmu_trigger_event(), so events that are
disallowed do not increment their counters.

Fixes: 9cd803d496e7 ("KVM: x86: Update vPMCs when retiring instructions")
Signed-off-by: Aaron Lewis <aaronlewis@google.com>
Reviewed-by: Like Xu <likexu@tencent.com>
Link: https://lore.kernel.org/r/20230307141400.1486314-2-aaronlewis@google.com
[sean: prepend "pmc" to the new function]
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/pmu.c