All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@armlinux.org.uk>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Will Deacon <will.deacon@arm.com>,
	linux-arm-kernel@lists.infradead.org, lkml@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] arm: ensure symbol is a thumb symbol in new binutils
Date: Tue, 21 Nov 2017 17:49:42 +0000	[thread overview]
Message-ID: <20171121174942.GK31757@n2100.armlinux.org.uk> (raw)
In-Reply-To: <CAHmME9quDFbdOR9hKRz-Px=Mh3FvYEyhVrs4V_+JT+GjDajMrA@mail.gmail.com>

On Tue, Nov 21, 2017 at 06:46:25PM +0100, Jason A. Donenfeld wrote:
> Hi Russell,
> 
> On Tue, Nov 21, 2017 at 6:38 PM, Russell King - ARM Linux
> <linux@armlinux.org.uk> wrote:
> > +toolcheck:
> > +       @$(CONFIG_SHELL) '$(srctree)/$(src)/toolcheck'
> 
> Perhaps faster to put the check for THUMB2_KERNEL around the make
> target, instead of doing it in the code?

Could do, I was debating about extending this for the buggy linker
problem too from a few weeks ago.

> > +if grep -q 'CONFIG_THUMB2_KERNEL=y' .config; then
> 
> See above.
> 
> > +   tmp=$(mktemp -d /tmp/binutils-test.XXXXXXXXXX)
> > +   cat <<EOF | $AS $ASFLAGS -o $tmp/test.o
> > +       .syntax unified
> > +       .thumb
> > +       .macro  badr, reg, sym
> > +       adr     \reg, \sym + 1
> > +       .endm
> > +
> > +test:
> > +       mov     r0, #0
> > +       badr    lr, test
> > +EOF
> > +   if ! $OBJDUMP -d $tmp/test.o | grep -q '4:\s*f2af 0e07'; then
> > +      echo "Error: your assembler version produces buggy kernels" >&2
> > +      $AS --version | head -n1 >&2
> > +      rm $tmp/*.o
> > +      rmdir $tmp
> > +      exit 1
> > +   fi
> > +   rm $tmp/*.o
> > +   rmdir $tmp
> > +fi
> 
> This doesn't actually catch the issues. In the buggy binutils, it
> appears that sometimes adr grabs the right symbol and sometimes it
> doesn't. I'm not yet able to figure out a minimal condition for it
> going one way or the other.

What if we locate the "badr" instruction to the same offset - does
that trigger the binutils bug?  Note that the grep expression will
need updating...

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up

WARNING: multiple messages have this Message-ID (diff)
From: linux@armlinux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm: ensure symbol is a thumb symbol in new binutils
Date: Tue, 21 Nov 2017 17:49:42 +0000	[thread overview]
Message-ID: <20171121174942.GK31757@n2100.armlinux.org.uk> (raw)
In-Reply-To: <CAHmME9quDFbdOR9hKRz-Px=Mh3FvYEyhVrs4V_+JT+GjDajMrA@mail.gmail.com>

On Tue, Nov 21, 2017 at 06:46:25PM +0100, Jason A. Donenfeld wrote:
> Hi Russell,
> 
> On Tue, Nov 21, 2017 at 6:38 PM, Russell King - ARM Linux
> <linux@armlinux.org.uk> wrote:
> > +toolcheck:
> > +       @$(CONFIG_SHELL) '$(srctree)/$(src)/toolcheck'
> 
> Perhaps faster to put the check for THUMB2_KERNEL around the make
> target, instead of doing it in the code?

Could do, I was debating about extending this for the buggy linker
problem too from a few weeks ago.

> > +if grep -q 'CONFIG_THUMB2_KERNEL=y' .config; then
> 
> See above.
> 
> > +   tmp=$(mktemp -d /tmp/binutils-test.XXXXXXXXXX)
> > +   cat <<EOF | $AS $ASFLAGS -o $tmp/test.o
> > +       .syntax unified
> > +       .thumb
> > +       .macro  badr, reg, sym
> > +       adr     \reg, \sym + 1
> > +       .endm
> > +
> > +test:
> > +       mov     r0, #0
> > +       badr    lr, test
> > +EOF
> > +   if ! $OBJDUMP -d $tmp/test.o | grep -q '4:\s*f2af 0e07'; then
> > +      echo "Error: your assembler version produces buggy kernels" >&2
> > +      $AS --version | head -n1 >&2
> > +      rm $tmp/*.o
> > +      rmdir $tmp
> > +      exit 1
> > +   fi
> > +   rm $tmp/*.o
> > +   rmdir $tmp
> > +fi
> 
> This doesn't actually catch the issues. In the buggy binutils, it
> appears that sometimes adr grabs the right symbol and sometimes it
> doesn't. I'm not yet able to figure out a minimal condition for it
> going one way or the other.

What if we locate the "badr" instruction to the same offset - does
that trigger the binutils bug?  Note that the grep expression will
need updating...

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up

  reply	other threads:[~2017-11-21 17:49 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-21 17:27 [PATCH] arm: ensure symbol is a thumb symbol in new binutils Jason A. Donenfeld
2017-11-21 17:27 ` Jason A. Donenfeld
2017-11-21 17:38 ` Russell King - ARM Linux
2017-11-21 17:38   ` Russell King - ARM Linux
2017-11-21 17:46   ` Jason A. Donenfeld
2017-11-21 17:46     ` Jason A. Donenfeld
2017-11-21 17:49     ` Russell King - ARM Linux [this message]
2017-11-21 17:49       ` Russell King - ARM Linux
2017-11-22 23:34       ` Jason A. Donenfeld
2017-11-22 23:34         ` Jason A. Donenfeld
2017-11-23 10:35         ` Russell King - ARM Linux
2017-11-23 10:35           ` Russell King - ARM Linux
2017-11-23 10:47           ` Fwd: " Jason A. Donenfeld
2017-11-23 10:47             ` Jason A. Donenfeld
2017-11-23 11:48             ` [PATCH] arm: detect buggy binutils when in thumb2 mode Jason A. Donenfeld
2017-11-23 11:48               ` Jason A. Donenfeld
2017-11-23 11:50               ` [PATCH v2] " Jason A. Donenfeld
2017-11-23 11:50                 ` Jason A. Donenfeld
2017-11-23 12:01                 ` Martin Storsjö
2017-11-23 12:01                   ` Martin Storsjö
2017-11-23 14:02             ` Fwd: [PATCH] arm: ensure symbol is a thumb symbol in new binutils Russell King - ARM Linux
2017-11-23 14:02               ` Russell King - ARM Linux
2017-11-23 14:26               ` Ard Biesheuvel
2017-11-23 14:26                 ` Ard Biesheuvel
2017-11-23 14:26                 ` Ard Biesheuvel
     [not found]                 ` <765227b5-981d-0cea-c831-73cfe2f58721@redhat.com>
     [not found]                   ` <aaf57bb5-13e6-852c-0f67-f72aedef0e79@gmail.com>
     [not found]                     ` <254af731-459b-1f1d-2d93-27c5a91e7bfb@redhat.com>
2018-05-31 21:16                       ` [Buildroot] " Romain Naour
2018-06-01  8:28                         ` Christophe PRIOUZEAU
     [not found]                           ` <2a8151c1-644e-a6b0-9a21-2c570ac7000b@redhat.com>
2018-06-05  8:52                             ` Christophe PRIOUZEAU
     [not found]                               ` <ec2b0134-6c4a-53ff-4ae2-69c3f0646ded@redhat.com>
2018-06-05 14:11                                 ` Christophe PRIOUZEAU
     [not found]                                   ` <1d8f302b-5ece-9921-b930-8c4bca61743e@redhat.com>
2018-06-11 14:47                                     ` Christophe PRIOUZEAU
     [not found]                                   ` <1d8f302b-5ece-9921-b930-8c4bca61743e@redhat. com>
     [not found]                                     ` <CAJA7tRbsNa7oTS-1sLs0WpA74RZr0R-v=sCyQxbDam5Gb7fYHA@mail.gmail.com>
     [not found]                                       ` <be2db8d4-7c12-2706-5084-322aa659c3bc@redhat.com>
2018-06-18 15:04                                         ` Christophe PRIOUZEAU
2018-06-18 18:29                                           ` Romain Naour
     [not found]                                             ` <062a421f-a669-fc1c-91e0-88cf73794414@redhat.com>
2018-06-19 12:27                                               ` Christophe PRIOUZEAU
2018-01-16  8:43 ` Chen-Yu Tsai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171121174942.GK31757@n2100.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=Jason@zx2c4.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=lkml@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.