Skip to content

Commit 6de2ccc

Browse files
committed
KVM: x86/pmu: Move .hw_event_available() check out of PMC filter helper
Move the call to kvm_x86_pmu.hw_event_available(), which has nothing to with the userspace PMU filter, out of check_pmu_event_filter() and into its sole caller pmc_event_is_allowed(). pmc_event_is_allowed() didn't exist when commit 7aadaa9 ("KVM: x86/pmu: Drop amd_event_mapping[] in the KVM context"), so presumably the motivation for invoking .hw_event_available() from check_pmu_event_filter() was to avoid having to add multiple call sites. Link: https://lore.kernel.org/r/20230607010206.1425277-5-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 6d88d0e commit 6de2ccc

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

arch/x86/kvm/pmu.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,6 @@ static bool check_pmu_event_filter(struct kvm_pmc *pmc)
382382
struct kvm_x86_pmu_event_filter *filter;
383383
struct kvm *kvm = pmc->vcpu->kvm;
384384

385-
if (!static_call(kvm_x86_pmu_hw_event_available)(pmc))
386-
return false;
387-
388385
filter = srcu_dereference(kvm->arch.pmu_event_filter, &kvm->srcu);
389386
if (!filter)
390387
return true;
@@ -398,6 +395,7 @@ static bool check_pmu_event_filter(struct kvm_pmc *pmc)
398395
static bool pmc_event_is_allowed(struct kvm_pmc *pmc)
399396
{
400397
return pmc_is_globally_enabled(pmc) && pmc_speculative_in_use(pmc) &&
398+
static_call(kvm_x86_pmu_hw_event_available)(pmc) &&
401399
check_pmu_event_filter(pmc);
402400
}
403401

0 commit comments

Comments
 (0)