From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0993BC433F5 for ; Mon, 11 Apr 2022 10:30:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rVKFqrAS4TeMoDtgIm2OeOhD38BfTjVx0nDoQbA8XPk=; b=K6I+XicblPSTfP bXBjPhtNOyhnlqqtqNnIhxHa4mdxwd5eahuFYKZL0JF6v+DOBfav7KYnYllGPa4wb1PfEpb+BNeAT F1k2pzrTgkp+TZusHFeB11Y945/oOxGJWBMiEoH+et/BpBtPmBl+V9j8ZE1MWBSNOVRW5yqBsnrsA Bg+wkGDkgOwSoVNklDqZzXAney6P0N+mZreTKVUSD1+rego1gcbRkAiK4huhHe9U3CMhgsttr3DvN WrwWjZ1gnZ8iAOvhlkcUQnOMsURhBzZshpFU8rj2plga709e79K2hZWe2K4cNDqK0evzdEekZ0lfB zYoi/1eGCYOlgAjRidpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ndrI4-008KuZ-JG; Mon, 11 Apr 2022 10:29:00 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ndquR-0089mr-JM for linux-arm-kernel@lists.infradead.org; Mon, 11 Apr 2022 10:04:37 +0000 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 6B4A1169E; Mon, 11 Apr 2022 03:04:34 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.9.30]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6CC9A3F5A1; Mon, 11 Apr 2022 03:04:33 -0700 (PDT) Date: Mon, 11 Apr 2022 11:04:26 +0100 From: Mark Rutland To: Rob Herring Cc: Will Deacon , Al Grant , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm_pmu: Validate single/group leader events Message-ID: References: <20220408203330.4014015-1-robh@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220408203330.4014015-1-robh@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220411_030435_743069_83EF3282 X-CRM114-Status: GOOD ( 19.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Rob, On Fri, Apr 08, 2022 at 03:33:30PM -0500, Rob Herring wrote: > In the case where there is only a cycle counter available (i.e. > PMCR_EL0.N is 0) and an event other than CPU cycles is opened, the open > should fail as the event can never possibly be scheduled. However, the > event validation when an event is opened is skipped when the group > leader is opened. Fix this by always validating the group leader events. > > Reported-by: Al Grant > Cc: Will Deacon > Cc: Mark Rutland > Signed-off-by: Rob Herring This looks obviously correct to me, so FWIW: Acked-by: Mark Rutland Just to check, have you tested this (e.g. by running on a platform with PMCR_EL0.N == 0, or hacking the PMU probing to report just the cycle counter) Thanks, Mark. > --- > drivers/perf/arm_pmu.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c > index 9694370651fa..59d3980b8ca2 100644 > --- a/drivers/perf/arm_pmu.c > +++ b/drivers/perf/arm_pmu.c > @@ -400,6 +400,9 @@ validate_group(struct perf_event *event) > if (!validate_event(event->pmu, &fake_pmu, leader)) > return -EINVAL; > > + if (event == leader) > + return 0; > + > for_each_sibling_event(sibling, leader) { > if (!validate_event(event->pmu, &fake_pmu, sibling)) > return -EINVAL; > @@ -489,12 +492,7 @@ __hw_perf_event_init(struct perf_event *event) > local64_set(&hwc->period_left, hwc->sample_period); > } > > - if (event->group_leader != event) { > - if (validate_group(event) != 0) > - return -EINVAL; > - } > - > - return 0; > + return validate_group(event); > } > > static int armpmu_event_init(struct perf_event *event) > -- > 2.32.0 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel