From: Leo Yan <leo.yan@arm.com>
To: Ping Li <leeonion.muyu@gmail.com>
Cc: will@kernel.org, mark.rutland@arm.com, robh@kernel.org,
james.clark@linaro.org, linux-arm-kernel@lists.infradead.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] perf: arm_spe: Validate the data source filter per-bit
Date: Mon, 30 Nov 2026 10:40:35 +0000 [thread overview]
Message-ID: <20261130104035.GJ861809@e132581.arm.com> (raw)
In-Reply-To: <20261130061331.90095-3-leeonion.muyu@gmail.com>
On Mon, Nov 30, 2026 at 02:13:31PM +0800, Ping Li wrote:
[...]
> @@ -822,9 +823,19 @@ static int arm_spe_pmu_event_init(struct perf_event *event)
> if (arm_spe_event_to_pmsnevfr(event) & spe_pmu->pmsnevfr_res0)
> return -EOPNOTSUPP;
>
> - if (arm_spe_event_to_pmsdsfr(event) != U64_MAX &&
> - !(spe_pmu->features & SPE_PMU_FEAT_FDS))
> - return -EOPNOTSUPP;
> + /*
> + * The data source filter is exposed inverted, so validate the
> + * value written to PMSDSFR_EL1 (~config4) rather than config4
> + * itself.
> + */
> + reg = arm_spe_event_to_pmsdsfr(event);
> + if (reg != U64_MAX) {
> + if (!(spe_pmu->features & SPE_PMU_FEAT_FDS))
> + return -EOPNOTSUPP;
> +
> + if (reg & spe_pmu->pmsdsfr_res0)
> + return -EOPNOTSUPP;
Sashiko's comment seems reasonable:
"When userspace excludes a supported data source such as
inv_data_src_filter=0x1, bits 1..63 are 0 in config4 and 1 in reg, so
arm_spe_pmu_event_init() fails with -EOPNOTSUPP on any CPU with
unimplemented bits in PMSDSFR_EL1, and spe_pmu->pmsdsfr_res0 is not
exposed in sysfs caps/ for userspace to mask out. Conversely, a non-zero
config4 that only sets unimplemented RAZ/WI bits clears those bits in reg
and passes this check while enabling PMSFCR_EL1.FDS as a no-op filter.
Should this validate config4 (or ~reg) against spe_pmu->pmsdsfr_res0
instead?"
So, I'd update code and put comment directly above it:
/*
* Each set bit in config4 (~reg) requests a data source
* exclusion. Check for bits that lack filter support.
*/
if (~reg & spe_pmu->pmsdsfr_res0)
return -EOPNOTSUPP;
Thanks,
Leo
next prev parent reply other threads:[~2026-11-30 10:40 UTC|newest]
Thread overview: 9+ 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 ` [PATCH v2 1/2] perf: arm_spe: Validate the inverse event filter against PMSNEVFR_EL1 Ping Li
2026-11-30 10:42 ` James Clark
2026-11-30 10:56 ` Leo Yan
2026-11-30 6:13 ` [PATCH v2 2/2] perf: arm_spe: Validate the data source filter per-bit Ping Li
2026-11-30 10:40 ` Leo Yan [this message]
2026-11-30 14:51 ` James Clark
[not found] <"20261130104035.GJ861809@e132581.arm.com">
2026-11-30 13:17 ` Ping Li
2026-11-30 14:50 ` Leo Yan
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=20261130104035.GJ861809@e132581.arm.com \
--to=leo.yan@arm.com \
--cc=james.clark@linaro.org \
--cc=leeonion.muyu@gmail.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