pmu.c (9635adf8541ae9cbead19d769dce2c945fa88de6) pmu.c (6a5cba7bed35580effda9fb1872b274da47e6b23)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Kernel-based Virtual Machine -- Performance Monitoring Unit support
4 *
5 * Copyright 2015 Red Hat, Inc. and/or its affiliates.
6 *
7 * Authors:
8 * Avi Kivity <avi@redhat.com>
9 * Gleb Natapov <gleb@redhat.com>
10 * Wei Huang <wei@redhat.com>
11 */
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Kernel-based Virtual Machine -- Performance Monitoring Unit support
4 *
5 * Copyright 2015 Red Hat, Inc. and/or its affiliates.
6 *
7 * Authors:
8 * Avi Kivity <avi@redhat.com>
9 * Gleb Natapov <gleb@redhat.com>
10 * Wei Huang <wei@redhat.com>
11 */
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
12
13#include <linux/types.h>
14#include <linux/kvm_host.h>
15#include <linux/perf_event.h>
16#include <linux/bsearch.h>
17#include <linux/sort.h>
18#include <asm/perf_event.h>
19#include <asm/cpu_device_id.h>

--- 253 unchanged lines hidden (view full) ---

273 if (!static_call(kvm_x86_pmu_hw_event_available)(pmc))
274 return false;
275
276 filter = srcu_dereference(kvm->arch.pmu_event_filter, &kvm->srcu);
277 if (!filter)
278 goto out;
279
280 if (pmc_is_gp(pmc)) {
13
14#include <linux/types.h>
15#include <linux/kvm_host.h>
16#include <linux/perf_event.h>
17#include <linux/bsearch.h>
18#include <linux/sort.h>
19#include <asm/perf_event.h>
20#include <asm/cpu_device_id.h>

--- 253 unchanged lines hidden (view full) ---

274 if (!static_call(kvm_x86_pmu_hw_event_available)(pmc))
275 return false;
276
277 filter = srcu_dereference(kvm->arch.pmu_event_filter, &kvm->srcu);
278 if (!filter)
279 goto out;
280
281 if (pmc_is_gp(pmc)) {
281 key = pmc->eventsel & AMD64_RAW_EVENT_MASK_NB;
282 key = pmc->eventsel & (kvm_pmu_ops.EVENTSEL_EVENT |
283 ARCH_PERFMON_EVENTSEL_UMASK);
282 if (bsearch(&key, filter->events, filter->nevents,
283 sizeof(__u64), cmp_u64))
284 allow_event = filter->action == KVM_PMU_EVENT_ALLOW;
285 else
286 allow_event = filter->action == KVM_PMU_EVENT_DENY;
287 } else {
288 idx = pmc->idx - INTEL_PMC_IDX_FIXED;
289 if (filter->action == KVM_PMU_EVENT_DENY &&

--- 363 unchanged lines hidden ---
284 if (bsearch(&key, filter->events, filter->nevents,
285 sizeof(__u64), cmp_u64))
286 allow_event = filter->action == KVM_PMU_EVENT_ALLOW;
287 else
288 allow_event = filter->action == KVM_PMU_EVENT_DENY;
289 } else {
290 idx = pmc->idx - INTEL_PMC_IDX_FIXED;
291 if (filter->action == KVM_PMU_EVENT_DENY &&

--- 363 unchanged lines hidden ---