]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.9-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Nov 2018 17:56:02 +0000 (18:56 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Nov 2018 17:56:02 +0000 (18:56 +0100)
added patches:
arm64-uaccess-suppress-spurious-clang-warning.patch
crypto-arm64-sha-avoid-non-standard-inline-asm-tricks.patch
crypto-x86-aesni-fix-token-pasting-for-clang.patch
efi-libstub-arm64-force-hidden-visibility-for-section-markers.patch
efi-libstub-arm64-set-fpie-when-building-the-efi-stub.patch
efi-libstub-arm64-use-hidden-attribute-for-struct-screen_info-reference.patch
efi-libstub-preserve-.debug-sections-after-absolute-relocation-check.patch
kbuild-add-__cc-option-macro.patch
kbuild-add-better-clang-cross-build-support.patch
kbuild-add-support-to-generate-llvm-assembly-files.patch
kbuild-clang-add-no-integrated-as-to-kbuild_flags.patch
kbuild-clang-disable-address-of-packed-member-warning.patch
kbuild-consolidate-header-generation-from-asm-offset-information.patch
kbuild-consolidate-redundant-sed-script-asm-offset-generation.patch
kbuild-drop-wno-unknown-warning-option-from-clang-options.patch
kbuild-fix-asm-offset-generation-to-work-with-clang.patch
kbuild-llvmlinux-add-werror-to-cc-option-to-support-clang.patch
kbuild-use-fshort-wchar-globally.patch
kbuild-use-oz-instead-of-os-when-using-clang.patch
modules-mark-__inittest-__exittest-as-__maybe_unused.patch
x86-boot-undef-memcpy-et-al-in-string.c.patch
x86-build-fix-stack-alignment-for-clang.patch
x86-build-specify-stack-alignment-for-clang.patch
x86-build-use-__cc-option-for-boot-code-compiler-options.patch
x86-build-use-cc-option-to-validate-stack-alignment-parameter.patch
x86-kbuild-use-cc-option-to-enable-falign-jumps-loops.patch

27 files changed:
queue-4.9/arm64-uaccess-suppress-spurious-clang-warning.patch [new file with mode: 0644]
queue-4.9/crypto-arm64-sha-avoid-non-standard-inline-asm-tricks.patch [new file with mode: 0644]
queue-4.9/crypto-x86-aesni-fix-token-pasting-for-clang.patch [new file with mode: 0644]
queue-4.9/efi-libstub-arm64-force-hidden-visibility-for-section-markers.patch [new file with mode: 0644]
queue-4.9/efi-libstub-arm64-set-fpie-when-building-the-efi-stub.patch [new file with mode: 0644]
queue-4.9/efi-libstub-arm64-use-hidden-attribute-for-struct-screen_info-reference.patch [new file with mode: 0644]
queue-4.9/efi-libstub-preserve-.debug-sections-after-absolute-relocation-check.patch [new file with mode: 0644]
queue-4.9/kbuild-add-__cc-option-macro.patch [new file with mode: 0644]
queue-4.9/kbuild-add-better-clang-cross-build-support.patch [new file with mode: 0644]
queue-4.9/kbuild-add-support-to-generate-llvm-assembly-files.patch [new file with mode: 0644]
queue-4.9/kbuild-clang-add-no-integrated-as-to-kbuild_flags.patch [new file with mode: 0644]
queue-4.9/kbuild-clang-disable-address-of-packed-member-warning.patch [new file with mode: 0644]
queue-4.9/kbuild-consolidate-header-generation-from-asm-offset-information.patch [new file with mode: 0644]
queue-4.9/kbuild-consolidate-redundant-sed-script-asm-offset-generation.patch [new file with mode: 0644]
queue-4.9/kbuild-drop-wno-unknown-warning-option-from-clang-options.patch [new file with mode: 0644]
queue-4.9/kbuild-fix-asm-offset-generation-to-work-with-clang.patch [new file with mode: 0644]
queue-4.9/kbuild-llvmlinux-add-werror-to-cc-option-to-support-clang.patch [new file with mode: 0644]
queue-4.9/kbuild-use-fshort-wchar-globally.patch [new file with mode: 0644]
queue-4.9/kbuild-use-oz-instead-of-os-when-using-clang.patch [new file with mode: 0644]
queue-4.9/modules-mark-__inittest-__exittest-as-__maybe_unused.patch [new file with mode: 0644]
queue-4.9/series
queue-4.9/x86-boot-undef-memcpy-et-al-in-string.c.patch [new file with mode: 0644]
queue-4.9/x86-build-fix-stack-alignment-for-clang.patch [new file with mode: 0644]
queue-4.9/x86-build-specify-stack-alignment-for-clang.patch [new file with mode: 0644]
queue-4.9/x86-build-use-__cc-option-for-boot-code-compiler-options.patch [new file with mode: 0644]
queue-4.9/x86-build-use-cc-option-to-validate-stack-alignment-parameter.patch [new file with mode: 0644]
queue-4.9/x86-kbuild-use-cc-option-to-enable-falign-jumps-loops.patch [new file with mode: 0644]

diff --git a/queue-4.9/arm64-uaccess-suppress-spurious-clang-warning.patch b/queue-4.9/arm64-uaccess-suppress-spurious-clang-warning.patch
new file mode 100644 (file)
index 0000000..8028b3b
--- /dev/null
@@ -0,0 +1,85 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Mark Rutland <mark.rutland@arm.com>
+Date: Wed, 3 May 2017 16:09:38 +0100
+Subject: arm64: uaccess: suppress spurious clang warning
+
+From: Mark Rutland <mark.rutland@arm.com>
+
+commit d135b8b5060ea91dd751ff172d179eb4eab1e966 upstream.
+
+Clang tries to warn when there's a mismatch between an operand's size,
+and the size of the register it is held in, as this may indicate a bug.
+Specifically, clang warns when the operand's type is less than 64 bits
+wide, and the register is used unqualified (i.e. %N rather than %xN or
+%wN).
+
+Unfortunately clang can generate these warnings for unreachable code.
+For example, for code like:
+
+do {                                            \
+        typeof(*(ptr)) __v = (v);               \
+        switch(sizeof(*(ptr))) {                \
+        case 1:                                 \
+                // assume __v is 1 byte wide    \
+                asm ("{op}b %w0" : : "r" (v));  \
+                break;                          \
+        case 8:                                 \
+                // assume __v is 8 bytes wide   \
+                asm ("{op} %0" : : "r" (v));    \
+                break;                          \
+        }
+while (0)
+
+... if op() were passed a char value and pointer to char, clang may
+produce a warning for the unreachable case where sizeof(*(ptr)) is 8.
+
+For the same reasons, clang produces warnings when __put_user_err() is
+used for types that are less than 64 bits wide.
+
+We could avoid this with a cast to a fixed-width type in each of the
+cases. However, GCC will then warn that pointer types are being cast to
+mismatched integer sizes (in unreachable paths).
+
+Another option would be to use the same union trickery as we do for
+__smp_store_release() and __smp_load_acquire(), but this is fairly
+invasive.
+
+Instead, this patch suppresses the clang warning by using an x modifier
+in the assembly for the 8 byte case of __put_user_err(). No additional
+work is necessary as the value has been cast to typeof(*(ptr)), so the
+compiler will have performed any necessary extension for the reachable
+case.
+
+For consistency, __get_user_err() is also updated to use the x modifier
+for its 8 byte case.
+
+Acked-by: Will Deacon <will.deacon@arm.com>
+Signed-off-by: Mark Rutland <mark.rutland@arm.com>
+Reported-by: Matthias Kaehlcke <mka@chromium.org>
+Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/arm64/include/asm/uaccess.h |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/arch/arm64/include/asm/uaccess.h
++++ b/arch/arm64/include/asm/uaccess.h
+@@ -198,7 +198,7 @@ do {                                                                       \
+                              (err), ARM64_HAS_UAO);                   \
+               break;                                                  \
+       case 8:                                                         \
+-              __get_user_asm("ldr", "ldtr", "%",  __gu_val, (ptr),    \
++              __get_user_asm("ldr", "ldtr", "%x",  __gu_val, (ptr),   \
+                              (err), ARM64_HAS_UAO);                   \
+               break;                                                  \
+       default:                                                        \
+@@ -272,7 +272,7 @@ do {                                                                       \
+                              (err), ARM64_HAS_UAO);                   \
+               break;                                                  \
+       case 8:                                                         \
+-              __put_user_asm("str", "sttr", "%", __pu_val, (ptr),     \
++              __put_user_asm("str", "sttr", "%x", __pu_val, (ptr),    \
+                              (err), ARM64_HAS_UAO);                   \
+               break;                                                  \
+       default:                                                        \
diff --git a/queue-4.9/crypto-arm64-sha-avoid-non-standard-inline-asm-tricks.patch b/queue-4.9/crypto-arm64-sha-avoid-non-standard-inline-asm-tricks.patch
new file mode 100644 (file)
index 0000000..b384767
--- /dev/null
@@ -0,0 +1,140 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+Date: Wed, 26 Apr 2017 17:11:32 +0100
+Subject: crypto: arm64/sha - avoid non-standard inline asm tricks
+
+From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+
+commit f4857f4c2ee9aa4e2aacac1a845352b00197fb57 upstream.
+
+Replace the inline asm which exports struct offsets as ELF symbols
+with proper const variables exposing the same values. This works
+around an issue with Clang which does not interpret the "i" (or "I")
+constraints in the same way as GCC.
+
+Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+Tested-by: Matthias Kaehlcke <mka@chromium.org>
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/arm64/crypto/sha1-ce-core.S |    6 ++++--
+ arch/arm64/crypto/sha1-ce-glue.c |   11 +++--------
+ arch/arm64/crypto/sha2-ce-core.S |    6 ++++--
+ arch/arm64/crypto/sha2-ce-glue.c |   13 +++++--------
+ 4 files changed, 16 insertions(+), 20 deletions(-)
+
+--- a/arch/arm64/crypto/sha1-ce-core.S
++++ b/arch/arm64/crypto/sha1-ce-core.S
+@@ -82,7 +82,8 @@ ENTRY(sha1_ce_transform)
+       ldr             dgb, [x0, #16]
+       /* load sha1_ce_state::finalize */
+-      ldr             w4, [x0, #:lo12:sha1_ce_offsetof_finalize]
++      ldr_l           w4, sha1_ce_offsetof_finalize, x4
++      ldr             w4, [x0, x4]
+       /* load input */
+ 0:    ld1             {v8.4s-v11.4s}, [x1], #64
+@@ -132,7 +133,8 @@ CPU_LE(    rev32           v11.16b, v11.16b        )
+        * the padding is handled by the C code in that case.
+        */
+       cbz             x4, 3f
+-      ldr             x4, [x0, #:lo12:sha1_ce_offsetof_count]
++      ldr_l           w4, sha1_ce_offsetof_count, x4
++      ldr             x4, [x0, x4]
+       movi            v9.2d, #0
+       mov             x8, #0x80000000
+       movi            v10.2d, #0
+--- a/arch/arm64/crypto/sha1-ce-glue.c
++++ b/arch/arm64/crypto/sha1-ce-glue.c
+@@ -17,9 +17,6 @@
+ #include <linux/crypto.h>
+ #include <linux/module.h>
+-#define ASM_EXPORT(sym, val) \
+-      asm(".globl " #sym "; .set " #sym ", %0" :: "I"(val));
+-
+ MODULE_DESCRIPTION("SHA1 secure hash using ARMv8 Crypto Extensions");
+ MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
+ MODULE_LICENSE("GPL v2");
+@@ -32,6 +29,9 @@ struct sha1_ce_state {
+ asmlinkage void sha1_ce_transform(struct sha1_ce_state *sst, u8 const *src,
+                                 int blocks);
++const u32 sha1_ce_offsetof_count = offsetof(struct sha1_ce_state, sst.count);
++const u32 sha1_ce_offsetof_finalize = offsetof(struct sha1_ce_state, finalize);
++
+ static int sha1_ce_update(struct shash_desc *desc, const u8 *data,
+                         unsigned int len)
+ {
+@@ -52,11 +52,6 @@ static int sha1_ce_finup(struct shash_de
+       struct sha1_ce_state *sctx = shash_desc_ctx(desc);
+       bool finalize = !sctx->sst.count && !(len % SHA1_BLOCK_SIZE);
+-      ASM_EXPORT(sha1_ce_offsetof_count,
+-                 offsetof(struct sha1_ce_state, sst.count));
+-      ASM_EXPORT(sha1_ce_offsetof_finalize,
+-                 offsetof(struct sha1_ce_state, finalize));
+-
+       /*
+        * Allow the asm code to perform the finalization if there is no
+        * partial data and the input is a round multiple of the block size.
+--- a/arch/arm64/crypto/sha2-ce-core.S
++++ b/arch/arm64/crypto/sha2-ce-core.S
+@@ -88,7 +88,8 @@ ENTRY(sha2_ce_transform)
+       ld1             {dgav.4s, dgbv.4s}, [x0]
+       /* load sha256_ce_state::finalize */
+-      ldr             w4, [x0, #:lo12:sha256_ce_offsetof_finalize]
++      ldr_l           w4, sha256_ce_offsetof_finalize, x4
++      ldr             w4, [x0, x4]
+       /* load input */
+ 0:    ld1             {v16.4s-v19.4s}, [x1], #64
+@@ -136,7 +137,8 @@ CPU_LE(    rev32           v19.16b, v19.16b        )
+        * the padding is handled by the C code in that case.
+        */
+       cbz             x4, 3f
+-      ldr             x4, [x0, #:lo12:sha256_ce_offsetof_count]
++      ldr_l           w4, sha256_ce_offsetof_count, x4
++      ldr             x4, [x0, x4]
+       movi            v17.2d, #0
+       mov             x8, #0x80000000
+       movi            v18.2d, #0
+--- a/arch/arm64/crypto/sha2-ce-glue.c
++++ b/arch/arm64/crypto/sha2-ce-glue.c
+@@ -17,9 +17,6 @@
+ #include <linux/crypto.h>
+ #include <linux/module.h>
+-#define ASM_EXPORT(sym, val) \
+-      asm(".globl " #sym "; .set " #sym ", %0" :: "I"(val));
+-
+ MODULE_DESCRIPTION("SHA-224/SHA-256 secure hash using ARMv8 Crypto Extensions");
+ MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
+ MODULE_LICENSE("GPL v2");
+@@ -32,6 +29,11 @@ struct sha256_ce_state {
+ asmlinkage void sha2_ce_transform(struct sha256_ce_state *sst, u8 const *src,
+                                 int blocks);
++const u32 sha256_ce_offsetof_count = offsetof(struct sha256_ce_state,
++                                            sst.count);
++const u32 sha256_ce_offsetof_finalize = offsetof(struct sha256_ce_state,
++                                               finalize);
++
+ static int sha256_ce_update(struct shash_desc *desc, const u8 *data,
+                           unsigned int len)
+ {
+@@ -52,11 +54,6 @@ static int sha256_ce_finup(struct shash_
+       struct sha256_ce_state *sctx = shash_desc_ctx(desc);
+       bool finalize = !sctx->sst.count && !(len % SHA256_BLOCK_SIZE);
+-      ASM_EXPORT(sha256_ce_offsetof_count,
+-                 offsetof(struct sha256_ce_state, sst.count));
+-      ASM_EXPORT(sha256_ce_offsetof_finalize,
+-                 offsetof(struct sha256_ce_state, finalize));
+-
+       /*
+        * Allow the asm code to perform the finalization if there is no
+        * partial data and the input is a round multiple of the block size.
diff --git a/queue-4.9/crypto-x86-aesni-fix-token-pasting-for-clang.patch b/queue-4.9/crypto-x86-aesni-fix-token-pasting-for-clang.patch
new file mode 100644 (file)
index 0000000..ef3b488
--- /dev/null
@@ -0,0 +1,63 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Michael Davidson <md@google.com>
+Date: Wed, 15 Mar 2017 15:36:00 -0700
+Subject: crypto, x86: aesni - fix token pasting for clang
+
+From: Michael Davidson <md@google.com>
+
+commit fdb2726f4e61c5e3abc052f547d5a5f6c0dc5504 upstream.
+
+aes_ctrby8_avx-x86_64.S uses the C preprocessor for token pasting
+of character sequences that are not valid preprocessor tokens.
+While this is allowed when preprocessing assembler files it exposes
+an incompatibilty between the clang and gcc preprocessors where
+clang does not strip leading white space from macro parameters,
+leading to the CONCAT(%xmm, i) macro expansion on line 96 resulting
+in a token with a space character embedded in it.
+
+While this could be resolved by deleting the offending space character,
+the assembler is perfectly capable of doing the token pasting correctly
+for itself so we can just get rid of the preprocessor macros.
+
+Signed-off-by: Michael Davidson <md@google.com>
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/crypto/aes_ctrby8_avx-x86_64.S |    7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+--- a/arch/x86/crypto/aes_ctrby8_avx-x86_64.S
++++ b/arch/x86/crypto/aes_ctrby8_avx-x86_64.S
+@@ -65,7 +65,6 @@
+ #include <linux/linkage.h>
+ #include <asm/inst.h>
+-#define CONCAT(a,b)   a##b
+ #define VMOVDQ                vmovdqu
+ #define xdata0                %xmm0
+@@ -92,8 +91,6 @@
+ #define num_bytes     %r8
+ #define tmp           %r10
+-#define       DDQ(i)          CONCAT(ddq_add_,i)
+-#define       XMM(i)          CONCAT(%xmm, i)
+ #define       DDQ_DATA        0
+ #define       XDATA           1
+ #define KEY_128               1
+@@ -131,12 +128,12 @@ ddq_add_8:
+ /* generate a unique variable for ddq_add_x */
+ .macro setddq n
+-      var_ddq_add = DDQ(\n)
++      var_ddq_add = ddq_add_\n
+ .endm
+ /* generate a unique variable for xmm register */
+ .macro setxdata n
+-      var_xdata = XMM(\n)
++      var_xdata = %xmm\n
+ .endm
+ /* club the numeric 'id' to the symbol 'name' */
diff --git a/queue-4.9/efi-libstub-arm64-force-hidden-visibility-for-section-markers.patch b/queue-4.9/efi-libstub-arm64-force-hidden-visibility-for-section-markers.patch
new file mode 100644 (file)
index 0000000..4902ff5
--- /dev/null
@@ -0,0 +1,49 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+Date: Fri, 18 Aug 2017 20:49:36 +0100
+Subject: efi/libstub/arm64: Force 'hidden' visibility for section markers
+
+From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+
+commit 0426a4e68f18d75515414361de9e3e1445d2644e upstream.
+
+To prevent the compiler from emitting absolute references to the section
+markers when running in PIC mode, override the visibility to 'hidden' for
+all contents of asm/sections.h
+
+Tested-by: Matthias Kaehlcke <mka@chromium.org>
+Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Matt Fleming <matt@codeblueprint.co.uk>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: linux-efi@vger.kernel.org
+Link: http://lkml.kernel.org/r/20170818194947.19347-4-ard.biesheuvel@linaro.org
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/firmware/efi/libstub/arm64-stub.c |   10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+--- a/drivers/firmware/efi/libstub/arm64-stub.c
++++ b/drivers/firmware/efi/libstub/arm64-stub.c
+@@ -9,9 +9,17 @@
+  * published by the Free Software Foundation.
+  *
+  */
++
++/*
++ * To prevent the compiler from emitting GOT-indirected (and thus absolute)
++ * references to the section markers, override their visibility as 'hidden'
++ */
++#pragma GCC visibility push(hidden)
++#include <asm/sections.h>
++#pragma GCC visibility pop
++
+ #include <linux/efi.h>
+ #include <asm/efi.h>
+-#include <asm/sections.h>
+ #include <asm/sysreg.h>
+ #include "efistub.h"
diff --git a/queue-4.9/efi-libstub-arm64-set-fpie-when-building-the-efi-stub.patch b/queue-4.9/efi-libstub-arm64-set-fpie-when-building-the-efi-stub.patch
new file mode 100644 (file)
index 0000000..d1e2ff3
--- /dev/null
@@ -0,0 +1,49 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+Date: Fri, 18 Aug 2017 20:49:37 +0100
+Subject: efi/libstub/arm64: Set -fpie when building the EFI stub
+
+From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+
+commit 91ee5b21ee026c49e4e7483de69b55b8b47042be upstream.
+
+Clang may emit absolute symbol references when building in non-PIC mode,
+even when using the default 'small' code model, which is already mostly
+position independent to begin with, due to its use of adrp/add pairs
+that have a relative range of +/- 4 GB. The remedy is to pass the -fpie
+flag, which can be done safely now that the code has been updated to avoid
+GOT indirections (which may be emitted due to the compiler assuming that
+the PIC/PIE code may end up in a shared library that is subject to ELF
+symbol preemption)
+
+Passing -fpie when building code that needs to execute at an a priori
+unknown offset is arguably an improvement in any case, and given that
+the recent visibility changes allow the PIC build to pass with GCC as
+well, let's add -fpie for all arm64 builds rather than only for Clang.
+
+Tested-by: Matthias Kaehlcke <mka@chromium.org>
+Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Matt Fleming <matt@codeblueprint.co.uk>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: linux-efi@vger.kernel.org
+Link: http://lkml.kernel.org/r/20170818194947.19347-5-ard.biesheuvel@linaro.org
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/firmware/efi/libstub/Makefile |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/firmware/efi/libstub/Makefile
++++ b/drivers/firmware/efi/libstub/Makefile
+@@ -10,7 +10,7 @@ cflags-$(CONFIG_X86)         += -m$(BITS) -D__K
+                                  -fPIC -fno-strict-aliasing -mno-red-zone \
+                                  -mno-mmx -mno-sse
+-cflags-$(CONFIG_ARM64)                := $(subst -pg,,$(KBUILD_CFLAGS))
++cflags-$(CONFIG_ARM64)                := $(subst -pg,,$(KBUILD_CFLAGS)) -fpie
+ cflags-$(CONFIG_ARM)          := $(subst -pg,,$(KBUILD_CFLAGS)) \
+                                  -fno-builtin -fpic -mno-single-pic-base
diff --git a/queue-4.9/efi-libstub-arm64-use-hidden-attribute-for-struct-screen_info-reference.patch b/queue-4.9/efi-libstub-arm64-use-hidden-attribute-for-struct-screen_info-reference.patch
new file mode 100644 (file)
index 0000000..331799a
--- /dev/null
@@ -0,0 +1,40 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+Date: Fri, 18 Aug 2017 20:49:35 +0100
+Subject: efi/libstub/arm64: Use hidden attribute for struct screen_info reference
+
+From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+
+commit 760b61d76da6d6a99eb245ab61abf71ca5415cea upstream.
+
+To prevent the compiler from emitting absolute references to screen_info
+when building position independent code, redeclare the symbol with hidden
+visibility.
+
+Tested-by: Matthias Kaehlcke <mka@chromium.org>
+Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Matt Fleming <matt@codeblueprint.co.uk>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: linux-efi@vger.kernel.org
+Link: http://lkml.kernel.org/r/20170818194947.19347-3-ard.biesheuvel@linaro.org
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/arm64/include/asm/efi.h |    3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/arch/arm64/include/asm/efi.h
++++ b/arch/arm64/include/asm/efi.h
+@@ -54,6 +54,9 @@ int efi_set_mapping_permissions(struct m
+ #define alloc_screen_info(x...)               &screen_info
+ #define free_screen_info(x...)
++/* redeclare as 'hidden' so the compiler will generate relative references */
++extern struct screen_info screen_info __attribute__((__visibility__("hidden")));
++
+ static inline void efifb_setup_from_dmi(struct screen_info *si, const char *opt)
+ {
+ }
diff --git a/queue-4.9/efi-libstub-preserve-.debug-sections-after-absolute-relocation-check.patch b/queue-4.9/efi-libstub-preserve-.debug-sections-after-absolute-relocation-check.patch
new file mode 100644 (file)
index 0000000..dfad1c6
--- /dev/null
@@ -0,0 +1,90 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+Date: Tue, 31 Jan 2017 13:21:42 +0000
+Subject: efi/libstub: Preserve .debug sections after absolute relocation check
+
+From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+
+commit 696204faa6e8a318320ebb49d9fa69bc8275644d upstream.
+
+The build commands for the ARM and arm64 EFI stubs strip the .debug
+sections and other sections that may legally contain absolute relocations,
+in order to inspect the remaining sections for the presence of such
+relocations.
+
+This leaves us without debugging symbols in the stub for no good reason,
+considering that these sections are omitted from the kernel binary anyway,
+and that these relocations are thus only consumed by users of the ELF
+binary, such as debuggers.
+
+So move to 'strip' for performing the relocation check, and if it succeeds,
+invoke objcopy as before, but leaving the .debug sections in place. Note
+that these sections may refer to ksymtab/kcrctab contents, so leave those
+in place as well.
+
+Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Matt Fleming <matt@codeblueprint.co.uk>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: linux-efi@vger.kernel.org
+Link: http://lkml.kernel.org/r/1485868902-20401-11-git-send-email-ard.biesheuvel@linaro.org
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/firmware/efi/libstub/Makefile |   24 ++++++++++++++++--------
+ 1 file changed, 16 insertions(+), 8 deletions(-)
+
+--- a/drivers/firmware/efi/libstub/Makefile
++++ b/drivers/firmware/efi/libstub/Makefile
+@@ -11,7 +11,7 @@ cflags-$(CONFIG_X86)         += -m$(BITS) -D__K
+                                  -mno-mmx -mno-sse
+ cflags-$(CONFIG_ARM64)                := $(subst -pg,,$(KBUILD_CFLAGS))
+-cflags-$(CONFIG_ARM)          := $(subst -pg,,$(KBUILD_CFLAGS)) -g0 \
++cflags-$(CONFIG_ARM)          := $(subst -pg,,$(KBUILD_CFLAGS)) \
+                                  -fno-builtin -fpic -mno-single-pic-base
+ cflags-$(CONFIG_EFI_ARMSTUB)  += -I$(srctree)/scripts/dtc/libfdt
+@@ -60,7 +60,7 @@ CFLAGS_arm64-stub.o          := -DTEXT_OFFSET=$
+ extra-$(CONFIG_EFI_ARMSTUB)   := $(lib-y)
+ lib-$(CONFIG_EFI_ARMSTUB)     := $(patsubst %.o,%.stub.o,$(lib-y))
+-STUBCOPY_FLAGS-y              := -R .debug* -R *ksymtab* -R *kcrctab*
++STUBCOPY_RM-y                 := -R *ksymtab* -R *kcrctab*
+ STUBCOPY_FLAGS-$(CONFIG_ARM64)        += --prefix-alloc-sections=.init \
+                                  --prefix-symbols=__efistub_
+ STUBCOPY_RELOC-$(CONFIG_ARM64)        := R_AARCH64_ABS
+@@ -68,17 +68,25 @@ STUBCOPY_RELOC-$(CONFIG_ARM64)     := R_AARC
+ $(obj)/%.stub.o: $(obj)/%.o FORCE
+       $(call if_changed,stubcopy)
++#
++# Strip debug sections and some other sections that may legally contain
++# absolute relocations, so that we can inspect the remaining sections for
++# such relocations. If none are found, regenerate the output object, but
++# this time, use objcopy and leave all sections in place.
++#
+ quiet_cmd_stubcopy = STUBCPY $@
+-      cmd_stubcopy = if $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@; then    \
+-                   $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y)        \
+-                   && (echo >&2 "$@: absolute symbol references not allowed in the EFI stub"; \
+-                       rm -f $@; /bin/false); else /bin/false; fi
++      cmd_stubcopy = if $(STRIP) --strip-debug $(STUBCOPY_RM-y) -o $@ $<; \
++                   then if $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y); \
++                   then (echo >&2 "$@: absolute symbol references not allowed in the EFI stub"; \
++                         rm -f $@; /bin/false);                         \
++                   else $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@; fi        \
++                   else /bin/false; fi
+ #
+ # ARM discards the .data section because it disallows r/w data in the
+ # decompressor. So move our .data to .data.efistub, which is preserved
+ # explicitly by the decompressor linker script.
+ #
+-STUBCOPY_FLAGS-$(CONFIG_ARM)  += --rename-section .data=.data.efistub \
+-                                 -R ___ksymtab+sort -R ___kcrctab+sort
++STUBCOPY_FLAGS-$(CONFIG_ARM)  += --rename-section .data=.data.efistub
++STUBCOPY_RM-$(CONFIG_ARM)     += -R ___ksymtab+sort -R ___kcrctab+sort
+ STUBCOPY_RELOC-$(CONFIG_ARM)  := R_ARM_ABS
diff --git a/queue-4.9/kbuild-add-__cc-option-macro.patch b/queue-4.9/kbuild-add-__cc-option-macro.patch
new file mode 100644 (file)
index 0000000..eb522c0
--- /dev/null
@@ -0,0 +1,92 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Matthias Kaehlcke <mka@chromium.org>
+Date: Wed, 21 Jun 2017 16:28:03 -0700
+Subject: kbuild: Add __cc-option macro
+
+From: Matthias Kaehlcke <mka@chromium.org>
+
+commit 9f3f1fd299768782465cb32cdf0dd4528d11f26b upstream.
+
+cc-option uses KBUILD_CFLAGS and KBUILD_CPPFLAGS when it determines
+whether an option is supported or not. This is fine for options used to
+build the kernel itself, however some components like the x86 boot code
+use a different set of flags.
+
+Add the new macro __cc-option which is a more generic version of
+cc-option with additional parameters. One parameter is the compiler
+with which the check should be performed, the other the compiler options
+to be used instead KBUILD_C*FLAGS.
+
+Refactor cc-option and hostcc-option to use __cc-option and move
+hostcc-option to scripts/Kbuild.include.
+
+Suggested-by: Arnd Bergmann <arnd@arndb.de>
+Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
+Acked-by: Arnd Bergmann <arnd@arndb.de>
+Acked-by: Michal Marek <mmarek@suse.com>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile               |    2 +-
+ scripts/Kbuild.include |   14 ++++++++++++--
+ scripts/Makefile.host  |    6 ------
+ 3 files changed, 13 insertions(+), 9 deletions(-)
+
+--- a/Makefile
++++ b/Makefile
+@@ -303,7 +303,7 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH"
+ HOSTCC       = gcc
+ HOSTCXX      = g++
+-HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
++HOSTCFLAGS   := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
+ HOSTCXXFLAGS = -O2
+ ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
+--- a/scripts/Kbuild.include
++++ b/scripts/Kbuild.include
+@@ -109,6 +109,11 @@ as-option = $(call try-run,\
+ as-instr = $(call try-run,\
+       printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
++# __cc-option
++# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
++__cc-option = $(call try-run,\
++      $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4))
++
+ # Do not attempt to build with gcc plugins during cc-option tests.
+ # (And this uses delayed resolution so the flags will be up to date.)
+ CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
+@@ -116,8 +121,13 @@ CC_OPTION_CFLAGS = $(filter-out $(GCC_PL
+ # cc-option
+ # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
+-cc-option = $(call try-run,\
+-      $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
++cc-option = $(call __cc-option, $(CC),\
++      $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS),$(1),$(2))
++
++# hostcc-option
++# Usage: cflags-y += $(call hostcc-option,-march=winchip-c6,-march=i586)
++hostcc-option = $(call __cc-option, $(HOSTCC),\
++      $(HOSTCFLAGS) $(HOST_EXTRACFLAGS),$(1),$(2))
+ # cc-option-yn
+ # Usage: flag := $(call cc-option-yn,-march=winchip-c6)
+--- a/scripts/Makefile.host
++++ b/scripts/Makefile.host
+@@ -20,12 +20,6 @@
+ # Will compile qconf as a C++ program, and menu as a C program.
+ # They are linked as C++ code to the executable qconf
+-# hostcc-option
+-# Usage: cflags-y += $(call hostcc-option,-march=winchip-c6,-march=i586)
+-
+-hostcc-option = $(call try-run,\
+-      $(HOSTCC) $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
+-
+ __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
+ host-cshlib := $(sort $(hostlibs-y) $(hostlibs-m))
+ host-cxxshlib := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
diff --git a/queue-4.9/kbuild-add-better-clang-cross-build-support.patch b/queue-4.9/kbuild-add-better-clang-cross-build-support.patch
new file mode 100644 (file)
index 0000000..e367d28
--- /dev/null
@@ -0,0 +1,48 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Behan Webster <behanw@converseincode.com>
+Date: Fri, 21 Apr 2017 11:20:01 -0700
+Subject: kbuild: Add better clang cross build support
+
+From: Behan Webster <behanw@converseincode.com>
+
+commit 785f11aa595bc3d4e74096cbd598ada54ecc0d81 upstream.
+
+Add cross target to CC if using clang. Also add custom gcc toolchain
+path for fallback gcc tools.
+
+Clang will fallback to using things like ld, as, and libgcc if
+(respectively) one of the llvm linkers isn't available, the integrated
+assembler is turned off, or an appropriately cross-compiled version of
+compiler-rt isn't available. To this end, you can specify the path to
+this fallback gcc toolchain with GCC_TOOLCHAIN.
+
+Signed-off-by: Behan Webster <behanw@converseincode.com>
+Reviewed-by: Jan-Simon Möller <dl9pf@gmx.de>
+Reviewed-by: Mark Charlebois <charlebm@gmail.com>
+Signed-off-by: Greg Hackmann <ghackmann@google.com>
+Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile |    9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+--- a/Makefile
++++ b/Makefile
+@@ -704,6 +704,15 @@ endif
+ KBUILD_CFLAGS += $(stackp-flag)
+ ifeq ($(cc-name),clang)
++ifneq ($(CROSS_COMPILE),)
++CLANG_TARGET  := -target $(notdir $(CROSS_COMPILE:%-=%))
++GCC_TOOLCHAIN := $(realpath $(dir $(shell which $(LD)))/..)
++endif
++ifneq ($(GCC_TOOLCHAIN),)
++CLANG_GCC_TC  := -gcc-toolchain $(GCC_TOOLCHAIN)
++endif
++KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
++KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
+ KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
+ KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,)
+ KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
diff --git a/queue-4.9/kbuild-add-support-to-generate-llvm-assembly-files.patch b/queue-4.9/kbuild-add-support-to-generate-llvm-assembly-files.patch
new file mode 100644 (file)
index 0000000..2df9a1b
--- /dev/null
@@ -0,0 +1,82 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: "Vinícius Tinti" <viniciustinti@gmail.com>
+Date: Mon, 24 Apr 2017 13:04:58 -0700
+Subject: kbuild: Add support to generate LLVM assembly files
+
+From: "Vinícius Tinti" <viniciustinti@gmail.com>
+
+commit 433db3e260bc8134d4a46ddf20b3668937e12556 upstream.
+
+Add rules to kbuild in order to generate LLVM assembly files with the .ll
+extension when using clang.
+
+  # from c code
+  make CC=clang kernel/pid.ll
+
+Signed-off-by: Vinícius Tinti <viniciustinti@gmail.com>
+Signed-off-by: Behan Webster <behanw@converseincode.com>
+Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ .gitignore             |    1 +
+ Makefile               |    5 +++++
+ scripts/Makefile.build |    8 ++++++++
+ 3 files changed, 14 insertions(+)
+
+--- a/.gitignore
++++ b/.gitignore
+@@ -33,6 +33,7 @@
+ *.lzo
+ *.patch
+ *.gcno
++*.ll
+ modules.builtin
+ Module.symvers
+ *.dwo
+--- a/Makefile
++++ b/Makefile
+@@ -1390,6 +1390,8 @@ help:
+       @echo  '                    (default: $$(INSTALL_MOD_PATH)/lib/firmware)'
+       @echo  '  dir/            - Build all files in dir and below'
+       @echo  '  dir/file.[ois]  - Build specified target only'
++      @echo  '  dir/file.ll     - Build the LLVM assembly file'
++      @echo  '                    (requires compiler support for LLVM assembly generation)'
+       @echo  '  dir/file.lst    - Build specified mixed source/assembly target only'
+       @echo  '                    (requires a recent binutils and recent build (System.map))'
+       @echo  '  dir/file.ko     - Build module including final link'
+@@ -1574,6 +1576,7 @@ clean: $(clean-dirs)
+               -o -name '*.symtypes' -o -name 'modules.order' \
+               -o -name modules.builtin -o -name '.tmp_*.o.*' \
+               -o -name '*.c.[012]*.*' \
++              -o -name '*.ll' \
+               -o -name '*.gcno' \) -type f -print | xargs rm -f
+ # Generate tags for editors
+@@ -1677,6 +1680,8 @@ endif
+       $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
+ %.symtypes: %.c prepare scripts FORCE
+       $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
++%.ll: %.c prepare scripts FORCE
++      $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
+ # Modules
+ /: prepare scripts FORCE
+--- a/scripts/Makefile.build
++++ b/scripts/Makefile.build
+@@ -176,6 +176,14 @@ cmd_cc_symtypes_c =
+ $(obj)/%.symtypes : $(src)/%.c FORCE
+       $(call cmd,cc_symtypes_c)
++# LLVM assembly
++# Generate .ll files from .c
++quiet_cmd_cc_ll_c = CC $(quiet_modtag)  $@
++      cmd_cc_ll_c = $(CC) $(c_flags) -emit-llvm -S -o $@ $<
++
++$(obj)/%.ll: $(src)/%.c FORCE
++      $(call if_changed_dep,cc_ll_c)
++
+ # C (.c) files
+ # The C file is compiled and updated dependency information is generated.
+ # (See cmd_cc_o_c + relevant part of rule_cc_o_c)
diff --git a/queue-4.9/kbuild-clang-add-no-integrated-as-to-kbuild_flags.patch b/queue-4.9/kbuild-clang-add-no-integrated-as-to-kbuild_flags.patch
new file mode 100644 (file)
index 0000000..24249b6
--- /dev/null
@@ -0,0 +1,37 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Michael Davidson <md@google.com>
+Date: Tue, 25 Apr 2017 15:47:35 -0700
+Subject: kbuild: clang: add -no-integrated-as to KBUILD_[AC]FLAGS
+
+From: Michael Davidson <md@google.com>
+
+commit a37c45cd82e62a361706b9688a984a3a63957321 upstream.
+
+The Linux Kernel relies on GCC's acceptance of inline assembly as an
+opaque object which will not have any validation performed on the content.
+The current behaviour in LLVM is to perform validation of the contents by
+means of parsing the input if the MC layer can handle it.
+
+Disable clangs integrated assembler and use the GNU assembler instead.
+
+Wording-mostly-from: Saleem Abdulrasool <compnerd@compnerd.org>
+Signed-off-by: Michael Davidson <md@google.com>
+Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile |    2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/Makefile
++++ b/Makefile
+@@ -725,6 +725,8 @@ KBUILD_CFLAGS += $(call cc-disable-warni
+ # See modpost pattern 2
+ KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
+ KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
++KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
++KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
+ else
+ # These warnings generated too much noise in a regular build.
diff --git a/queue-4.9/kbuild-clang-disable-address-of-packed-member-warning.patch b/queue-4.9/kbuild-clang-disable-address-of-packed-member-warning.patch
new file mode 100644 (file)
index 0000000..4b01142
--- /dev/null
@@ -0,0 +1,32 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Matthias Kaehlcke <mka@chromium.org>
+Date: Fri, 21 Apr 2017 14:39:30 -0700
+Subject: kbuild: clang: Disable 'address-of-packed-member' warning
+
+From: Matthias Kaehlcke <mka@chromium.org>
+
+commit bfb38988c51e440fd7062ddf3157f7d8b1dd5d70 upstream.
+
+clang generates plenty of these warnings in different parts of the code,
+to an extent that the warnings are little more than noise. Disable the
+'address-of-packed-member' warning.
+
+Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
+Reviewed-by: Douglas Anderson <dianders@chromium.org>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/Makefile
++++ b/Makefile
+@@ -718,6 +718,7 @@ KBUILD_CPPFLAGS += $(call cc-option,-Qun
+ KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
+ KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
+ KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
++KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
+ # Quiet clang warning: comparison of unsigned expression < 0 is always false
+ KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
+ # CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
diff --git a/queue-4.9/kbuild-consolidate-header-generation-from-asm-offset-information.patch b/queue-4.9/kbuild-consolidate-header-generation-from-asm-offset-information.patch
new file mode 100644 (file)
index 0000000..bcb68b0
--- /dev/null
@@ -0,0 +1,166 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Matthias Kaehlcke <mka@chromium.org>
+Date: Wed, 12 Apr 2017 12:43:52 -0700
+Subject: kbuild: Consolidate header generation from ASM offset information
+
+From: Matthias Kaehlcke <mka@chromium.org>
+
+commit ebf003f0cfb3705e60d40dedc3ec949176c741af upstream.
+
+Largely redundant code is used in different places to generate C headers
+from offset information extracted from assembly language output.
+Consolidate the code in Makefile.lib and use this instead.
+
+Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Kbuild                    |   25 -------------------------
+ arch/ia64/kernel/Makefile |   26 ++------------------------
+ scripts/Makefile.lib      |   28 ++++++++++++++++++++++++++++
+ scripts/mod/Makefile      |   28 ++--------------------------
+ 4 files changed, 32 insertions(+), 75 deletions(-)
+
+--- a/Kbuild
++++ b/Kbuild
+@@ -7,31 +7,6 @@
+ # 4) Check for missing system calls
+ # 5) Generate constants.py (may need bounds.h)
+-# Default sed regexp - multiline due to syntax constraints
+-define sed-y
+-      "/^->/{s:->#\(.*\):/* \1 */:; \
+-      s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
+-      s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
+-      s:->::; p;}"
+-endef
+-
+-# Use filechk to avoid rebuilds when a header changes, but the resulting file
+-# does not
+-define filechk_offsets
+-      (set -e; \
+-       echo "#ifndef $2"; \
+-       echo "#define $2"; \
+-       echo "/*"; \
+-       echo " * DO NOT MODIFY."; \
+-       echo " *"; \
+-       echo " * This file was generated by Kbuild"; \
+-       echo " */"; \
+-       echo ""; \
+-       sed -ne $(sed-y); \
+-       echo ""; \
+-       echo "#endif" )
+-endef
+-
+ #####
+ # 1) Generate bounds.h
+--- a/arch/ia64/kernel/Makefile
++++ b/arch/ia64/kernel/Makefile
+@@ -50,32 +50,10 @@ CFLAGS_traps.o  += -mfixed-range=f2-f5,f
+ # The gate DSO image is built using a special linker script.
+ include $(src)/Makefile.gate
+-# Calculate NR_IRQ = max(IA64_NATIVE_NR_IRQS, XEN_NR_IRQS, ...) based on config
+-define sed-y
+-      "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"
+-endef
+-quiet_cmd_nr_irqs = GEN     $@
+-define cmd_nr_irqs
+-      (set -e; \
+-       echo "#ifndef __ASM_NR_IRQS_H__"; \
+-       echo "#define __ASM_NR_IRQS_H__"; \
+-       echo "/*"; \
+-       echo " * DO NOT MODIFY."; \
+-       echo " *"; \
+-       echo " * This file was generated by Kbuild"; \
+-       echo " *"; \
+-       echo " */"; \
+-       echo ""; \
+-       sed -ne $(sed-y) $<; \
+-       echo ""; \
+-       echo "#endif" ) > $@
+-endef
+-
+ # We use internal kbuild rules to avoid the "is up to date" message from make
+ arch/$(SRCARCH)/kernel/nr-irqs.s: arch/$(SRCARCH)/kernel/nr-irqs.c
+       $(Q)mkdir -p $(dir $@)
+       $(call if_changed_dep,cc_s_c)
+-include/generated/nr-irqs.h: arch/$(SRCARCH)/kernel/nr-irqs.s
+-      $(Q)mkdir -p $(dir $@)
+-      $(call cmd,nr_irqs)
++include/generated/nr-irqs.h: arch/$(SRCARCH)/kernel/nr-irqs.s FORCE
++      $(call filechk,offsets,__ASM_NR_IRQS_H__)
+--- a/scripts/Makefile.lib
++++ b/scripts/Makefile.lib
+@@ -408,3 +408,31 @@ quiet_cmd_xzmisc = XZMISC  $@
+ cmd_xzmisc = (cat $(filter-out FORCE,$^) | \
+       xz --check=crc32 --lzma2=dict=1MiB) > $@ || \
+       (rm -f $@ ; false)
++
++# ASM offsets
++# ---------------------------------------------------------------------------
++
++# Default sed regexp - multiline due to syntax constraints
++define sed-offsets
++      "/^->/{s:->#\(.*\):/* \1 */:; \
++      s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
++      s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
++      s:->::; p;}"
++endef
++
++# Use filechk to avoid rebuilds when a header changes, but the resulting file
++# does not
++define filechk_offsets
++      (set -e; \
++       echo "#ifndef $2"; \
++       echo "#define $2"; \
++       echo "/*"; \
++       echo " * DO NOT MODIFY."; \
++       echo " *"; \
++       echo " * This file was generated by Kbuild"; \
++       echo " */"; \
++       echo ""; \
++       sed -ne $(sed-offsets); \
++       echo ""; \
++       echo "#endif" )
++endef
+--- a/scripts/mod/Makefile
++++ b/scripts/mod/Makefile
+@@ -7,32 +7,8 @@ modpost-objs  := modpost.o file2alias.o s
+ devicetable-offsets-file := devicetable-offsets.h
+-define sed-y
+-      "/^->/{s:->#\(.*\):/* \1 */:; \
+-      s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
+-      s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
+-      s:->::; p;}"
+-endef
+-
+-quiet_cmd_offsets = GEN     $@
+-define cmd_offsets
+-      (set -e; \
+-       echo "#ifndef __DEVICETABLE_OFFSETS_H__"; \
+-       echo "#define __DEVICETABLE_OFFSETS_H__"; \
+-       echo "/*"; \
+-       echo " * DO NOT MODIFY."; \
+-       echo " *"; \
+-       echo " * This file was generated by Kbuild"; \
+-       echo " *"; \
+-       echo " */"; \
+-       echo ""; \
+-       sed -ne $(sed-y) $<; \
+-       echo ""; \
+-       echo "#endif" ) > $@
+-endef
+-
+-$(obj)/$(devicetable-offsets-file): $(obj)/devicetable-offsets.s
+-      $(call if_changed,offsets)
++$(obj)/$(devicetable-offsets-file): $(obj)/devicetable-offsets.s FORCE
++      $(call filechk,offsets,__DEVICETABLE_OFFSETS_H__)
+ targets += $(devicetable-offsets-file) devicetable-offsets.s
diff --git a/queue-4.9/kbuild-consolidate-redundant-sed-script-asm-offset-generation.patch b/queue-4.9/kbuild-consolidate-redundant-sed-script-asm-offset-generation.patch
new file mode 100644 (file)
index 0000000..2cc062b
--- /dev/null
@@ -0,0 +1,49 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Masahiro Yamada <yamada.masahiro@socionext.com>
+Date: Fri, 21 Apr 2017 15:21:10 +0900
+Subject: kbuild: consolidate redundant sed script ASM offset generation
+
+From: Masahiro Yamada <yamada.masahiro@socionext.com>
+
+commit 7dd47b95b0f54f2057d40af6e66d477e3fe95d13 upstream.
+
+This part ended up in redundant code after touched by multiple
+people.
+
+[1] Commit 3234282f33b2 ("x86, asm: Fix CFI macro invocations to
+deal with shortcomings in gas") added parentheses for defined
+expressions to support old gas for x86.
+
+[2] Commit a22dcdb0032c ("x86, asm: Fix ancient-GAS workaround")
+split the pattern into two to avoid parentheses for non-numeric
+expressions.
+
+[3] Commit 95a2f6f72d37 ("Partially revert patch that encloses
+asm-offset.h numbers in brackets") removed parentheses from numeric
+expressions as well because parentheses in MN10300 assembly have a
+special meaning (pointer access).
+
+Apparently, there is a conflict between [1] and [3].  After all,
+[3] took precedence, and a long time has passed since then.
+
+Now, merge the two patterns again because the first one is covered
+by the other.
+
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ scripts/Makefile.lib |    1 -
+ 1 file changed, 1 deletion(-)
+
+--- a/scripts/Makefile.lib
++++ b/scripts/Makefile.lib
+@@ -415,7 +415,6 @@ cmd_xzmisc = (cat $(filter-out FORCE,$^)
+ # Default sed regexp - multiline due to syntax constraints
+ define sed-offsets
+       "/^->/{s:->#\(.*\):/* \1 */:; \
+-      s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
+       s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
+       s:->::; p;}"
+ endef
diff --git a/queue-4.9/kbuild-drop-wno-unknown-warning-option-from-clang-options.patch b/queue-4.9/kbuild-drop-wno-unknown-warning-option-from-clang-options.patch
new file mode 100644 (file)
index 0000000..96fcfb8
--- /dev/null
@@ -0,0 +1,48 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Masahiro Yamada <yamada.masahiro@socionext.com>
+Date: Thu, 13 Apr 2017 07:25:21 +0900
+Subject: kbuild: drop -Wno-unknown-warning-option from clang options
+
+From: Masahiro Yamada <yamada.masahiro@socionext.com>
+
+commit a0ae981eba8f07dbc74bce38fd3a462b69a5bc8e upstream.
+
+Since commit c3f0d0bc5b01 ("kbuild, LLVMLinux: Add -Werror to
+cc-option to support clang"), cc-option and friends work nicely
+for clang.
+
+However, -Wno-unknown-warning-option makes clang happy with any
+unknown warning options even if -Werror is specified.
+
+Once -Wno-unknown-warning-option is added, any succeeding call of
+cc-disable-warning is evaluated positive, then unknown warning
+options are accepted.  This should be dropped.
+
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile                   |    1 -
+ scripts/Makefile.extrawarn |    1 -
+ 2 files changed, 2 deletions(-)
+
+--- a/Makefile
++++ b/Makefile
+@@ -714,7 +714,6 @@ endif
+ KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
+ KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
+ KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
+-KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,)
+ KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
+ KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
+ KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
+--- a/scripts/Makefile.extrawarn
++++ b/scripts/Makefile.extrawarn
+@@ -64,7 +64,6 @@ ifeq ($(cc-name),clang)
+ KBUILD_CFLAGS += $(call cc-disable-warning, initializer-overrides)
+ KBUILD_CFLAGS += $(call cc-disable-warning, unused-value)
+ KBUILD_CFLAGS += $(call cc-disable-warning, format)
+-KBUILD_CFLAGS += $(call cc-disable-warning, unknown-warning-option)
+ KBUILD_CFLAGS += $(call cc-disable-warning, sign-compare)
+ KBUILD_CFLAGS += $(call cc-disable-warning, format-zero-length)
+ KBUILD_CFLAGS += $(call cc-disable-warning, uninitialized)
diff --git a/queue-4.9/kbuild-fix-asm-offset-generation-to-work-with-clang.patch b/queue-4.9/kbuild-fix-asm-offset-generation-to-work-with-clang.patch
new file mode 100644 (file)
index 0000000..adfc75b
--- /dev/null
@@ -0,0 +1,69 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Jeroen Hofstee <jeroen@myspectrum.nl>
+Date: Fri, 21 Apr 2017 15:21:11 +0900
+Subject: kbuild: fix asm-offset generation to work with clang
+
+From: Jeroen Hofstee <jeroen@myspectrum.nl>
+
+commit cf0c3e68aa81f992b0301f62e341b710d385bf68 upstream.
+
+KBuild abuses the asm statement to write to a file and
+clang chokes about these invalid asm statements. Hack it
+even more by fooling this is actual valid asm code.
+
+[masahiro:
+ Import Jeroen's work for U-Boot:
+ http://patchwork.ozlabs.org/patch/375026/
+ Tweak sed script a little to avoid garbage '#' for GCC case, like
+ #define NR_PAGEFLAGS 23 /* __NR_PAGEFLAGS       # */ ]
+
+Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
+Tested-by: Matthias Kaehlcke <mka@chromium.org>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ include/linux/kbuild.h |    6 +++---
+ scripts/Makefile.lib   |    8 ++++++--
+ 2 files changed, 9 insertions(+), 5 deletions(-)
+
+--- a/include/linux/kbuild.h
++++ b/include/linux/kbuild.h
+@@ -2,14 +2,14 @@
+ #define __LINUX_KBUILD_H
+ #define DEFINE(sym, val) \
+-        asm volatile("\n->" #sym " %0 " #val : : "i" (val))
++      asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
+-#define BLANK() asm volatile("\n->" : : )
++#define BLANK() asm volatile("\n.ascii \"->\"" : : )
+ #define OFFSET(sym, str, mem) \
+       DEFINE(sym, offsetof(struct str, mem))
+ #define COMMENT(x) \
+-      asm volatile("\n->#" x)
++      asm volatile("\n.ascii \"->#" x "\"")
+ #endif
+--- a/scripts/Makefile.lib
++++ b/scripts/Makefile.lib
+@@ -413,10 +413,14 @@ cmd_xzmisc = (cat $(filter-out FORCE,$^)
+ # ---------------------------------------------------------------------------
+ # Default sed regexp - multiline due to syntax constraints
++#
++# Use [:space:] because LLVM's integrated assembler inserts <tab> around
++# the .ascii directive whereas GCC keeps the <space> as-is.
+ define sed-offsets
+-      "/^->/{s:->#\(.*\):/* \1 */:; \
++      's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \
++      /^->/{s:->#\(.*\):/* \1 */:; \
+       s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
+-      s:->::; p;}"
++      s:->::; p;}'
+ endef
+ # Use filechk to avoid rebuilds when a header changes, but the resulting file
diff --git a/queue-4.9/kbuild-llvmlinux-add-werror-to-cc-option-to-support-clang.patch b/queue-4.9/kbuild-llvmlinux-add-werror-to-cc-option-to-support-clang.patch
new file mode 100644 (file)
index 0000000..b6089d5
--- /dev/null
@@ -0,0 +1,57 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Mark Charlebois <charlebm@gmail.com>
+Date: Fri, 31 Mar 2017 22:38:13 +0200
+Subject: kbuild, LLVMLinux: Add -Werror to cc-option to support clang
+
+From: Mark Charlebois <charlebm@gmail.com>
+
+commit c3f0d0bc5b01ad90c45276952802455750444b4f upstream.
+
+Clang will warn about unknown warnings but will not return false
+unless -Werror is set. GCC will return false if an unknown
+warning is passed.
+
+Adding -Werror make both compiler behave the same.
+
+[arnd: it turns out we need the same patch for testing whether -ffunction-sections
+       works right with gcc. I've build tested extensively with this patch
+       applied, so let's just merge this one now.]
+
+Signed-off-by: Mark Charlebois <charlebm@gmail.com>
+Signed-off-by: Behan Webster <behanw@converseincode.com>
+Reviewed-by: Jan-Simon Möller <dl9pf@gmx.de>
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Acked-by: Kees Cook <keescook@chromium.org>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ scripts/Kbuild.include |    6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/scripts/Kbuild.include
++++ b/scripts/Kbuild.include
+@@ -117,12 +117,12 @@ CC_OPTION_CFLAGS = $(filter-out $(GCC_PL
+ # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
+ cc-option = $(call try-run,\
+-      $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
++      $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
+ # cc-option-yn
+ # Usage: flag := $(call cc-option-yn,-march=winchip-c6)
+ cc-option-yn = $(call try-run,\
+-      $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
++      $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
+ # cc-option-align
+ # Prefix align with either -falign or -malign
+@@ -132,7 +132,7 @@ cc-option-align = $(subst -functions=0,,
+ # cc-disable-warning
+ # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
+ cc-disable-warning = $(call try-run,\
+-      $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
++      $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
+ # cc-name
+ # Expands to either gcc or clang
diff --git a/queue-4.9/kbuild-use-fshort-wchar-globally.patch b/queue-4.9/kbuild-use-fshort-wchar-globally.patch
new file mode 100644 (file)
index 0000000..78a0d2f
--- /dev/null
@@ -0,0 +1,62 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Arnd Bergmann <arnd@arndb.de>
+Date: Wed, 26 Jul 2017 15:36:23 +0200
+Subject: Kbuild: use -fshort-wchar globally
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+commit 8c97023cf0518f172b8cb7a9fffc28b89401abbf upstream.
+
+Commit 971a69db7dc0 ("Xen: don't warn about 2-byte wchar_t in efi")
+added the --no-wchar-size-warning to the Makefile to avoid this
+harmless warning:
+
+arm-linux-gnueabi-ld: warning: drivers/xen/efi.o uses 2-byte wchar_t yet the output is to use 4-byte wchar_t; use of wchar_t values across objects may fail
+
+Changing kbuild to use thin archives instead of recursive linking
+unfortunately brings the same warning back during the final link.
+
+The kernel does not use wchar_t string literals at this point, and
+xen does not use wchar_t at all (only efi_char16_t), so the flag
+has no effect, but as pointed out by Jan Beulich, adding a wchar_t
+string literal would be bad here.
+
+Since wchar_t is always defined as u16, independent of the toolchain
+default, always passing -fshort-wchar is correct and lets us
+remove the Xen specific hack along with fixing the warning.
+
+Link: https://patchwork.kernel.org/patch/9275217/
+Fixes: 971a69db7dc0 ("Xen: don't warn about 2-byte wchar_t in efi")
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Acked-by: David Vrabel <david.vrabel@citrix.com>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile             |    2 +-
+ drivers/xen/Makefile |    3 ---
+ 2 files changed, 1 insertion(+), 4 deletions(-)
+
+--- a/Makefile
++++ b/Makefile
+@@ -394,7 +394,7 @@ LINUXINCLUDE       += $(filter-out $(LINUXINCL
+ KBUILD_AFLAGS   := -D__ASSEMBLY__
+ KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
+-                 -fno-strict-aliasing -fno-common \
++                 -fno-strict-aliasing -fno-common -fshort-wchar \
+                  -Werror-implicit-function-declaration \
+                  -Wno-format-security \
+                  -std=gnu89
+--- a/drivers/xen/Makefile
++++ b/drivers/xen/Makefile
+@@ -7,9 +7,6 @@ obj-y  += xenbus/
+ nostackp := $(call cc-option, -fno-stack-protector)
+ CFLAGS_features.o                     := $(nostackp)
+-CFLAGS_efi.o                          += -fshort-wchar
+-LDFLAGS                                       += $(call ld-option, --no-wchar-size-warning)
+-
+ dom0-$(CONFIG_ARM64) += arm-device.o
+ dom0-$(CONFIG_PCI) += pci.o
+ dom0-$(CONFIG_USB_SUPPORT) += dbgp.o
diff --git a/queue-4.9/kbuild-use-oz-instead-of-os-when-using-clang.patch b/queue-4.9/kbuild-use-oz-instead-of-os-when-using-clang.patch
new file mode 100644 (file)
index 0000000..4aeeb1a
--- /dev/null
@@ -0,0 +1,32 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Behan Webster <behanw@converseincode.com>
+Date: Mon, 27 Mar 2017 18:19:09 -0700
+Subject: kbuild: use -Oz instead of -Os when using clang
+
+From: Behan Webster <behanw@converseincode.com>
+
+commit 6748cb3c299de1ffbe56733647b01dbcc398c419 upstream.
+
+This generates smaller resulting object code when compiled with clang.
+
+Signed-off-by: Behan Webster <behanw@converseincode.com>
+Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/Makefile
++++ b/Makefile
+@@ -644,7 +644,8 @@ KBUILD_CFLAGS      += $(call cc-option,-fdata
+ endif
+ ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
+-KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,)
++KBUILD_CFLAGS += $(call cc-option,-Oz,-Os)
++KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,)
+ else
+ ifdef CONFIG_PROFILE_ALL_BRANCHES
+ KBUILD_CFLAGS += -O2 $(call cc-disable-warning,maybe-uninitialized,)
diff --git a/queue-4.9/modules-mark-__inittest-__exittest-as-__maybe_unused.patch b/queue-4.9/modules-mark-__inittest-__exittest-as-__maybe_unused.patch
new file mode 100644 (file)
index 0000000..9045424
--- /dev/null
@@ -0,0 +1,45 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Arnd Bergmann <arnd@arndb.de>
+Date: Wed, 1 Feb 2017 18:00:14 +0100
+Subject: modules: mark __inittest/__exittest as __maybe_unused
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+commit 1f318a8bafcfba9f0d623f4870c4e890fd22e659 upstream.
+
+clang warns about unused inline functions by default:
+
+arch/arm/crypto/aes-cipher-glue.c:68:1: warning: unused function '__inittest' [-Wunused-function]
+arch/arm/crypto/aes-cipher-glue.c:69:1: warning: unused function '__exittest' [-Wunused-function]
+
+As these appear in every single module, let's just disable the warnings by marking the
+two functions as __maybe_unused.
+
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Reviewed-by: Miroslav Benes <mbenes@suse.cz>
+Acked-by: Rusty Russell <rusty@rustcorp.com.au>
+Signed-off-by: Jessica Yu <jeyu@redhat.com>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ include/linux/module.h |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/include/linux/module.h
++++ b/include/linux/module.h
+@@ -127,13 +127,13 @@ extern void cleanup_module(void);
+ /* Each module must use one module_init(). */
+ #define module_init(initfn)                                   \
+-      static inline initcall_t __inittest(void)               \
++      static inline initcall_t __maybe_unused __inittest(void)                \
+       { return initfn; }                                      \
+       int init_module(void) __attribute__((alias(#initfn)));
+ /* This is only required if you want to be unloadable. */
+ #define module_exit(exitfn)                                   \
+-      static inline exitcall_t __exittest(void)               \
++      static inline exitcall_t __maybe_unused __exittest(void)                \
+       { return exitfn; }                                      \
+       void cleanup_module(void) __attribute__((alias(#exitfn)));
index 536d4b073f146f59a99ab935f1756c1694a3a0d0..047e30c32626e8f85ecabe5184e6663a7577e7b8 100644 (file)
@@ -7,3 +7,29 @@ tg3-add-phy-reset-for-5717-5719-5720-in-change-ring-and-flow-control-paths.patch
 usbnet-smsc95xx-disable-carrier-check-while-suspending.patch
 inet-frags-better-deal-with-smp-races.patch
 ipv6-fix-pmtu-updates-for-udp-raw-sockets-in-presence-of-vrf.patch
+kbuild-add-better-clang-cross-build-support.patch
+kbuild-clang-add-no-integrated-as-to-kbuild_flags.patch
+kbuild-consolidate-header-generation-from-asm-offset-information.patch
+kbuild-consolidate-redundant-sed-script-asm-offset-generation.patch
+kbuild-fix-asm-offset-generation-to-work-with-clang.patch
+kbuild-drop-wno-unknown-warning-option-from-clang-options.patch
+kbuild-llvmlinux-add-werror-to-cc-option-to-support-clang.patch
+kbuild-use-oz-instead-of-os-when-using-clang.patch
+kbuild-add-support-to-generate-llvm-assembly-files.patch
+modules-mark-__inittest-__exittest-as-__maybe_unused.patch
+x86-kbuild-use-cc-option-to-enable-falign-jumps-loops.patch
+crypto-x86-aesni-fix-token-pasting-for-clang.patch
+kbuild-add-__cc-option-macro.patch
+x86-build-use-__cc-option-for-boot-code-compiler-options.patch
+x86-build-specify-stack-alignment-for-clang.patch
+kbuild-clang-disable-address-of-packed-member-warning.patch
+crypto-arm64-sha-avoid-non-standard-inline-asm-tricks.patch
+x86-boot-undef-memcpy-et-al-in-string.c.patch
+efi-libstub-arm64-use-hidden-attribute-for-struct-screen_info-reference.patch
+efi-libstub-arm64-force-hidden-visibility-for-section-markers.patch
+efi-libstub-preserve-.debug-sections-after-absolute-relocation-check.patch
+efi-libstub-arm64-set-fpie-when-building-the-efi-stub.patch
+x86-build-fix-stack-alignment-for-clang.patch
+x86-build-use-cc-option-to-validate-stack-alignment-parameter.patch
+kbuild-use-fshort-wchar-globally.patch
+arm64-uaccess-suppress-spurious-clang-warning.patch
diff --git a/queue-4.9/x86-boot-undef-memcpy-et-al-in-string.c.patch b/queue-4.9/x86-boot-undef-memcpy-et-al-in-string.c.patch
new file mode 100644 (file)
index 0000000..ed84a5e
--- /dev/null
@@ -0,0 +1,57 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Michael Davidson <md@google.com>
+Date: Mon, 24 Jul 2017 16:51:55 -0700
+Subject: x86/boot: #undef memcpy() et al in string.c
+
+From: Michael Davidson <md@google.com>
+
+commit 18d5e6c34a8eda438d5ad8b3b15f42dab01bf05d upstream.
+
+undef memcpy() and friends in boot/string.c so that the functions
+defined here will have the correct names, otherwise we end up
+up trying to redefine __builtin_memcpy() etc.
+
+Surprisingly, GCC allows this (and, helpfully, discards the
+__builtin_ prefix from the function name when compiling it),
+but clang does not.
+
+Adding these #undef's appears to preserve what I assume was
+the original intent of the code.
+
+Signed-off-by: Michael Davidson <md@google.com>
+Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
+Acked-by: H. Peter Anvin <hpa@zytor.com>
+Cc: Arnd Bergmann <arnd@arndb.de>
+Cc: Bernhard.Rosenkranzer@linaro.org
+Cc: Greg Hackmann <ghackmann@google.com>
+Cc: Kees Cook <keescook@chromium.org>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Nick Desaulniers <ndesaulniers@google.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Link: http://lkml.kernel.org/r/20170724235155.79255-1-mka@chromium.org
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/boot/string.c |    9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+--- a/arch/x86/boot/string.c
++++ b/arch/x86/boot/string.c
+@@ -16,6 +16,15 @@
+ #include "ctype.h"
+ #include "string.h"
++/*
++ * Undef these macros so that the functions that we provide
++ * here will have the correct names regardless of how string.h
++ * may have chosen to #define them.
++ */
++#undef memcpy
++#undef memset
++#undef memcmp
++
+ int memcmp(const void *s1, const void *s2, size_t len)
+ {
+       bool diff;
diff --git a/queue-4.9/x86-build-fix-stack-alignment-for-clang.patch b/queue-4.9/x86-build-fix-stack-alignment-for-clang.patch
new file mode 100644 (file)
index 0000000..f493497
--- /dev/null
@@ -0,0 +1,97 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Matthias Kaehlcke <mka@chromium.org>
+Date: Wed, 16 Aug 2017 17:47:40 -0700
+Subject: x86/build: Fix stack alignment for CLang
+
+From: Matthias Kaehlcke <mka@chromium.org>
+
+commit 8f91869766c00622b2eaa8ee567db4f333b78c1a upstream.
+
+Commit:
+
+  d77698df39a5 ("x86/build: Specify stack alignment for clang")
+
+intended to use the same stack alignment for clang as with gcc.
+
+The two compilers use different options to configure the stack alignment
+(gcc: -mpreferred-stack-boundary=n, clang: -mstack-alignment=n).
+
+The above commit assumes that the clang option uses the same parameter
+type as gcc, i.e. that the alignment is specified as 2^n. However clang
+interprets the value of this option literally to use an alignment of n,
+in consequence the stack remains misaligned.
+
+Change the values used with -mstack-alignment to be the actual alignment
+instead of a power of two.
+
+cc-option isn't used here with the typical pattern of KBUILD_CFLAGS +=
+$(call cc-option ...). The reason is that older gcc versions don't
+support the -mpreferred-stack-boundary option, since cc-option doesn't
+verify whether the alternative option is valid it would incorrectly
+select the clang option -mstack-alignment..
+
+Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
+Cc: Arnd Bergmann <arnd@arndb.de>
+Cc: Bernhard.Rosenkranzer@linaro.org
+Cc: Greg Hackmann <ghackmann@google.com>
+Cc: Kees Cook <keescook@chromium.org>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
+Cc: Michael Davidson <md@google.com>
+Cc: Nick Desaulniers <ndesaulniers@google.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Stephen Hines <srhines@google.com>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: dianders@chromium.org
+Link: http://lkml.kernel.org/r/20170817004740.170588-1-mka@chromium.org
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/Makefile |   14 ++++++++------
+ 1 file changed, 8 insertions(+), 6 deletions(-)
+
+--- a/arch/x86/Makefile
++++ b/arch/x86/Makefile
+@@ -14,9 +14,11 @@ endif
+ # For gcc stack alignment is specified with -mpreferred-stack-boundary,
+ # clang has the option -mstack-alignment for that purpose.
+ ifneq ($(call cc-option, -mpreferred-stack-boundary=4),)
+-        cc_stack_align_opt := -mpreferred-stack-boundary
+-else ifneq ($(call cc-option, -mstack-alignment=4),)
+-        cc_stack_align_opt := -mstack-alignment
++      cc_stack_align4 := -mpreferred-stack-boundary=2
++      cc_stack_align8 := -mpreferred-stack-boundary=3
++else ifneq ($(call cc-option, -mstack-alignment=16),)
++      cc_stack_align4 := -mstack-alignment=4
++      cc_stack_align8 := -mstack-alignment=8
+ endif
+ # How to compile the 16-bit code.  Note we always compile for -march=i386;
+@@ -36,7 +38,7 @@ REALMODE_CFLAGS      := $(M16_CFLAGS) -g -Os
+ REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding)
+ REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector)
+-REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align_opt)=2)
++REALMODE_CFLAGS += $(cc_stack_align4)
+ export REALMODE_CFLAGS
+ # BITS is used as extension for files which are available in a 32 bit
+@@ -76,7 +78,7 @@ ifeq ($(CONFIG_X86_32),y)
+         # Align the stack to the register width instead of using the default
+         # alignment of 16 bytes. This reduces stack usage and the number of
+         # alignment instructions.
+-        KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align_opt)=2)
++        KBUILD_CFLAGS += $(cc_stack_align4)
+         # Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
+         # a lot more stack due to the lack of sharing of stacklots:
+@@ -115,7 +117,7 @@ else
+         # default alignment which keep the stack *mis*aligned.
+         # Furthermore an alignment to the register width reduces stack usage
+         # and the number of alignment instructions.
+-        KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align_opt)=3)
++        KBUILD_CFLAGS += $(cc_stack_align8)
+       # Use -mskip-rax-setup if supported.
+       KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)
diff --git a/queue-4.9/x86-build-specify-stack-alignment-for-clang.patch b/queue-4.9/x86-build-specify-stack-alignment-for-clang.patch
new file mode 100644 (file)
index 0000000..26e0b14
--- /dev/null
@@ -0,0 +1,85 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Matthias Kaehlcke <mka@chromium.org>
+Date: Wed, 21 Jun 2017 16:28:05 -0700
+Subject: x86/build: Specify stack alignment for clang
+
+From: Matthias Kaehlcke <mka@chromium.org>
+
+commit d77698df39a512911586834d303275ea5fda74d0 upstream.
+
+For gcc stack alignment is configured with -mpreferred-stack-boundary=N,
+clang has the option -mstack-alignment=N for that purpose. Use the same
+alignment as with gcc.
+
+If the alignment is not specified clang assumes an alignment of
+16 bytes, as required by the standard ABI. However as mentioned in
+d9b0cde91c60 ("x86-64, gcc: Use -mpreferred-stack-boundary=3 if
+supported") the standard kernel entry on x86-64 leaves the stack
+on an 8-byte boundary, as a consequence clang will keep the stack
+misaligned.
+
+Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
+Acked-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/Makefile |   26 +++++++++++++++++++++-----
+ 1 file changed, 21 insertions(+), 5 deletions(-)
+
+--- a/arch/x86/Makefile
++++ b/arch/x86/Makefile
+@@ -11,6 +11,14 @@ else
+         KBUILD_DEFCONFIG := $(ARCH)_defconfig
+ endif
++# For gcc stack alignment is specified with -mpreferred-stack-boundary,
++# clang has the option -mstack-alignment for that purpose.
++ifneq ($(call cc-option, -mpreferred-stack-boundary=4),)
++        cc_stack_align_opt := -mpreferred-stack-boundary
++else ifneq ($(call cc-option, -mstack-alignment=4),)
++        cc_stack_align_opt := -mstack-alignment
++endif
++
+ # How to compile the 16-bit code.  Note we always compile for -march=i386;
+ # that way we can complain to the user if the CPU is insufficient.
+ #
+@@ -28,7 +36,7 @@ REALMODE_CFLAGS      := $(M16_CFLAGS) -g -Os
+ REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding)
+ REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector)
+-REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -mpreferred-stack-boundary=2)
++REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align_opt)=2)
+ export REALMODE_CFLAGS
+ # BITS is used as extension for files which are available in a 32 bit
+@@ -65,8 +73,10 @@ ifeq ($(CONFIG_X86_32),y)
+         # with nonstandard options
+         KBUILD_CFLAGS += -fno-pic
+-        # prevent gcc from keeping the stack 16 byte aligned
+-        KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2)
++        # Align the stack to the register width instead of using the default
++        # alignment of 16 bytes. This reduces stack usage and the number of
++        # alignment instructions.
++        KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align_opt)=2)
+         # Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
+         # a lot more stack due to the lack of sharing of stacklots:
+@@ -98,8 +108,14 @@ else
+         KBUILD_CFLAGS += $(call cc-option,-mno-80387)
+         KBUILD_CFLAGS += $(call cc-option,-mno-fp-ret-in-387)
+-      # Use -mpreferred-stack-boundary=3 if supported.
+-      KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=3)
++        # By default gcc and clang use a stack alignment of 16 bytes for x86.
++        # However the standard kernel entry on x86-64 leaves the stack on an
++        # 8-byte boundary. If the compiler isn't informed about the actual
++        # alignment it will generate extra alignment instructions for the
++        # default alignment which keep the stack *mis*aligned.
++        # Furthermore an alignment to the register width reduces stack usage
++        # and the number of alignment instructions.
++        KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align_opt)=3)
+       # Use -mskip-rax-setup if supported.
+       KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)
diff --git a/queue-4.9/x86-build-use-__cc-option-for-boot-code-compiler-options.patch b/queue-4.9/x86-build-use-__cc-option-for-boot-code-compiler-options.patch
new file mode 100644 (file)
index 0000000..fb53c13
--- /dev/null
@@ -0,0 +1,53 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Matthias Kaehlcke <mka@chromium.org>
+Date: Wed, 21 Jun 2017 16:28:04 -0700
+Subject: x86/build: Use __cc-option for boot code compiler options
+
+From: Matthias Kaehlcke <mka@chromium.org>
+
+commit 032a2c4f65a2f81c93e161a11197ba19bc14a909 upstream.
+
+cc-option is used to enable compiler options for the boot code if they
+are available. The macro uses KBUILD_CFLAGS and KBUILD_CPPFLAGS for the
+check, however these flags aren't used to build the boot code, in
+consequence cc-option can yield wrong results. For example
+-mpreferred-stack-boundary=2 is never set with a 64-bit compiler,
+since the setting is only valid for 16 and 32-bit binaries. This
+is also the case for 32-bit kernel builds, because the option -m32 is
+added to KBUILD_CFLAGS after the assignment of REALMODE_CFLAGS.
+
+Use __cc-option instead of cc-option for the boot mode options.
+The macro receives the compiler options as parameter instead of using
+KBUILD_C*FLAGS, for the boot code we pass REALMODE_CFLAGS.
+
+Also use separate statements for the __cc-option checks instead
+of performing them in the initial assignment of REALMODE_CFLAGS since
+the variable is an input of the macro.
+
+Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
+Acked-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/Makefile |    9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+--- a/arch/x86/Makefile
++++ b/arch/x86/Makefile
+@@ -24,10 +24,11 @@ REALMODE_CFLAGS    := $(M16_CFLAGS) -g -Os
+                  -DDISABLE_BRANCH_PROFILING \
+                  -Wall -Wstrict-prototypes -march=i386 -mregparm=3 \
+                  -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
+-                 -mno-mmx -mno-sse \
+-                 $(call cc-option, -ffreestanding) \
+-                 $(call cc-option, -fno-stack-protector) \
+-                 $(call cc-option, -mpreferred-stack-boundary=2)
++                 -mno-mmx -mno-sse
++
++REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding)
++REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector)
++REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -mpreferred-stack-boundary=2)
+ export REALMODE_CFLAGS
+ # BITS is used as extension for files which are available in a 32 bit
diff --git a/queue-4.9/x86-build-use-cc-option-to-validate-stack-alignment-parameter.patch b/queue-4.9/x86-build-use-cc-option-to-validate-stack-alignment-parameter.patch
new file mode 100644 (file)
index 0000000..60581a7
--- /dev/null
@@ -0,0 +1,75 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Matthias Kaehlcke <mka@chromium.org>
+Date: Thu, 17 Aug 2017 11:20:47 -0700
+Subject: x86/build: Use cc-option to validate stack alignment parameter
+
+From: Matthias Kaehlcke <mka@chromium.org>
+
+commit 9e8730b178a2472fca3123e909d6e69cc8127778 upstream.
+
+With the following commit:
+
+  8f91869766c0 ("x86/build: Fix stack alignment for CLang")
+
+cc-option is only used to determine the name of the stack alignment option
+supported by the compiler, but not to verify that the actual parameter
+<option>=N is valid in combination with the other CFLAGS.
+
+This causes problems (as reported by the kbuild robot) with older GCC versions
+which only support stack alignment on a boundary of 16 bytes or higher.
+
+Also use (__)cc_option to add the stack alignment option to CFLAGS to
+make sure only valid options are added.
+
+Reported-by: kbuild test robot <fengguang.wu@intel.com>
+Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
+Cc: Arnd Bergmann <arnd@arndb.de>
+Cc: Bernhard.Rosenkranzer@linaro.org
+Cc: Greg Hackmann <ghackmann@google.com>
+Cc: Kees Cook <keescook@chromium.org>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
+Cc: Michael Davidson <md@google.com>
+Cc: Nick Desaulniers <ndesaulniers@google.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Stephen Hines <srhines@google.com>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: dianders@chromium.org
+Fixes: 8f91869766c0 ("x86/build: Fix stack alignment for CLang")
+Link: http://lkml.kernel.org/r/20170817182047.176752-1-mka@chromium.org
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/Makefile |    6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/arch/x86/Makefile
++++ b/arch/x86/Makefile
+@@ -38,7 +38,7 @@ REALMODE_CFLAGS      := $(M16_CFLAGS) -g -Os
+ REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding)
+ REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector)
+-REALMODE_CFLAGS += $(cc_stack_align4)
++REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align4))
+ export REALMODE_CFLAGS
+ # BITS is used as extension for files which are available in a 32 bit
+@@ -78,7 +78,7 @@ ifeq ($(CONFIG_X86_32),y)
+         # Align the stack to the register width instead of using the default
+         # alignment of 16 bytes. This reduces stack usage and the number of
+         # alignment instructions.
+-        KBUILD_CFLAGS += $(cc_stack_align4)
++        KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align4))
+         # Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
+         # a lot more stack due to the lack of sharing of stacklots:
+@@ -117,7 +117,7 @@ else
+         # default alignment which keep the stack *mis*aligned.
+         # Furthermore an alignment to the register width reduces stack usage
+         # and the number of alignment instructions.
+-        KBUILD_CFLAGS += $(cc_stack_align8)
++        KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align8))
+       # Use -mskip-rax-setup if supported.
+       KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)
diff --git a/queue-4.9/x86-kbuild-use-cc-option-to-enable-falign-jumps-loops.patch b/queue-4.9/x86-kbuild-use-cc-option-to-enable-falign-jumps-loops.patch
new file mode 100644 (file)
index 0000000..139e6f9
--- /dev/null
@@ -0,0 +1,43 @@
+From foo@baz Wed Nov 21 18:50:25 CET 2018
+From: Matthias Kaehlcke <mka@chromium.org>
+Date: Thu, 13 Apr 2017 10:26:09 -0700
+Subject: x86/kbuild: Use cc-option to enable -falign-{jumps/loops}
+
+From: Matthias Kaehlcke <mka@chromium.org>
+
+commit 2c4fd1ac3ff167c91272dc43c7bfd2269ef61557 upstream.
+
+clang currently does not support these optimizations, only enable them
+when they are available.
+
+Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
+Cc: Greg Hackmann <ghackmann@google.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
+Cc: Michael Davidson <md@google.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: grundler@chromium.org
+Link: http://lkml.kernel.org/r/20170413172609.118122-1-mka@chromium.org
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/Makefile |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/arch/x86/Makefile
++++ b/arch/x86/Makefile
+@@ -88,10 +88,10 @@ else
+         KBUILD_CFLAGS += -m64
+         # Align jump targets to 1 byte, not the default 16 bytes:
+-        KBUILD_CFLAGS += -falign-jumps=1
++        KBUILD_CFLAGS += $(call cc-option,-falign-jumps=1)
+         # Pack loops tightly as well:
+-        KBUILD_CFLAGS += -falign-loops=1
++        KBUILD_CFLAGS += $(call cc-option,-falign-loops=1)
+         # Don't autogenerate traditional x87 instructions
+         KBUILD_CFLAGS += $(call cc-option,-mno-80387)