From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796019850; b=qw+fE2J8JeZQVFgNoIN/xCsDwQa6CBLNz8SIKvwRBp490HolfbLrav2Mo7u5lIxMroNL jkqu0vHuT3M1Dq0ERhVKGEDSHxz97g3o6nmm7jwLv99XsS3phMmbUbniUcHT6vit5Dy4j bnnRaMvloacelpeSO7Y11d14Og3SVst7ZM991SesbibwEQEwKxrUKdoMXHzCW0kU48Cv9 LAh5qhPQ+WEQN+ZnwUJMn5vZDPSkGIr4XdFQVd3MDi4R6i/Jo/j/sTOfhiQHigO3/No33 zVsWdf6J8WpdNR7QuVE07rBFVekNKftglS0WdRxCJJsjLyGRwRLc5bamnXReOrzzZ1Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796019850; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=UApR07EgdkesLvLkINh2w8IuP/8E7V/SPtZGDs90y4c=; b=Qhdid7Gm2XJw0skZxcQaw/Bb3py23mBCKk1bzB8iLxMeHNR2Ns0YGZ5984ImsUm7fWUk fa54dW/B+bJUKffofyoFnYiWnAW8MBN3UHLkAEdKiqcJWsudfEJCFeLnUdO9OfpZ/I68a FcSNMbkdU0dwvceKhvp4q0xq8EdsnjNnKGqlBZUhH7H/c2Zj1T3Abd00WLtBxjgp63i/C YiPuZpEYVj5/CQi9yKTS3lzSelT5LoAeXx1BMb8LWVn/tIE5cR1jvJ0kdiV8EobHohwNs QxumrpvNhgwOVAFXNzZV2OPO1RQV1ZJ09cdtgpNi3BhR44QIGayLeUqAd+LunhpGIuw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kmYowF13; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 503C7606A31C for ; Mon, 30 Nov 2026 06:24:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kmYowF13 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 859B71F00896; Mon, 30 Nov 2026 06:24:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796019849; bh=UApR07EgdkesLvLkINh2w8IuP/8E7V/SPtZGDs90y4c=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=kmYowF133QeQWPuxrHS2aE2kbebd5a7tQBggkh6AzuqI3sQ4XfjsgCjgbMdGdCGww sTZg6rwxa+oLsvArt7WIIrn/Mq6lixcrUD7qWTBBSaiYtRLDkuAQCxmBaU7yBJejgD Gdw8muidWuVGeDzSDL6LAFUnVFxfDenz/mYcDUDfLDXFlZTGGMs39oU+VzI8HflCqt TZNCkukYVR9oW8O+w7QxVN0hdf4C398xtzgdS1vB+5L2OOahIna8nK0EJz9RAl4lFS bWpbjgon2p9OozyUrAcacvtWQeHxr6qmrJCqeLW+o0KwGJRnzoOiJPtX+LnxI5QeIm 1KDYrg7p713NQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 2/2] perf: arm_spe: Validate the data source filter per-bit Reply-To: sashiko-reviews@lists.linux.dev To: "Ping Li" Cc: linux-perf-users@vger.kernel.org In-Reply-To: <20261130061331.90095-3-leeonion.muyu@gmail.com> References: <20261130061331.90095-1-leeonion.muyu@gmail.com> <20261130061331.90095-3-leeonion.muyu@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 06:24:09 +0000 X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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; > =20 > - if (arm_spe_event_to_pmsdsfr(event) !=3D 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 =3D arm_spe_event_to_pmsdsfr(event); > + if (reg !=3D 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=3D0x1, 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? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130061331.9009= 5-1-leeonion.muyu@gmail.com?part=3D2