Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3929452imm; Mon, 8 Oct 2018 11:51:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV62RrS1P+AHlQMk+nAD7xDRJLUglNL8b+4YmYMiLqKqxWw4EXEFFfQ9dUzAdaVTMVnRh/iBb X-Received: by 2002:a62:ce83:: with SMTP id y125-v6mr26429378pfg.201.1539024697655; Mon, 08 Oct 2018 11:51:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539024697; cv=none; d=google.com; s=arc-20160816; b=Dag27d1SPsGhwOdrthfxa9iOCXkkV16MHH/1984jZYOy5TLHFC7d26hW3H+NCFE5RD VxexuXvDPBRqiHgcrqQ30nH9yi58D5GBcFrLcDAGOCkjX2rStwUVkqkbUySZLR8iOcuR QrQlKYtdet6QglxGqt1aOmj3V2FoaSS85ZGSkmlQfICoYk9EAVPWdVXBWsnVGlsJz8N8 AV2XXOUHXIRGJE1A5jDb6ROW8bNZKj75Uq4uLi6PNt7FH8kfHhvVU7hsi1WHoHToQSYc 6kM5xk+wVWJMWJbDYLeDZqshPSCgYHcjmaOPoq+nCFO/7xNpsXrm3tTuRfivvbI9fnlt pnjw== 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=xgYsoU+x02s6MVBbCvVBzk7J+0cYSi/708xLnJpHVsg=; b=TAPOhHEQ10g4wGRtQxRvHY7lVoOCkP3S35NpeTEmoZgcHKm8+xT3JYlIjcBajfO/Ak iTt4cgB6lZxHnKHaIBLSUBVbKePjQXTlp2+bHxtih1Xi3xielO5Ojq2kLgiijbtkE/Cu uzDALgcXHGOZ8BO7cr6KGlXk6l6eHYeUAKE5+jDdClGXIOc5PGdW21ZgFIRJf3H1UonQ rlWaV6y6K43d+Gwsq7IdQSwzZryVxWghdqN+ltHYO05LwR1nHPLRQhXEdN97K7IJhX/d IMKl/nVcdbbRhlYbqpqT5ypK7u2FrtvjIHoTNTC+edB/S30oOxxanz3d9wHdot9f6xGO JXMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dA1T38bZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5-v6si12901820pgc.289.2018.10.08.11.51.22; Mon, 08 Oct 2018 11:51:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dA1T38bZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732280AbeJICEV (ORCPT + 99 others); Mon, 8 Oct 2018 22:04:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:54120 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726450AbeJICEU (ORCPT ); Mon, 8 Oct 2018 22:04:20 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (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 82BE320645; Mon, 8 Oct 2018 18:51:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024673; bh=8+XoG7WRQ8K8u85+0KMzElpvWlMjs1TM2F5r5SajLVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dA1T38bZLErbIaY5nNcLnK2+iwVtdEh/GaIqJxhkox3iT3BqFowMn29fmXY0rpbvF 6XLFLcu05bLl/WzpGexBlyHAK10JDX1pnOjJ7FgthQElKqdkgUK/iD8HkZCy1M3Tyu wdo6vgzCDaUQTgV70xtYgLJ0BpASo6DQGeEf+iDo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kim Phillips , Arnaldo Carvalho de Melo , Alexander Shishkin , Anton Blanchard , Christian Borntraeger , Jiri Olsa , Mark Rutland , Namhyung Kim , Peter Zijlstra , Ravi Bangoria , Robin Murphy , Taeung Song , linux-arm-kernel@lists.infradead.org, Sasha Levin Subject: [PATCH 4.18 093/168] perf annotate: Fix parsing aarch64 branch instructions after objdump update Date: Mon, 8 Oct 2018 20:31:13 +0200 Message-Id: <20181008175623.594562370@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175620.043587728@linuxfoundation.org> References: <20181008175620.043587728@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kim Phillips [ Upstream commit 4e67b2a5df5d3f341776d12ee575e00ca3ef92de ] Starting with binutils 2.28, aarch64 objdump adds comments to the disassembly output to show the alternative names of a condition code [1]. It is assumed that commas in objdump comments could occur in other arches now or in the future, so this fix is arch-independent. The fix could have been done with arm64 specific jump__parse and jump__scnprintf functions, but the jump__scnprintf instruction would have to have its comment character be a literal, since the scnprintf functions cannot receive a struct arch easily. This inconvenience also applies to the generic jump__scnprintf, which is why we add a raw_comment pointer to struct ins_operands, so the __parse function assigns it to be re-used by its corresponding __scnprintf function. Example differences in 'perf annotate --stdio2' output on an aarch64 perf.data file: BEFORE: → b.cs ffff200008133d1c // b.hs, dffff7ecc47b AFTER : ↓ b.cs 18c BEFORE: → b.cc ffff200008d8d9cc // b.lo, b.ul, dffff727295b AFTER : ↓ b.cc 31c The branch target labels 18c and 31c also now appear in the output: BEFORE: add x26, x29, #0x80 AFTER : 18c: add x26, x29, #0x80 BEFORE: add x21, x21, #0x8 AFTER : 31c: add x21, x21, #0x8 The Fixes: tag below is added so stable branches will get the update; it doesn't necessarily mean that commit was broken at the time, rather it didn't withstand the aarch64 objdump update. Tested no difference in output for sample x86_64, power arch perf.data files. [1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=bb7eff5206e4795ac79c177a80fe9f4630aaf730 Signed-off-by: Kim Phillips Tested-by: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: Anton Blanchard Cc: Christian Borntraeger Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Ravi Bangoria Cc: Robin Murphy Cc: Taeung Song Cc: linux-arm-kernel@lists.infradead.org Fixes: b13bbeee5ee6 ("perf annotate: Fix branch instruction with multiple operands") Link: http://lkml.kernel.org/r/20180827125340.a2f7e291901d17cea05daba4@arm.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/annotate.c | 22 +++++++++++++++++++++- tools/perf/util/annotate.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -281,7 +281,19 @@ bool ins__is_call(const struct ins *ins) return ins->ops == &call_ops || ins->ops == &s390_call_ops; } -static int jump__parse(struct arch *arch __maybe_unused, struct ins_operands *ops, struct map_symbol *ms) +/* + * Prevents from matching commas in the comment section, e.g.: + * ffff200008446e70: b.cs ffff2000084470f4 // b.hs, b.nlast + */ +static inline const char *validate_comma(const char *c, struct ins_operands *ops) +{ + if (ops->raw_comment && c > ops->raw_comment) + return NULL; + + return c; +} + +static int jump__parse(struct arch *arch, struct ins_operands *ops, struct map_symbol *ms) { struct map *map = ms->map; struct symbol *sym = ms->sym; @@ -290,6 +302,10 @@ static int jump__parse(struct arch *arch }; const char *c = strchr(ops->raw, ','); u64 start, end; + + ops->raw_comment = strchr(ops->raw, arch->objdump.comment_char); + c = validate_comma(c, ops); + /* * Examples of lines to parse for the _cpp_lex_token@@Base * function: @@ -309,6 +325,7 @@ static int jump__parse(struct arch *arch ops->target.addr = strtoull(c, NULL, 16); if (!ops->target.addr) { c = strchr(c, ','); + c = validate_comma(c, ops); if (c++ != NULL) ops->target.addr = strtoull(c, NULL, 16); } @@ -366,9 +383,12 @@ static int jump__scnprintf(struct ins *i return scnprintf(bf, size, "%-6s %s", ins->name, ops->target.sym->name); c = strchr(ops->raw, ','); + c = validate_comma(c, ops); + if (c != NULL) { const char *c2 = strchr(c + 1, ','); + c2 = validate_comma(c2, ops); /* check for 3-op insn */ if (c2 != NULL) c = c2; --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -21,6 +21,7 @@ struct ins { struct ins_operands { char *raw; + char *raw_comment; struct { char *raw; char *name;