From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796035240; b=F0bW4CNBdZB4YGHIyCWuJ/c6ge/Mj2JDFm6zDj19Eo1Ba6UrRRa6jSgIirJikwFL0BM+ UUct57gWUEobAjBQ1+7+ZhfcrlgTvjwxe2ZeFBO1dEfZ+MvPXWbsHOENXKz/JwyrMFv34 JN+C38pEDXfy/OOmGQ8E8mzhhvMUQytSzgiv4ooSCVZFnibfO0ZEpc6Us5QYHcW1nJCkl YG01d2EIoLfNqCSJ7UMUh2sd/VNPX4pF7rD/vXJpGRQAsDq9J9zdysTImP7cayKqq7EYF bywxgqCUhYxlHPXMuG5BZcSRtosFZJKapMeipZSmLSPUcmLCxQucC9OrKlazqkh2/AQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796035240; h=DMARC-Filter:Received:Received:DKIM-Signature:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=M9xE2ROWujFaY8ZFJuRuwVVfVJEii/1+BgsNjFE161o=; b=Z1vTJBjPiO4sB7eGQ/BuILT2ufZicgeVZ4vv58sWeVBkiOJJC4dlEhANQqXAqJ6N7UCD WuPQ/VNboE+n7+oi1p2z+J1776PPgxRaECIu4VQt2/dU3y8ubaXHE2T6XiKnFUmLfOYgT UZuuouHTYQi1NKWIGLYG2XJ77X/BUXFAEtLB7vaiq9vP4CBTqBRreShNM8HG3BArq92i4 SOiaWbT18jeMmQOkYnk7OMp6WDhAyChNuzFodk0vLD9rLTaFiB8jZSj1GoyNXTIgVb7vT CIxjBJLqWL+qBkbAxWvCyoFw78WtDGq7swmsY6TU53QD09HPEpKKi7yAcR7R/8nqhOg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=kfhvefi3; arc=none smtp.remote-ip=217.140.110.172 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C46D6606A32C; Mon, 30 Nov 2026 10:40:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C46D6606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=kfhvefi3 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DF1CF1476; Mon, 30 Nov 2026 02:40:34 -0800 (PST) Received: from localhost (unknown [10.2.196.114]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4F33B3F86F; Mon, 30 Nov 2026 02:40:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796035237; bh=314dqM3LDxtlcAur04P1HYTpJGRjo/32fyzHVIAxLo0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kfhvefi38r+VrmyZiOTAWchSZ0/ubz+hzCBmLQmxFgmKsr3DOKT9pikBm/qz8SCz8 izAveM0avFSGjcW9bX1GhIyj4TZoGt9DCudNxA0smA6FsgU8zQUtlIqfTz+9IMpwC+ iPrtVzX2Yc79UC6ZuNt0I7Sa+kjRBCOIKrnLK/KY= Date: Mon, 30 Nov 2026 10:40:35 +0000 From: Leo Yan To: Ping Li 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 Message-ID: <20261130104035.GJ861809@e132581.arm.com> References: <20261130061331.90095-1-leeonion.muyu@gmail.com> <20261130061331.90095-3-leeonion.muyu@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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