From patchwork Mon Oct 1 00:38:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 10621573 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C6FF41750 for ; Mon, 1 Oct 2018 00:38:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACAD128FD4 for ; Mon, 1 Oct 2018 00:38:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9EBCE28FDC; Mon, 1 Oct 2018 00:38:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DE8F728FD4 for ; Mon, 1 Oct 2018 00:38:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-ID:In-Reply-To: References:Message-ID:Date:Subject:To:From:Reply-To:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CkDlaC6BV0TPaj8xA/HJemoCg5d463nRIUFEr64yWUc=; b=TB314LCGhheo51 y633zeazCxqVatI+CAcYwwgj0uD2kdYuwmFJwDsF62MDNYkU/EEitYa3/5EiNkDDDS2V2kq8cdHho JJoxNK1ARPlofq51ZfZaYD5Bxw/BqmAIwH6goDLfp3qq7ohbk6Q5+pGB1kAyAPjQFCItvsOEj2L2d 57ytluPC90kKCsXNnn0bUjXqTFnkOB+gnFHc1BasCC9GAw86RZDzqEVx8dnU7tAPOd0K4j3T4oF5T rYNH4kt7mQW4jZCA2glZ2QmCzBieOBWIWem1RZyoAs9a1n30RWMtVc+suJSMXSZ8KTaeL/3DSSH7s JF41A0z+NlyX2RF1JR/Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g6mEM-0006X4-Ay; Mon, 01 Oct 2018 00:38:34 +0000 Received: from mail-dm3nam03on0101.outbound.protection.outlook.com ([104.47.41.101] helo=NAM03-DM3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g6mEG-0006Sq-Mh for linux-arm-kernel@lists.infradead.org; Mon, 01 Oct 2018 00:38:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tddSRu6W9vi9olzMZXzR64Yl1Wa6uI+xIjrmwDnbo74=; b=bvnvdHqujuXrQIDTP6QCYsteguUOJx2TO2BfZd8r0BxAESQzwJh9g/t2NtGaplxgaXiw+wr8ffD8TP8WbPelONMJeWSGEorMvNRpx8Jv3HROWsR6/02WRbIVGLbXHUoTkQ2nt7VserYqSH2rZ2gyQaAffw3ZKJrmgnp8N/5l1E4= Received: from CY4PR21MB0776.namprd21.prod.outlook.com (10.173.192.22) by CY4PR21MB0472.namprd21.prod.outlook.com (10.172.121.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.3; Mon, 1 Oct 2018 00:38:12 +0000 Received: from CY4PR21MB0776.namprd21.prod.outlook.com ([fe80::54e2:88e0:b622:b36]) by CY4PR21MB0776.namprd21.prod.outlook.com ([fe80::54e2:88e0:b622:b36%5]) with mapi id 15.20.1228.006; Mon, 1 Oct 2018 00:38:12 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH AUTOSEL 4.18 15/65] perf annotate: Fix parsing aarch64 branch instructions after objdump update Thread-Topic: [PATCH AUTOSEL 4.18 15/65] perf annotate: Fix parsing aarch64 branch instructions after objdump update Thread-Index: AQHUWR8Ia9ls3+GfI0O5urZ9Z6/p+g== Date: Mon, 1 Oct 2018 00:38:12 +0000 Message-ID: <20181001003754.146961-15-alexander.levin@microsoft.com> References: <20181001003754.146961-1-alexander.levin@microsoft.com> In-Reply-To: <20181001003754.146961-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; CY4PR21MB0472; 6:t7NdXW7w8Sm/Bc35hl6DAd5dqAv0it64T/7IoTrml9ALMfmRZFy8y5jJtR/BY0+8NyjgvrTkUv/UJ3klCYQmjQnjrluxV5OOFIATpv48R6CqBfUHsdYoEpMFZgfUIjx2sSqoR/80tEbX6Up4d2I4/04fyxWh2fVZK9RhCwxmjNPO2AbLNUYlY663OLlu+G40oZiQfqRsKle1yARtTtUXckFYJwbWxINKofIo3/2DBjM7nZ7uW7ayJO1GD4qNAO94PthZK3E77Hc434F/8mVprzQnG2eJnBPv04EHPZCEgdpcqIna76s8HUKC5A+RoWL7p5/KzbKtG3mpamUEKk9gbWhVjnOKLkXZfMZxHt0RyKtlv7/QSKg04/E4aaVk4yDvWD/xYAmi1ygBB+FJigT8LmBpuItMtDIUPzJYlo9KREqy4e9d7CVJ9x6t/0k2gpBdnQ/45TKjI7Ri8X2YZvS0PQ==; 5:o+riqGIEJ0+dzw7eN4q5mmYnd6TsjzPcyIUa3v6VFAGYgrPFFjQau+WoFinljmqz0uOZgIvxjaHT/jjm19erc+X4k7IguGvucQvmZkrnwzlySChEi1QVC/YlEFzcotijUnWQpTewOB1Szcwm3OcR67968sYO6NWTrv1qU0Cm0MY=; 7:JU931JRjlVerfCKGxiDdU17UIifQhdGuKxuBEzq8NA9GhQk3sp1mGZN15uKYVP3VphEWzIU5hjlnzHafWVYxhG9l+VZWYmOXtoNOPMr14oJd7lrXTfp/qegCFmob8wCvcc5UiPz6Zd6NuJ91TXXZtwxHYHKm9tqihjBXBNYdNRmf50n7+dq9xivw9qoGYrgpwPYriowu6/jFHctlIJMOgZLY76FbWXsbu+mdiSpaap1fM4OFfKB79Jcz74SL5qJ8 x-ms-office365-filtering-correlation-id: 4eaa3ffa-20ea-4ffe-a33b-08d627362b21 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7193020); SRVR:CY4PR21MB0472; x-ms-traffictypediagnostic: CY4PR21MB0472: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(258649278758335)(42068640409301)(180628864354917)(228905959029699)(190383065149520)(104084551191319)(85827821059158)(28532068793085)(89211679590171); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231355)(944501410)(4982022)(52105095)(2018427008)(3002001)(6055026)(149066)(150057)(6041310)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(201708071742011)(7699051)(76991041); SRVR:CY4PR21MB0472; BCL:0; PCL:0; RULEID:; SRVR:CY4PR21MB0472; x-forefront-prvs: 0812095267 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(366004)(396003)(376002)(39860400002)(346002)(199004)(189003)(5660300001)(966005)(6486002)(6306002)(8936002)(68736007)(486006)(6436002)(10710500007)(2616005)(6506007)(6346003)(8676002)(6512007)(81166006)(81156014)(5250100002)(6116002)(2906002)(3846002)(107886003)(2501003)(39060400002)(1076002)(22452003)(478600001)(102836004)(25786009)(4326008)(97736004)(10090500001)(11346002)(256004)(14444005)(106356001)(105586002)(99286004)(86362001)(575784001)(53936002)(316002)(71200400001)(71190400001)(305945005)(7416002)(15650500001)(2420400007)(2900100001)(217873002)(7736002)(10290500003)(14454004)(34290500001)(446003)(66066001)(72206003)(110136005)(54906003)(7110500001)(186003)(86612001)(476003)(76176011)(26005)(36756003); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR21MB0472; H:CY4PR21MB0776.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: 5/KqA88tPZXJhFhmvmeZI7MdkQSAV3uQHrAtYdmV6W4bVGkZH/8R3nytyd03MlrqCE03sqz0RLDYzcO6KT9E+yHemdBxANAGoD8806Z4jsr1ynJbumRUYG8v2Aalp9nrNkbKz8o5oIeId4/LNV3fgct+rrK2wkQHGGQBd+6O01Anx5OOSvOQ3wO7XAzd4oI2XFPD8Csb+IRJJwKttJj31PDDdMxmutArt0rMnBkLhUou3uL/wk92skHIWGrPe6CDVh166rp+sRZlsbbAIwJA2vP6LYa0gRxy98zTi94bi6lpf3Md8xm+21GsmnCQI3ZbaxbC/gecH3v95xUDMe81unwO48ssVSetXiGg/3eKgS0= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: <2865C2D9722F4245989B077EE646A6BD@namprd21.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4eaa3ffa-20ea-4ffe-a33b-08d627362b21 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Oct 2018 00:38:12.3374 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR21MB0472 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180930_173828_792769_315C4415 X-CRM114-Status: GOOD ( 18.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Sasha Levin , Kim Phillips , Alexander Shishkin , Robin Murphy , Ravi Bangoria , Arnaldo Carvalho de Melo , Christian Borntraeger , Peter Zijlstra , Anton Blanchard , Namhyung Kim , Jiri Olsa , "linux-arm-kernel@lists.infradead.org" , Taeung Song Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- tools/perf/util/annotate.c | 22 +++++++++++++++++++++- tools/perf/util/annotate.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 31a1e18c7bf2..3b05219c3ed7 100644 --- 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 __maybe_unused, struct ins_operands *op }; 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 __maybe_unused, struct ins_operands *op 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 *ins, char *bf, size_t size, 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; diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index a4c0d91907e6..61e0c7fd5efd 100644 --- 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;