From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752436AbdI1SBX (ORCPT ); Thu, 28 Sep 2017 14:01:23 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:60704 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752067AbdI1SBV (ORCPT ); Thu, 28 Sep 2017 14:01:21 -0400 Date: Thu, 28 Sep 2017 19:01:35 +0100 From: Will Deacon To: Dave Martin Cc: mmarek@suse.cz, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] scripts/decodecode: Fix decoding for AArch64 (arm64) instructions Message-ID: <20170928180135.GH9892@arm.com> References: <1506596147-23630-1-git-send-email-will.deacon@arm.com> <20170928124206.GA3611@e103592.cambridge.arm.com> <20170928141447.GA27788@arm.com> <20170928143704.GC3611@e103592.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170928143704.GC3611@e103592.cambridge.arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 28, 2017 at 03:37:04PM +0100, Dave Martin wrote: > On Thu, Sep 28, 2017 at 03:14:47PM +0100, Will Deacon wrote: > > On Thu, Sep 28, 2017 at 01:42:31PM +0100, Dave Martin wrote: > > > On Thu, Sep 28, 2017 at 11:55:47AM +0100, Will Deacon wrote: > > > > There are a couple of problems with the decodecode script and arm64: > > > > > > > > 1. AArch64 objdump refuses to disassemble .4byte directives as instructions, > > > > insisting that they are data values and displaying them as: > > > > > > > > a94153f3 .word 0xa94153f3 <-- trapping instruction > > > > > > > > This is resolved by using the .inst directive instead. > > > > > > > > 2. Disassembly of branch instructions attempts to provide the target as > > > > an offset from a symbol, e.g.: > > > > > > > > 0: 34000082 cbz w2, 10 <.text+0x10> > > > > > > > > however this falls foul of the grep -v, which matches lines containing > > > > ".text" and ends up removing all branch instructions from the dump. > > > > > > Any idea why this doesn't affect other arches too ... or does it? > > > > I'm not sure, although I don't know how .inst works for architectures > > with variable-length instructions and I *guess* the disassembly is less > > fussy about data vs text for those targets. > > I rather meant the target disassembly for relative branches in the > absence of labels. > > Anyway, I think this is at least harmless to other arches, and possibly > helpful to them (if they disassemble those branch targets in the same > sort of way). Ah, I see what you mean. Something like the fixup below on top. Will --->8 diff --git a/scripts/decodecode b/scripts/decodecode index 67214ec5b2cb..f1ec57c3cbf7 100755 --- a/scripts/decodecode +++ b/scripts/decodecode @@ -49,21 +49,14 @@ esac disas() { ${CROSS_COMPILE}as $AFLAGS -o $1.o $1.s > /dev/null 2>&1 + ${CROSS_COMPILE}strip $1.o - if [ "$ARCH" = "arm" ]; then - if [ $width -eq 2 ]; then - OBJDUMPFLAGS="-M force-thumb" - fi - - ${CROSS_COMPILE}strip $1.o + if [ "$ARCH" = "arm" -a $width -eq 2 ]; then + OBJDUMPFLAGS="-M force-thumb" fi - if [ "$ARCH" = "arm64" ]; then - if [ $width -eq 4 ]; then - type=inst - fi - - ${CROSS_COMPILE}strip $1.o + if [ "$ARCH" = "arm64" -a $width -eq 4 ]; then + type=inst fi ${CROSS_COMPILE}objdump $OBJDUMPFLAGS -S $1.o | \ From mboxrd@z Thu Jan 1 00:00:00 1970 From: will.deacon@arm.com (Will Deacon) Date: Thu, 28 Sep 2017 19:01:35 +0100 Subject: [PATCH] scripts/decodecode: Fix decoding for AArch64 (arm64) instructions In-Reply-To: <20170928143704.GC3611@e103592.cambridge.arm.com> References: <1506596147-23630-1-git-send-email-will.deacon@arm.com> <20170928124206.GA3611@e103592.cambridge.arm.com> <20170928141447.GA27788@arm.com> <20170928143704.GC3611@e103592.cambridge.arm.com> Message-ID: <20170928180135.GH9892@arm.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Thu, Sep 28, 2017 at 03:37:04PM +0100, Dave Martin wrote: > On Thu, Sep 28, 2017 at 03:14:47PM +0100, Will Deacon wrote: > > On Thu, Sep 28, 2017 at 01:42:31PM +0100, Dave Martin wrote: > > > On Thu, Sep 28, 2017 at 11:55:47AM +0100, Will Deacon wrote: > > > > There are a couple of problems with the decodecode script and arm64: > > > > > > > > 1. AArch64 objdump refuses to disassemble .4byte directives as instructions, > > > > insisting that they are data values and displaying them as: > > > > > > > > a94153f3 .word 0xa94153f3 <-- trapping instruction > > > > > > > > This is resolved by using the .inst directive instead. > > > > > > > > 2. Disassembly of branch instructions attempts to provide the target as > > > > an offset from a symbol, e.g.: > > > > > > > > 0: 34000082 cbz w2, 10 <.text+0x10> > > > > > > > > however this falls foul of the grep -v, which matches lines containing > > > > ".text" and ends up removing all branch instructions from the dump. > > > > > > Any idea why this doesn't affect other arches too ... or does it? > > > > I'm not sure, although I don't know how .inst works for architectures > > with variable-length instructions and I *guess* the disassembly is less > > fussy about data vs text for those targets. > > I rather meant the target disassembly for relative branches in the > absence of labels. > > Anyway, I think this is at least harmless to other arches, and possibly > helpful to them (if they disassemble those branch targets in the same > sort of way). Ah, I see what you mean. Something like the fixup below on top. Will --->8 diff --git a/scripts/decodecode b/scripts/decodecode index 67214ec5b2cb..f1ec57c3cbf7 100755 --- a/scripts/decodecode +++ b/scripts/decodecode @@ -49,21 +49,14 @@ esac disas() { ${CROSS_COMPILE}as $AFLAGS -o $1.o $1.s > /dev/null 2>&1 + ${CROSS_COMPILE}strip $1.o - if [ "$ARCH" = "arm" ]; then - if [ $width -eq 2 ]; then - OBJDUMPFLAGS="-M force-thumb" - fi - - ${CROSS_COMPILE}strip $1.o + if [ "$ARCH" = "arm" -a $width -eq 2 ]; then + OBJDUMPFLAGS="-M force-thumb" fi - if [ "$ARCH" = "arm64" ]; then - if [ $width -eq 4 ]; then - type=inst - fi - - ${CROSS_COMPILE}strip $1.o + if [ "$ARCH" = "arm64" -a $width -eq 4 ]; then + type=inst fi ${CROSS_COMPILE}objdump $OBJDUMPFLAGS -S $1.o | \