From patchwork Tue Sep 8 15:23:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 11763583 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6467059D for ; Tue, 8 Sep 2020 16:31:43 +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 2BF3520708 for ; Tue, 8 Sep 2020 16:31:43 +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 2BF3520708 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+patchwork-linux-arm=patchwork.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-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [198.145.29.99 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.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;