2021-01-19 04:26:47

by Will Deacon

[permalink] [raw]
Subject: [STABLE BACKPORT 4.4.y, 4.9.y and 4.14.y] compiler.h: Raise minimum version of GCC to 5.1 for arm64

commit dca5244d2f5b94f1809f0c02a549edf41ccd5493 upstream.

GCC versions >= 4.9 and < 5.1 have been shown to emit memory references
beyond the stack pointer, resulting in memory corruption if an interrupt
is taken after the stack pointer has been adjusted but before the
reference has been executed. This leads to subtle, infrequent data
corruption such as the EXT4 problems reported by Russell King at the
link below.

Life is too short for buggy compilers, so raise the minimum GCC version
required by arm64 to 5.1.

Reported-by: Russell King <[email protected]>
Suggested-by: Arnd Bergmann <[email protected]>
Signed-off-by: Will Deacon <[email protected]>
Tested-by: Nathan Chancellor <[email protected]>
Reviewed-by: Nick Desaulniers <[email protected]>
Reviewed-by: Nathan Chancellor <[email protected]>
Acked-by: Linus Torvalds <[email protected]>
Cc: <[email protected]> # 4.4.y, 4.9.y and 4.14.y only
Cc: Theodore Ts'o <[email protected]>
Cc: Florian Weimer <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Nick Desaulniers <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Catalin Marinas <[email protected]>
[will: backport to 4.4.y/4.9.y/4.14.y]
Signed-off-by: Will Deacon <[email protected]>
---
include/linux/compiler-gcc.h | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index af8b4a879934..3cc8adede67b 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -145,6 +145,12 @@

#if GCC_VERSION < 30200
# error Sorry, your compiler is too old - please upgrade it.
+#elif defined(CONFIG_ARM64) && GCC_VERSION < 50100
+/*
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
+ * https://lore.kernel.org/r/[email protected]
+ */
+# error Sorry, your version of GCC is too old - please use 5.1 or newer.
#endif

#if GCC_VERSION < 30300
--
2.30.0.284.gd98b1dd5eaa7-goog


2021-01-19 22:23:47

by Nick Desaulniers

[permalink] [raw]
Subject: Re: [STABLE BACKPORT 4.4.y, 4.9.y and 4.14.y] compiler.h: Raise minimum version of GCC to 5.1 for arm64

On Mon, Jan 18, 2021 at 5:54 AM Will Deacon <[email protected]> wrote:
>
> commit dca5244d2f5b94f1809f0c02a549edf41ccd5493 upstream.
>
> GCC versions >= 4.9 and < 5.1 have been shown to emit memory references
> beyond the stack pointer, resulting in memory corruption if an interrupt
> is taken after the stack pointer has been adjusted but before the
> reference has been executed. This leads to subtle, infrequent data
> corruption such as the EXT4 problems reported by Russell King at the
> link below.
>
> Life is too short for buggy compilers, so raise the minimum GCC version
> required by arm64 to 5.1.
>
> Reported-by: Russell King <[email protected]>
> Suggested-by: Arnd Bergmann <[email protected]>
> Signed-off-by: Will Deacon <[email protected]>
> Tested-by: Nathan Chancellor <[email protected]>
> Reviewed-by: Nick Desaulniers <[email protected]>
> Reviewed-by: Nathan Chancellor <[email protected]>
> Acked-by: Linus Torvalds <[email protected]>
> Cc: <[email protected]> # 4.4.y, 4.9.y and 4.14.y only
> Cc: Theodore Ts'o <[email protected]>
> Cc: Florian Weimer <[email protected]>
> Cc: Peter Zijlstra <[email protected]>
> Cc: Nick Desaulniers <[email protected]>
> Link: https://lore.kernel.org/r/[email protected]
> Link: https://lore.kernel.org/r/[email protected]
> Signed-off-by: Catalin Marinas <[email protected]>
> [will: backport to 4.4.y/4.9.y/4.14.y]

Merging this from stable into "Android Common Kernel" trees that were
built with AOSP GCC 4.9, I expect this to break some builds. Arnd,
IIRC did you mention that AOSP GCC had picked up a fix? If so, did
you verify that via disassembly, or gerrit patch file?

(AOSP GCC 4.9: https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/
master branch, roll back a few commits).
It looks like AOSP GCC `#defines __android__ 1`.

I'm not arguing against a backport, just trying to think through how
we'll need to sort this out downstream. (Revert or patch on top that
checks for __android__, if AOSP GCC does in fact have a fix.)

> Signed-off-by: Will Deacon <[email protected]>
> ---
> include/linux/compiler-gcc.h | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> index af8b4a879934..3cc8adede67b 100644
> --- a/include/linux/compiler-gcc.h
> +++ b/include/linux/compiler-gcc.h
> @@ -145,6 +145,12 @@
>
> #if GCC_VERSION < 30200
> # error Sorry, your compiler is too old - please upgrade it.
> +#elif defined(CONFIG_ARM64) && GCC_VERSION < 50100
> +/*
> + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
> + * https://lore.kernel.org/r/[email protected]
> + */
> +# error Sorry, your version of GCC is too old - please use 5.1 or newer.
> #endif
>
> #if GCC_VERSION < 30300
> --
> 2.30.0.284.gd98b1dd5eaa7-goog
>


--
Thanks,
~Nick Desaulniers

2021-01-19 23:35:01

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [STABLE BACKPORT 4.4.y, 4.9.y and 4.14.y] compiler.h: Raise minimum version of GCC to 5.1 for arm64

On Tue, Jan 19, 2021 at 02:15:43PM -0800, Nick Desaulniers wrote:
> On Mon, Jan 18, 2021 at 5:54 AM Will Deacon <[email protected]> wrote:
> >
> > commit dca5244d2f5b94f1809f0c02a549edf41ccd5493 upstream.
> >
> > GCC versions >= 4.9 and < 5.1 have been shown to emit memory references
> > beyond the stack pointer, resulting in memory corruption if an interrupt
> > is taken after the stack pointer has been adjusted but before the
> > reference has been executed. This leads to subtle, infrequent data
> > corruption such as the EXT4 problems reported by Russell King at the
> > link below.
> >
> > Life is too short for buggy compilers, so raise the minimum GCC version
> > required by arm64 to 5.1.
> >
> > Reported-by: Russell King <[email protected]>
> > Suggested-by: Arnd Bergmann <[email protected]>
> > Signed-off-by: Will Deacon <[email protected]>
> > Tested-by: Nathan Chancellor <[email protected]>
> > Reviewed-by: Nick Desaulniers <[email protected]>
> > Reviewed-by: Nathan Chancellor <[email protected]>
> > Acked-by: Linus Torvalds <[email protected]>
> > Cc: <[email protected]> # 4.4.y, 4.9.y and 4.14.y only
> > Cc: Theodore Ts'o <[email protected]>
> > Cc: Florian Weimer <[email protected]>
> > Cc: Peter Zijlstra <[email protected]>
> > Cc: Nick Desaulniers <[email protected]>
> > Link: https://lore.kernel.org/r/[email protected]
> > Link: https://lore.kernel.org/r/[email protected]
> > Signed-off-by: Catalin Marinas <[email protected]>
> > [will: backport to 4.4.y/4.9.y/4.14.y]
>
> Merging this from stable into "Android Common Kernel" trees that were
> built with AOSP GCC 4.9, I expect this to break some builds. Arnd,
> IIRC did you mention that AOSP GCC had picked up a fix? If so, did
> you verify that via disassembly, or gerrit patch file?
>
> (AOSP GCC 4.9: https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/
> master branch, roll back a few commits).
> It looks like AOSP GCC `#defines __android__ 1`.

It seems like this is the source for that toolchain?

https://android.googlesource.com/toolchain/gcc

If so, it looks like that patch was picked up in this commit.

https://android.googlesource.com/toolchain/gcc/+/5ae0308a147ec3f6502fd321860524e634a647a6

Cheers,
Nathan

2021-01-20 08:13:28

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [STABLE BACKPORT 4.4.y, 4.9.y and 4.14.y] compiler.h: Raise minimum version of GCC to 5.1 for arm64

On Wed, Jan 20, 2021 at 12:29 AM Nathan Chancellor
<[email protected]> wrote:
> On Tue, Jan 19, 2021 at 02:15:43PM -0800, Nick Desaulniers wrote:
> >
> > Merging this from stable into "Android Common Kernel" trees that were
> > built with AOSP GCC 4.9, I expect this to break some builds. Arnd,
> > IIRC did you mention that AOSP GCC had picked up a fix? If so, did
> > you verify that via disassembly, or gerrit patch file?

The only information I had was the fact that the gcc bug tracker
mentioned it being picked up into the Android gcc and gcc-linaro.
I verified that it was present in gcc-linaro, but did not also check
the Android sources.

> If so, it looks like that patch was picked up in this commit.
>
> https://android.googlesource.com/toolchain/gcc/+/5ae0308a147ec3f6502fd321860524e634a647a6

Right.

Arnd