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: 249362 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp4828696ilg; Tue, 8 Sep 2020 12:16:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykK5bv6LEtWfwv+QqpoLegtXSfHrHVREvpWA8cvQBhWs02OqSEGFoI6JGwgMjXgOk2LRrw X-Received: by 2002:a17:906:2b97:: with SMTP id m23mr28031523ejg.61.1599592615368; Tue, 08 Sep 2020 12:16:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599592615; cv=none; d=google.com; s=arc-20160816; b=0bBj5Mdn/shuLwQQvz0L09hyTUepgKfFJ5+mcrUpHyuYY4jZBEIKctihZq2XOQ8h7E VVOSp/Std6eJ/i03G4yBxiKs5SUcbFSh7v5Y6lN64QiDPfBhmqJA0pugZYIOakObT9rP 1QhY3I2Tix0aNjAHhO6bzQRXDm5U3eJaGI9D8+yLpQARQzFDk8YkhAteMAQCfCDTjFCN OFwANp+NS84boBJ5W6JZ2q6JTrNc3GxxcjIMmgCpDzwNE7xiwC2vegZieXhbxI7MI4H8 e5VR/pZHBZNKJOUP3c8xoYGhxV5D36zZygdwt5Uby1D3POdYlcVOL4VzJ8gRJimRFU8F 25ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QQeO1/lxZ0LI5Vi6anIHPDGrOW2BOjtHI9uLZQ4i8XE=; b=iJMRg1L06DMladgA/csAEwoY0G9dwwg7MKNLqtNDE2kiU5+TLW3AmI5U/s5+0qwM1Q 4H/y+dw8+SYKnQzfso1MEtYa9BOQFqWvskdVCaM06O4CJkGhuV8DohsMFV1k4JlZ7nh0 etZ7ll4wke4sj3cPHBeH5RgapBRjpnz+vyp29T5QxpnTz922IeuEP1vKmZBIBbn5QcLb icErDaMy/fSe6DTqfB5QRx29VoCW5Qb2v1HDRwfm8dfLsva7qUCTRiKiED3IPAhKSFBR //F8LMpUoba30HSTQJofKO6WIUodMHUbaf0x9SyuACjH4Gm2cgbvIECxHU0TDvGJQKDP hkpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zCSDJ+5e; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j10si24572edy.0.2020.09.08.12.16.55; Tue, 08 Sep 2020 12:16:55 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zCSDJ+5e; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731695AbgIHTQv (ORCPT + 15 others); Tue, 8 Sep 2020 15:16:51 -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 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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(-) -- 2.25.1 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;