linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Russell King - ARM Linux <linux@armlinux.org.uk>
Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Romain Izard <romain.izard.pro@gmail.com>,
	Sven Schmidt <4sschmid@informatik.uni-hamburg.de>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Petr Cvek <petrcvekcz@gmail.com>,
	Aaro Koskinen <aaro.koskinen@iki.fi>,
	Andrea Adami <andrea.adami@gmail.com>,
	Robert Jarzmik <robert.jarzmik@free.fr>
Subject: Re: [PATCH] ARM: add a private asm/unaligned.h
Date: Mon, 30 Oct 2017 18:01:44 +0100	[thread overview]
Message-ID: <CAK8P3a37pQZPzLbh_qCtDqz0=Ends+nnV3-Y1KJKZVxiRErFfQ@mail.gmail.com> (raw)
In-Reply-To: <20171030155029.GP20805@n2100.armlinux.org.uk>

On Mon, Oct 30, 2017 at 4:50 PM, Russell King - ARM Linux
<linux@armlinux.org.uk> wrote:
> On Mon, Oct 30, 2017 at 04:09:43PM +0100, Arnd Bergmann wrote:
>> On Fri, Oct 27, 2017 at 5:27 PM, Russell King - ARM Linux
>> <linux@armlinux.org.uk> wrote:
>>
>> >
>> > There's three things wrong, all of which I have patches to address:
>> >
>> > 1. The decompressor code reading the image data sometimes issues unaligned
>> >    reads.  Some compilers get this wrong and cause an abort.  Arnds patch
>> >    addresses this.
>> >
>> > 2. Additional sections can appear in the zImage binary which adds extra
>> >    bytes on the end of the image.  Concatenating the zImage with the
>> >    extra bytes onto a DTB is the same thing as doing this:
>> >
>> >         cat zImage extrabytes foo.dtb > image
>> >
>> >    and the decompressor tolerates no additional bytes between the
>> >    _official_ end of the zImage and the DTB.  I've added a patch which
>> >    detects this situation and fails the kernel build when it happens.
>> >
>> > 3. Ard's patch "efi/libstub: arm: omit sorting of the UEFI memory map"
>> >    gets rid of the additional sections that (a) change the alignment
>> >    of the compressed data, and (b) add additional unexpected bytes on
>> >    the end of zImage.
>>
>> It's possible that we still need yet another patch to address the gcc bug that
>> Alex Graf found, i.e. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82445
>>
>> Without the latest gcc, we might still get into a situation in which we get
>> an unaligned strd when compiling for armv5te or armv6 with gcc-7.[012].
>> As someone mentioned in the bug report, that problem doesn't seem
>> to happen with gcc-6 or -mtune=xscale, or with gcc-7 -march=armv7-a.
>
> There is another solution which we've used in the past - we could detect
> these compiler versions and refuse to build with the broken compilers.

Right, either fail the build or use the workaround from the gcc bugzilla,
passing -fno-store-merging to the broken compilers avoids the problem
reliably at the cost of slightly worse code. For the decompressor, we might
also get away with passing -march=armv5t (not armv5te), which has
experimentally been found to avoid the problem and produce better code
than "-march=armv6 -fno-store-merging" as it avoids the strd instruction
but not other store merging.

For normal kernel access (after the decompressor), relying on the fixup
in the kernel is probably good enough, we already have problems with
a couple of functiosn that check for
CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS before doing
accesses that can result in ldm/stm on any compiler.

I'm still trying to figure out exactly what architectures and gcc versions
are affected, the gcc-6 branch contains a fix for the problem but I
have not been able to reproduce it on that version or earlier. However,
I have now reproduced an strd with gcc-7.1 on this code on all
architectures that support strd, with this test case from the gcc testsuite:

void foo(int a, int b, int* p)
{
  p[1] = a;
  p[2] = b;
}

       Arnd

  reply	other threads:[~2017-10-30 17:01 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-20 20:01 [PATCH] ARM: add a private asm/unaligned.h Arnd Bergmann
2017-10-20 20:22 ` Ard Biesheuvel
2017-10-23 15:04 ` Romain Izard
2017-10-27 15:19 ` Gregory CLEMENT
2017-10-27 15:27   ` Russell King - ARM Linux
2017-10-30 13:48     ` Gregory CLEMENT
2017-10-30 14:55       ` Ard Biesheuvel
2017-10-30 15:05         ` Gregory CLEMENT
2017-10-30 15:07           ` Ard Biesheuvel
2017-10-30 15:09             ` Gregory CLEMENT
2017-10-30 15:20               ` Ard Biesheuvel
2017-10-30 15:33                 ` Gregory CLEMENT
2017-10-30 15:35                   ` Ard Biesheuvel
2017-10-30 15:40                     ` Gregory CLEMENT
2017-10-30 16:59                     ` Russell King - ARM Linux
2017-10-30 15:55                   ` Russell King - ARM Linux
2017-10-30 16:04                     ` Gregory CLEMENT
2017-10-30 15:48       ` Russell King - ARM Linux
2017-10-30 16:01         ` Gregory CLEMENT
2017-10-30 16:12           ` Russell King - ARM Linux
2017-10-30 16:24             ` Gregory CLEMENT
2017-10-30 16:38               ` Russell King - ARM Linux
2017-10-31 12:47                 ` Russell King - ARM Linux
2017-10-31 12:57                   ` Ard Biesheuvel
2017-10-31 13:22                     ` Gregory CLEMENT
2017-11-01 15:57                       ` Ard Biesheuvel
2017-11-01 18:00                         ` Russell King - ARM Linux
2017-11-01 18:02                           ` Ard Biesheuvel
2017-11-01 18:11                             ` Russell King - ARM Linux
2017-11-01 18:20                               ` Ard Biesheuvel
2017-11-01 19:10                                 ` Russell King - ARM Linux
2017-10-30 15:09     ` Arnd Bergmann
2017-10-30 15:50       ` Russell King - ARM Linux
2017-10-30 17:01         ` Arnd Bergmann [this message]
2017-10-30 17:13           ` Russell King - ARM Linux

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='CAK8P3a37pQZPzLbh_qCtDqz0=Ends+nnV3-Y1KJKZVxiRErFfQ@mail.gmail.com' \
    --to=arnd@arndb.de \
    --cc=4sschmid@informatik.uni-hamburg.de \
    --cc=aaro.koskinen@iki.fi \
    --cc=andrea.adami@gmail.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=gregory.clement@free-electrons.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=petrcvekcz@gmail.com \
    --cc=robert.jarzmik@free.fr \
    --cc=romain.izard.pro@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).