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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81E65C433FE for ; Thu, 9 Dec 2021 09:21:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234720AbhLIJY6 (ORCPT ); Thu, 9 Dec 2021 04:24:58 -0500 Received: from foss.arm.com ([217.140.110.172]:52196 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232940AbhLIJY5 (ORCPT ); Thu, 9 Dec 2021 04:24:57 -0500 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 5DF6011FB; Thu, 9 Dec 2021 01:21:24 -0800 (PST) Received: from [10.57.82.128] (unknown [10.57.82.128]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3D31C3F73B; Thu, 9 Dec 2021 01:21:22 -0800 (PST) Message-ID: Date: Thu, 9 Dec 2021 09:21:20 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH 1/3] coresight: Add config flag to enable branch broadcast To: James Clark , mathieu.poirier@linaro.org, coresight@lists.linaro.org Cc: Mike Leach , Leo Yan , John Garry , Will Deacon , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org References: <20211208160907.749482-1-james.clark@arm.com> From: Suzuki K Poulose In-Reply-To: <20211208160907.749482-1-james.clark@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/12/2021 16:09, James Clark wrote: > When enabled, all taken branch addresses are output, even if the branch > was because of a direct branch instruction. This enables reconstruction > of the program flow without having access to the memory image of the > code being executed. > > Use bit 8 for the config option which would be the correct bit for > programming ETMv3. Although branch broadcast can't be enabled on ETMv3 > because it's not in the define ETM3X_SUPPORTED_OPTIONS, using the > correct bit might help prevent future collisions or allow it to be > enabled if needed. > > Signed-off-by: James Clark > --- > drivers/hwtracing/coresight/coresight-etm-perf.c | 2 ++ > drivers/hwtracing/coresight/coresight-etm4x-core.c | 9 +++++++++ > include/linux/coresight-pmu.h | 2 ++ > 3 files changed, 13 insertions(+) > > diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c > index c039b6ae206f..43bbd5dc3d3b 100644 > --- a/drivers/hwtracing/coresight/coresight-etm-perf.c > +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c > @@ -52,6 +52,7 @@ static DEFINE_PER_CPU(struct coresight_device *, csdev_src); > * The PMU formats were orignally for ETMv3.5/PTM's ETMCR 'config'; > * now take them as general formats and apply on all ETMs. > */ > +PMU_FORMAT_ATTR(branch_broadcast, "config:"__stringify(ETM_OPT_BRANCH_BROADCAST)); > PMU_FORMAT_ATTR(cycacc, "config:" __stringify(ETM_OPT_CYCACC)); > /* contextid1 enables tracing CONTEXTIDR_EL1 for ETMv4 */ > PMU_FORMAT_ATTR(contextid1, "config:" __stringify(ETM_OPT_CTXTID)); > @@ -97,6 +98,7 @@ static struct attribute *etm_config_formats_attr[] = { > &format_attr_sinkid.attr, > &format_attr_preset.attr, > &format_attr_configid.attr, > + &format_attr_branch_broadcast.attr, > NULL, > }; > > diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c > index bf18128cf5de..d2bafb50c66a 100644 > --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c > +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c > @@ -692,6 +692,15 @@ static int etm4_parse_event_config(struct coresight_device *csdev, > ret = cscfg_csdev_enable_active_config(csdev, cfg_hash, preset); > } > > + /* branch broadcast - enable if selected and supported */ > + if (attr->config & BIT(ETM_OPT_BRANCH_BROADCAST)) { > + if (!drvdata->trcbb) { > + ret = -EINVAL; > + goto out; > + } else > + config->cfg |= BIT(ETM4_CFG_BIT_BB); nit: For consistent styling, I would recommend to wrap the else case also in { }. Otherwise looks good to me. Suzuki 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 F2DD2C433F5 for ; Thu, 9 Dec 2021 09:23:33 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=u7VRBZZWZDg5wM2K57hSasdNXBHob2kmQYh9Ko5Rkw0=; b=30Kp9oUrFEsQof YHygDBMAOwmtrLnw36ZCaciOBlj6GPhqQ5TSADS3L8bnYb3Hhpn22lCPXaYzkAA2PRGnoO50xvKoG eqC2n0zcDRKsnEoya2iBLe+sFAjTKhX4VBPLhv2oIQcYmEG+hB2i5pyBp2/Vuo73NEjl4gt561oLj elLeg0c8GTzBwFJ13D/xaWfKcjOyo8zwh3QXUegmw6s4emiIuR8wy3ElIaecVl1EsX8seh9pJbreH Rd8Mbar2Ahu7fsMemKIT/x4l3pVYbajCPTrAQaTRmgQr/Xe7IIgO/Nx0GXYbHSDPnEhvtjWqAhoIi 33QMv5HLL+GXOLh5piuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvFcQ-00FOrI-B2; Thu, 09 Dec 2021 09:21:39 +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 1mvFcD-00FOnl-Sl for linux-arm-kernel@lists.infradead.org; Thu, 09 Dec 2021 09:21:27 +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 5DF6011FB; Thu, 9 Dec 2021 01:21:24 -0800 (PST) Received: from [10.57.82.128] (unknown [10.57.82.128]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3D31C3F73B; Thu, 9 Dec 2021 01:21:22 -0800 (PST) Message-ID: Date: Thu, 9 Dec 2021 09:21:20 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH 1/3] coresight: Add config flag to enable branch broadcast To: James Clark , mathieu.poirier@linaro.org, coresight@lists.linaro.org Cc: Mike Leach , Leo Yan , John Garry , Will Deacon , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org References: <20211208160907.749482-1-james.clark@arm.com> From: Suzuki K Poulose In-Reply-To: <20211208160907.749482-1-james.clark@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211209_012126_101557_9F3D4B15 X-CRM114-Status: GOOD ( 22.36 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 08/12/2021 16:09, James Clark wrote: > When enabled, all taken branch addresses are output, even if the branch > was because of a direct branch instruction. This enables reconstruction > of the program flow without having access to the memory image of the > code being executed. > > Use bit 8 for the config option which would be the correct bit for > programming ETMv3. Although branch broadcast can't be enabled on ETMv3 > because it's not in the define ETM3X_SUPPORTED_OPTIONS, using the > correct bit might help prevent future collisions or allow it to be > enabled if needed. > > Signed-off-by: James Clark > --- > drivers/hwtracing/coresight/coresight-etm-perf.c | 2 ++ > drivers/hwtracing/coresight/coresight-etm4x-core.c | 9 +++++++++ > include/linux/coresight-pmu.h | 2 ++ > 3 files changed, 13 insertions(+) > > diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c > index c039b6ae206f..43bbd5dc3d3b 100644 > --- a/drivers/hwtracing/coresight/coresight-etm-perf.c > +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c > @@ -52,6 +52,7 @@ static DEFINE_PER_CPU(struct coresight_device *, csdev_src); > * The PMU formats were orignally for ETMv3.5/PTM's ETMCR 'config'; > * now take them as general formats and apply on all ETMs. > */ > +PMU_FORMAT_ATTR(branch_broadcast, "config:"__stringify(ETM_OPT_BRANCH_BROADCAST)); > PMU_FORMAT_ATTR(cycacc, "config:" __stringify(ETM_OPT_CYCACC)); > /* contextid1 enables tracing CONTEXTIDR_EL1 for ETMv4 */ > PMU_FORMAT_ATTR(contextid1, "config:" __stringify(ETM_OPT_CTXTID)); > @@ -97,6 +98,7 @@ static struct attribute *etm_config_formats_attr[] = { > &format_attr_sinkid.attr, > &format_attr_preset.attr, > &format_attr_configid.attr, > + &format_attr_branch_broadcast.attr, > NULL, > }; > > diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c > index bf18128cf5de..d2bafb50c66a 100644 > --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c > +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c > @@ -692,6 +692,15 @@ static int etm4_parse_event_config(struct coresight_device *csdev, > ret = cscfg_csdev_enable_active_config(csdev, cfg_hash, preset); > } > > + /* branch broadcast - enable if selected and supported */ > + if (attr->config & BIT(ETM_OPT_BRANCH_BROADCAST)) { > + if (!drvdata->trcbb) { > + ret = -EINVAL; > + goto out; > + } else > + config->cfg |= BIT(ETM4_CFG_BIT_BB); nit: For consistent styling, I would recommend to wrap the else case also in { }. Otherwise looks good to me. Suzuki _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel