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 E9279C2BC11 for ; Tue, 8 Sep 2020 19:24:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ADD292076C for ; Tue, 8 Sep 2020 19:24:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599593074; bh=3ahDVtPdEadssd8Vxb18CRDen5htLpWbWq5DrbGDtUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=w7/QjVCL7L+SbUMRAY1lp+Gp6S/tt5VbzWe0cypMxSJj/VcMQbW5nQy7cHhXc/3K8 AxCII09jU9iOwVEGrbiKnsspALHTX113E6YtQig1lLtMisDkIdJzEjdwo5GdUISICC Z7srhcrlDNVmeMXAW5+mioJBr/dFsBLCsHHMCSKg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730976AbgIHTXo (ORCPT ); Tue, 8 Sep 2020 15:23:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:48732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731096AbgIHQBY (ORCPT ); Tue, 8 Sep 2020 12:01:24 -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 04DA423EAF; Tue, 8 Sep 2020 15:37:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599579473; bh=3ahDVtPdEadssd8Vxb18CRDen5htLpWbWq5DrbGDtUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MMsLE2Q0RC7Fn506i55HCvjukvjWUwyw5gCRcVc10uoVO7xjWglbWs2wzbbWtoFTx EYVbFti24aXsst6HBdaj2R+TwQl5NKsEPwJbsKTJbr+wIl/rfbMmqHaJqCzHCYmrXK KOXelm4fjAl8z4HJZz7s69fVZOtjQuM6JyDsYci0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Grant , Adrian Hunter , Mathieu Poirier , Alexander Shishkin , Andi Kleen , Jiri Olsa , Kan Liang , Leo Yan , Mark Rutland , Mike Leach , Namhyung Kim , Peter Zijlstra , Suzuki Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.8 093/186] perf intel-pt: Fix corrupt data after perf inject from Date: Tue, 8 Sep 2020 17:23:55 +0200 Message-Id: <20200908152246.140021403@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: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Al Grant [ Upstream commit a347306fbec5dcaf7c276777b11d530eab6a4526 ] 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 Intel PT 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 Acked-by: Adrian Hunter Reviewed-by: Mathieu Poirier Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jiri Olsa Cc: Kan Liang Cc: Leo Yan Cc: Mark Rutland Cc: Mike Leach Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Suzuki Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lore.kernel.org/lkml/20200819084751.17686-2-leo.yan@linaro.org Signed-off-by: Leo Yan Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/intel-pt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index cb3c1e569a2db..9357b5f62c273 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -2913,8 +2913,15 @@ static int intel_pt_synth_events(struct intel_pt *pt, if (pt->synth_opts.callchain) attr.sample_type |= PERF_SAMPLE_CALLCHAIN; - if (pt->synth_opts.last_branch) + if (pt->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 (pt->synth_opts.instructions) { attr.config = PERF_COUNT_HW_INSTRUCTIONS; -- 2.25.1