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 X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF9DEC433E2 for ; Tue, 8 Sep 2020 16:31:42 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9574D20757 for ; Tue, 8 Sep 2020 16:31:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="TjhTtQMc"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="zCSDJ+5e" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9574D20757 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=agexTCiY5OADkQprfb4jZMia12ciSGiRqdNlyGpC/Vg=; b=TjhTtQMc7RwwGA8JwCjX4jDfB p8O4/fqEMxuqPyp5JDfVSkz1QtkhH+wqpvQjxazLzNeLcWX9AfnwRbGmA9tomdU67RAREbeNDVQzO 2SuKekZA7kxILZSlHspcK6++8T8++fknbPQlavYGfaLsegQnzo2GUPfuVvFj6QUFWhjKxkS6FvrE5 6K4QCn3LfSHIvqK/p194lhSKAnPQrbfGzpP82os304UshPC0+X1vU5CI8nLalt2Jbsmo013s1CyQZ jpCWhVXFx2fKZh+iF7ER6uvhHI8YyPwJJBnW7IsLV6Jg+LzxzhgU1it0kJbaMnFMAWP3wQU4wHvQr r5MAlQC8g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFfoS-0007XB-81; Tue, 08 Sep 2020 15:45:40 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFfoK-0007SQ-4p for linux-arm-kernel@lists.infradead.org; Tue, 08 Sep 2020 15:45:33 +0000 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 80E5D23E51; Tue, 8 Sep 2020 15:37:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599579471; bh=GEs1BKnoPh7fQfVizAtRTSwMUcpvmSDLQbdXLXIp+f0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zCSDJ+5eqTDZn6aqqpuLaEHcI1N+E60Zsuba070aT0whNzGPMlMHyC/jgW4Kg+YHc xH9tFbBHPcBrBS58btIRYykw7EFDljED/0bMcA5Bd6ACvSWRR8zcxJAGQM+vF6Uip4 d7Zph5WadaqFZDqc1XLr+Xya5jVhAsuaPGh5xPNI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Subject: [PATCH 5.8 092/186] perf cs-etm: Fix corrupt data after perf inject from Date: Tue, 8 Sep 2020 17:23:54 +0200 Message-Id: <20200908152246.099614619@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908152241.646390211@linuxfoundation.org> References: <20200908152241.646390211@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200908_114532_336567_942329F0 X-CRM114-Status: GOOD ( 17.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Sasha Levin , Andi Kleen , Al Grant , Mathieu Poirier , Suzuki Poulouse , Alexander Shishkin , Greg Kroah-Hartman , Adrian Hunter , stable@vger.kernel.org, Andrea Brunato , Arnaldo Carvalho de Melo , Peter Zijlstra , Leo Yan , Namhyung Kim , Mike Leach , Jiri Olsa , linux-arm-kernel@lists.infradead.org, Kan Liang 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 From: Al Grant [ Upstream commit f5f8e7e55fbdb4fdddec73518e23c48083108fbb ] Commit 42bbabed09ce6208 ("perf tools: Add hw_idx in struct branch_stack") changed the format of branch stacks in perf samples. When samples use this new format, a flag must be set in the corresponding event. Synthesized branch stacks generated from CoreSight ETM trace were using the new format, but not setting the event attribute, leading to consumers seeing corrupt data. This patch fixes the issue by setting the event attribute to indicate use of the new format. Fixes: 42bbabed09ce6208 ("perf tools: Add hw_idx in struct branch_stack") Signed-off-by: Al Grant Reviewed-by: Andrea Brunato Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jiri Olsa Cc: Kan Liang Cc: Mark Rutland Cc: Mathieu Poirier Cc: Mike Leach Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Suzuki Poulouse Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Leo Yan Link: http://lore.kernel.org/lkml/20200819084751.17686-1-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/cs-etm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index c283223fb31f2..a2a369e2fbb67 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1344,8 +1344,15 @@ static int cs_etm__synth_events(struct cs_etm_auxtrace *etm, attr.sample_type &= ~(u64)PERF_SAMPLE_ADDR; } - if (etm->synth_opts.last_branch) + if (etm->synth_opts.last_branch) { attr.sample_type |= PERF_SAMPLE_BRANCH_STACK; + /* + * We don't use the hardware index, but the sample generation + * code uses the new format branch_stack with this field, + * so the event attributes must indicate that it's present. + */ + attr.branch_sample_type |= PERF_SAMPLE_BRANCH_HW_INDEX; + } if (etm->synth_opts.instructions) { attr.config = PERF_COUNT_HW_INSTRUCTIONS; -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFDDFC43461 for ; Tue, 8 Sep 2020 19:17:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7531D2087D for ; Tue, 8 Sep 2020 19:17:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599592639; bh=GEs1BKnoPh7fQfVizAtRTSwMUcpvmSDLQbdXLXIp+f0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=GZqzml//4QuDzVvOt+jGgsjClbFZE5FAILTlfLOBJqMVkjk5QB8FYg1qHgH9ldi5l Na98x1tJHynE44unc0s8bKUfXnXMU8nsF+JxcsIFOjVHUOtM/EnUciwVadlebGaqAC BKJ+OIvVwz/LgQ5m5tzRYWLmp32rMY8XzxbIkNdM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731983AbgIHTRR (ORCPT ); Tue, 8 Sep 2020 15:17:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:52606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730586AbgIHQDh (ORCPT ); Tue, 8 Sep 2020 12:03:37 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 80E5D23E51; Tue, 8 Sep 2020 15:37:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599579471; bh=GEs1BKnoPh7fQfVizAtRTSwMUcpvmSDLQbdXLXIp+f0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zCSDJ+5eqTDZn6aqqpuLaEHcI1N+E60Zsuba070aT0whNzGPMlMHyC/jgW4Kg+YHc xH9tFbBHPcBrBS58btIRYykw7EFDljED/0bMcA5Bd6ACvSWRR8zcxJAGQM+vF6Uip4 d7Zph5WadaqFZDqc1XLr+Xya5jVhAsuaPGh5xPNI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Grant , Andrea Brunato , Adrian Hunter , Alexander Shishkin , Andi Kleen , Jiri Olsa , Kan Liang , Mark Rutland , Mathieu Poirier , Mike Leach , Namhyung Kim , Peter Zijlstra , Suzuki Poulouse , linux-arm-kernel@lists.infradead.org, Leo Yan , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.8 092/186] perf cs-etm: Fix corrupt data after perf inject from Date: Tue, 8 Sep 2020 17:23:54 +0200 Message-Id: <20200908152246.099614619@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908152241.646390211@linuxfoundation.org> References: <20200908152241.646390211@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Grant [ Upstream commit f5f8e7e55fbdb4fdddec73518e23c48083108fbb ] Commit 42bbabed09ce6208 ("perf tools: Add hw_idx in struct branch_stack") changed the format of branch stacks in perf samples. When samples use this new format, a flag must be set in the corresponding event. Synthesized branch stacks generated from CoreSight ETM trace were using the new format, but not setting the event attribute, leading to consumers seeing corrupt data. This patch fixes the issue by setting the event attribute to indicate use of the new format. Fixes: 42bbabed09ce6208 ("perf tools: Add hw_idx in struct branch_stack") Signed-off-by: Al Grant Reviewed-by: Andrea Brunato Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jiri Olsa Cc: Kan Liang Cc: Mark Rutland Cc: Mathieu Poirier Cc: Mike Leach Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Suzuki Poulouse Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Leo Yan Link: http://lore.kernel.org/lkml/20200819084751.17686-1-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/cs-etm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index c283223fb31f2..a2a369e2fbb67 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1344,8 +1344,15 @@ static int cs_etm__synth_events(struct cs_etm_auxtrace *etm, attr.sample_type &= ~(u64)PERF_SAMPLE_ADDR; } - if (etm->synth_opts.last_branch) + if (etm->synth_opts.last_branch) { attr.sample_type |= PERF_SAMPLE_BRANCH_STACK; + /* + * We don't use the hardware index, but the sample generation + * code uses the new format branch_stack with this field, + * so the event attributes must indicate that it's present. + */ + attr.branch_sample_type |= PERF_SAMPLE_BRANCH_HW_INDEX; + } if (etm->synth_opts.instructions) { attr.config = PERF_COUNT_HW_INSTRUCTIONS; -- 2.25.1