All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ping Li" <leeonion.muyu@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 2/2] perf: arm_spe: Validate the data source filter per-bit
Date: Mon, 30 Nov 2026 06:24:09 +0000	[thread overview]
Message-ID: <sashiko-outbox-240467@kernel.org> (raw)
In-Reply-To: <20261130061331.90095-3-leeonion.muyu@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] perf: arm_spe: inverted pmsdsfr_res0 check in
  arm_spe_pmu_event_init()
--

commit 85b6c511146b809ba3857b94de667a12bd64be40
Author: Ping Li <leeonion.muyu@gmail.com>

perf: arm_spe: Validate the data source filter per-bit

This commit probes the supported filter bits in PMSDSFR_EL1 when FDS is
implemented and validates the requested data source filter against
pmsdsfr_res0 in arm_spe_pmu_event_init().

> diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c
> index 0b1a088bb7c73..a0d0caf75145d 100644
> --- a/drivers/perf/arm_spe_pmu.c
> +++ b/drivers/perf/arm_spe_pmu.c

[ ... ]

> @@ -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;
> +	}

[Severity: High]
Does validating ~config4 against spe_pmu->pmsdsfr_res0 reject valid
exclusion masks in inv_data_src_filter?

arm_spe_event_to_pmsdsfr() returns ~config4, so every bit left at its
default 0 in config4 becomes 1 in reg.  Because spe_pmu->pmsdsfr_res0 has
1s for all unimplemented RAZ/WI bits in PMSDSFR_EL1, reg &
spe_pmu->pmsdsfr_res0 is non-zero whenever any unimplemented bit is left
at 0 in config4.

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?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130061331.90095-1-leeonion.muyu@gmail.com?part=2

  reply	other threads:[~2026-11-30  6:24 UTC|newest]

Thread overview: 12+ 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  6:24   ` sashiko-bot [this message]
2026-11-30 10:40   ` Leo Yan
2026-11-30 14:51   ` James Clark
2026-11-30  6:24 ` [PATCH v2 0/2] perf: arm_spe: Validate the filter configs per-bit sashiko-bot
     [not found] <"20261130104035.GJ861809@e132581.arm.com">
2026-11-30 13:17 ` [PATCH v2 2/2] perf: arm_spe: Validate the data source filter per-bit Ping Li
2026-11-30 14:50   ` Leo Yan
     [not found] <"3dffa952-9430-4947-b2b9-9a826f1cc938@linaro.org">
2026-12-01  3:31 ` 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=sashiko-outbox-240467@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=leeonion.muyu@gmail.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.