From: Ping Li <leeonion.muyu@gmail.com>
To: will@kernel.org, mark.rutland@arm.com
Cc: robh@kernel.org, leo.yan@arm.com, james.clark@linaro.org,
linux-arm-kernel@lists.infradead.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Ping Li <leeonion.muyu@gmail.com>
Subject: [PATCH v2 1/2] perf: arm_spe: Validate the inverse event filter against PMSNEVFR_EL1
Date: Mon, 30 Nov 2026 14:13:30 +0800 [thread overview]
Message-ID: <20261130061331.90095-2-leeonion.muyu@gmail.com> (raw)
In-Reply-To: <20261130061331.90095-1-leeonion.muyu@gmail.com>
config3 is validated against the mask probed from PMSEVFR_EL1, even
though it is written verbatim to PMSNEVFR_EL1. Implementations are
expected to use the same bit positions for the two registers, but the
borrowed mask also lets an invalid config pass the early check when
FEAT_INV_FILT_EVT is absent, deferring the error to the later
PMSFCR_EL1.FnE feature check.
Probe the supported filter bits of PMSNEVFR_EL1 separately and
validate config3 against its own mask. Keep a full mask when the
feature is not implemented so that any attempt to use the inverse
event filter is rejected at the earliest opportunity.
Fixes: 8d9190f00a975 ("perf: arm_spe: Add support for SPEv1.2 inverted event filtering")
Signed-off-by: Ping Li <leeonion.muyu@gmail.com>
---
drivers/perf/arm_spe_pmu.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c
index 707778c67dab..0b1a088bb7c7 100644
--- a/drivers/perf/arm_spe_pmu.c
+++ b/drivers/perf/arm_spe_pmu.c
@@ -92,6 +92,7 @@ struct arm_spe_pmu {
u64 features;
u64 pmsevfr_res0;
+ u64 pmsnevfr_res0;
u16 max_record_sz;
u16 align;
struct perf_output_handle __percpu *handle;
@@ -818,7 +819,7 @@ static int arm_spe_pmu_event_init(struct perf_event *event)
if (arm_spe_event_to_pmsevfr(event) & spe_pmu->pmsevfr_res0)
return -EOPNOTSUPP;
- if (arm_spe_event_to_pmsnevfr(event) & spe_pmu->pmsevfr_res0)
+ if (arm_spe_event_to_pmsnevfr(event) & spe_pmu->pmsnevfr_res0)
return -EOPNOTSUPP;
if (arm_spe_event_to_pmsdsfr(event) != U64_MAX &&
@@ -1228,6 +1229,13 @@ static void __arm_spe_pmu_dev_probe(void *info)
write_sysreg_s(U64_MAX, SYS_PMSEVFR_EL1);
spe_pmu->pmsevfr_res0 = ~read_sysreg_s(SYS_PMSEVFR_EL1);
+ if (spe_pmu->features & SPE_PMU_FEAT_INV_FILT_EVT) {
+ write_sysreg_s(U64_MAX, SYS_PMSNEVFR_EL1);
+ spe_pmu->pmsnevfr_res0 = ~read_sysreg_s(SYS_PMSNEVFR_EL1);
+ } else {
+ spe_pmu->pmsnevfr_res0 = U64_MAX;
+ }
+
dev_info(dev,
"probed SPEv1.%d for CPUs %*pbl [max_record_sz %u, align %u, features 0x%llx]\n",
spe_pmu->pmsver - 1, cpumask_pr_args(&spe_pmu->supported_cpus),
--
2.34.1
next prev parent reply other threads:[~2026-11-30 6:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 6:13 [PATCH v2 0/2] perf: arm_spe: Validate the filter configs per-bit Ping Li
2026-11-30 6:13 ` Ping Li [this message]
2026-11-30 6:13 ` [PATCH v2 2/2] perf: arm_spe: Validate the data source filter per-bit Ping Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261130061331.90095-2-leeonion.muyu@gmail.com \
--to=leeonion.muyu@gmail.com \
--cc=james.clark@linaro.org \
--cc=leo.yan@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=robh@kernel.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox