]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Nov 2018 17:55:42 +0000 (18:55 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Nov 2018 17:55:42 +0000 (18:55 +0100)
added patches:
arm64-disable-asm-operand-width-warning-for-clang.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
kbuild-add-__cc-option-macro.patch
kbuild-add-better-clang-cross-build-support.patch
kbuild-add-support-to-generate-llvm-assembly-files.patch
kbuild-allow-to-use-gcc-toolchain-not-in-clang-search-path.patch
kbuild-clang-add-no-integrated-as-to-kbuild_flags.patch
kbuild-clang-disable-address-of-packed-member-warning.patch
kbuild-clang-disable-unused-variable-warnings-only-when-constant.patch
kbuild-clang-fix-build-failures-with-sparse-check.patch
kbuild-clang-remove-crufty-hostcflags.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-fix-linker-feature-test-macros-when-cross-compiling-with-clang.patch
kbuild-llvmlinux-add-werror-to-cc-option-to-support-clang.patch
kbuild-move-cc-option-and-cc-disable-warning-after-incl.-arch-makefile.patch
kbuild-set-kbuild_cflags-before-incl.-arch-makefile.patch
kbuild-set-no-integrated-as-before-incl.-arch-makefile.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
x86-mm-kaslr-use-the-_asm_mul-macro-for-multiplication-to-work-around-clang-incompatibility.patch

33 files changed:
queue-4.4/arm64-disable-asm-operand-width-warning-for-clang.patch [new file with mode: 0644]
queue-4.4/crypto-arm64-sha-avoid-non-standard-inline-asm-tricks.patch [new file with mode: 0644]
queue-4.4/crypto-x86-aesni-fix-token-pasting-for-clang.patch [new file with mode: 0644]
queue-4.4/efi-libstub-arm64-force-hidden-visibility-for-section-markers.patch [new file with mode: 0644]
queue-4.4/efi-libstub-arm64-set-fpie-when-building-the-efi-stub.patch [new file with mode: 0644]
queue-4.4/kbuild-add-__cc-option-macro.patch [new file with mode: 0644]
queue-4.4/kbuild-add-better-clang-cross-build-support.patch [new file with mode: 0644]
queue-4.4/kbuild-add-support-to-generate-llvm-assembly-files.patch [new file with mode: 0644]
queue-4.4/kbuild-allow-to-use-gcc-toolchain-not-in-clang-search-path.patch [new file with mode: 0644]
queue-4.4/kbuild-clang-add-no-integrated-as-to-kbuild_flags.patch [new file with mode: 0644]
queue-4.4/kbuild-clang-disable-address-of-packed-member-warning.patch [new file with mode: 0644]
queue-4.4/kbuild-clang-disable-unused-variable-warnings-only-when-constant.patch [new file with mode: 0644]
queue-4.4/kbuild-clang-fix-build-failures-with-sparse-check.patch [new file with mode: 0644]
queue-4.4/kbuild-clang-remove-crufty-hostcflags.patch [new file with mode: 0644]
queue-4.4/kbuild-consolidate-header-generation-from-asm-offset-information.patch [new file with mode: 0644]
queue-4.4/kbuild-consolidate-redundant-sed-script-asm-offset-generation.patch [new file with mode: 0644]
queue-4.4/kbuild-drop-wno-unknown-warning-option-from-clang-options.patch [new file with mode: 0644]
queue-4.4/kbuild-fix-asm-offset-generation-to-work-with-clang.patch [new file with mode: 0644]
queue-4.4/kbuild-fix-linker-feature-test-macros-when-cross-compiling-with-clang.patch [new file with mode: 0644]
queue-4.4/kbuild-llvmlinux-add-werror-to-cc-option-to-support-clang.patch [new file with mode: 0644]
queue-4.4/kbuild-move-cc-option-and-cc-disable-warning-after-incl.-arch-makefile.patch [new file with mode: 0644]
queue-4.4/kbuild-set-kbuild_cflags-before-incl.-arch-makefile.patch [new file with mode: 0644]
queue-4.4/kbuild-set-no-integrated-as-before-incl.-arch-makefile.patch [new file with mode: 0644]
queue-4.4/kbuild-use-oz-instead-of-os-when-using-clang.patch [new file with mode: 0644]
queue-4.4/modules-mark-__inittest-__exittest-as-__maybe_unused.patch [new file with mode: 0644]
queue-4.4/series
queue-4.4/x86-boot-undef-memcpy-et-al-in-string.c.patch [new file with mode: 0644]
queue-4.4/x86-build-fix-stack-alignment-for-clang.patch [new file with mode: 0644]
queue-4.4/x86-build-specify-stack-alignment-for-clang.patch [new file with mode: 0644]
queue-4.4/x86-build-use-__cc-option-for-boot-code-compiler-options.patch [new file with mode: 0644]
queue-4.4/x86-build-use-cc-option-to-validate-stack-alignment-parameter.patch [new file with mode: 0644]
queue-4.4/x86-kbuild-use-cc-option-to-enable-falign-jumps-loops.patch [new file with mode: 0644]
queue-4.4/x86-mm-kaslr-use-the-_asm_mul-macro-for-multiplication-to-work-around-clang-incompatibility.patch [new file with mode: 0644]

diff --git a/queue-4.4/arm64-disable-asm-operand-width-warning-for-clang.patch b/queue-4.4/arm64-disable-asm-operand-width-warning-for-clang.patch
new file mode 100644 (file)
index 0000000..b6f2a56
--- /dev/null
@@ -0,0 +1,41 @@
+From foo@baz Wed Nov 21 18:50:39 CET 2018
+From: Matthias Kaehlcke <mka@chromium.org>
+Date: Fri, 21 Apr 2017 16:00:56 -0700
+Subject: arm64: Disable asm-operand-width warning for clang
+
+From: Matthias Kaehlcke <mka@chromium.org>
+
+clang raises 'asm-operand-widths' warnings in inline assembly code when
+the size of an operand is < 64 bits and the operand width is unspecified.
+Most warnings are raised in macros, i.e. the datatype of the operand may
+vary.
+
+Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
+
+nc: I trimmed the original commit message since I'm not a part of CrOS
+    and can't speak on their behalf.
+
+    To fix these warnings, it requires a fairly intrusive backport of
+    the sysreg conversion that Mark Rutland did in 4.9. I think
+    disabling the warning is smarter, similar to commit d41d0fe374d4
+    ("turn off -Wattribute-alias") in this tree.
+
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/arm64/Makefile |    4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/arch/arm64/Makefile
++++ b/arch/arm64/Makefile
+@@ -56,6 +56,10 @@ else
+ TEXT_OFFSET := 0x00080000
+ endif
++ifeq ($(cc-name),clang)
++KBUILD_CFLAGS += $(call cc-disable-warning, asm-operand-widths)
++endif
++
+ # KASAN_SHADOW_OFFSET = VA_START + (1 << (VA_BITS - 3)) - (1 << 61)
+ # in 32-bit arithmetic
+ KASAN_SHADOW_OFFSET := $(shell printf "0x%08x00000000\n" $$(( \
diff --git a/queue-4.4/crypto-arm64-sha-avoid-non-standard-inline-asm-tricks.patch b/queue-4.4/crypto-arm64-sha-avoid-non-standard-inline-asm-tricks.patch
new file mode 100644 (file)
index 0000000..f575392
--- /dev/null
@@ -0,0 +1,140 @@
+From foo@baz Wed Nov 21 18:50:39 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: Nathan Chancellor <natechancellor@gmail.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.4/crypto-x86-aesni-fix-token-pasting-for-clang.patch b/queue-4.4/crypto-x86-aesni-fix-token-pasting-for-clang.patch
new file mode 100644 (file)
index 0000000..7c26320
--- /dev/null
@@ -0,0 +1,63 @@
+From foo@baz Wed Nov 21 18:50:39 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: Nathan Chancellor <natechancellor@gmail.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.4/efi-libstub-arm64-force-hidden-visibility-for-section-markers.patch b/queue-4.4/efi-libstub-arm64-force-hidden-visibility-for-section-markers.patch
new file mode 100644 (file)
index 0000000..a51adc6
--- /dev/null
@@ -0,0 +1,50 @@
+From foo@baz Wed Nov 21 18:50:39 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>
+[nc: Fix conflict due to lack of commit 42b55734030c1 in linux-4.4.y]
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.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>
+ efi_status_t __init handle_kernel_image(efi_system_table_t *sys_table_arg,
+                                       unsigned long *image_addr,
diff --git a/queue-4.4/efi-libstub-arm64-set-fpie-when-building-the-efi-stub.patch b/queue-4.4/efi-libstub-arm64-set-fpie-when-building-the-efi-stub.patch
new file mode 100644 (file)
index 0000000..24bd34d
--- /dev/null
@@ -0,0 +1,49 @@
+From foo@baz Wed Nov 21 18:50:39 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: Nathan Chancellor <natechancellor@gmail.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 -DDISABLE_BRANCH_PROFILING
+-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.4/kbuild-add-__cc-option-macro.patch b/queue-4.4/kbuild-add-__cc-option-macro.patch
new file mode 100644 (file)
index 0000000..da52c6d
--- /dev/null
@@ -0,0 +1,69 @@
+From foo@baz Wed Nov 21 18:50:39 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>
+[nc: Fix conflicts due to lack of CC_OPTION_CFLAGS and hostcc-option
+     wasn't added until v4.8 so no point including it in this tree]
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile               |    2 +-
+ scripts/Kbuild.include |    9 +++++++--
+ 2 files changed, 8 insertions(+), 3 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
+ # Decide whether to build built-in, modular, or both.
+--- a/scripts/Kbuild.include
++++ b/scripts/Kbuild.include
+@@ -108,11 +108,16 @@ 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))
++
+ # cc-option
+ # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
+-cc-option = $(call try-run,\
+-      $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
++cc-option = $(call __cc-option, $(CC),\
++      $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS),$(1),$(2))
+ # cc-option-yn
+ # Usage: flag := $(call cc-option-yn,-march=winchip-c6)
diff --git a/queue-4.4/kbuild-add-better-clang-cross-build-support.patch b/queue-4.4/kbuild-add-better-clang-cross-build-support.patch
new file mode 100644 (file)
index 0000000..c45d6e0
--- /dev/null
@@ -0,0 +1,48 @@
+From foo@baz Wed Nov 21 18:50:39 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: Nathan Chancellor <natechancellor@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile |    9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+--- a/Makefile
++++ b/Makefile
+@@ -698,6 +698,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.4/kbuild-add-support-to-generate-llvm-assembly-files.patch b/queue-4.4/kbuild-add-support-to-generate-llvm-assembly-files.patch
new file mode 100644 (file)
index 0000000..aabc5d2
--- /dev/null
@@ -0,0 +1,83 @@
+From foo@baz Wed Nov 21 18:50:39 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>
+[nc: Fix conflicts due to lack of commit 6b90bd4ba40b3 in linux-4.4.y]
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.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
+@@ -1307,6 +1307,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'
+@@ -1482,6 +1484,7 @@ clean: $(clean-dirs)
+               -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
+               -o -name '*.symtypes' -o -name 'modules.order' \
+               -o -name modules.builtin -o -name '.tmp_*.o.*' \
++              -o -name '*.ll' \
+               -o -name '*.gcno' \) -type f -print | xargs rm -f
+ # Generate tags for editors
+@@ -1585,6 +1588,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
+@@ -175,6 +175,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.4/kbuild-allow-to-use-gcc-toolchain-not-in-clang-search-path.patch b/queue-4.4/kbuild-allow-to-use-gcc-toolchain-not-in-clang-search-path.patch
new file mode 100644 (file)
index 0000000..ef6b4fe
--- /dev/null
@@ -0,0 +1,55 @@
+From foo@baz Wed Nov 21 18:50:39 CET 2018
+From: Stefan Agner <stefan@agner.ch>
+Date: Mon, 17 Sep 2018 19:31:57 -0700
+Subject: kbuild: allow to use GCC toolchain not in Clang search path
+
+From: Stefan Agner <stefan@agner.ch>
+
+commit ef8c4ed9db80261f397f0c0bf723684601ae3b52 upstream.
+
+When using a GCC cross toolchain which is not in a compiled in
+Clang search path, Clang reverts to the system assembler and
+linker. This leads to assembler or linker errors, depending on
+which tool is first used for a given architecture.
+
+It seems that Clang is not searching $PATH for a matching
+assembler or linker.
+
+Make sure that Clang picks up the correct assembler or linker by
+passing the cross compilers bin directory as search path.
+
+This allows to use Clang provided by distributions with GCC
+toolchains not in /usr/bin.
+
+Link: https://github.com/ClangBuiltLinux/linux/issues/78
+Signed-off-by: Stefan Agner <stefan@agner.ch>
+Reviewed-and-tested-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+[nc: Adjust context]
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile |    8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+--- a/Makefile
++++ b/Makefile
+@@ -610,13 +610,15 @@ all: vmlinux
+ ifeq ($(cc-name),clang)
+ ifneq ($(CROSS_COMPILE),)
+ CLANG_TARGET  := --target=$(notdir $(CROSS_COMPILE:%-=%))
+-GCC_TOOLCHAIN := $(realpath $(dir $(shell which $(LD)))/..)
++GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD)))
++CLANG_PREFIX  := --prefix=$(GCC_TOOLCHAIN_DIR)
++GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
+ 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_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
++KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
+ KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
+ KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
+ endif
diff --git a/queue-4.4/kbuild-clang-add-no-integrated-as-to-kbuild_flags.patch b/queue-4.4/kbuild-clang-add-no-integrated-as-to-kbuild_flags.patch
new file mode 100644 (file)
index 0000000..9337452
--- /dev/null
@@ -0,0 +1,37 @@
+From foo@baz Wed Nov 21 18:50:39 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: Nathan Chancellor <natechancellor@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile |    2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/Makefile
++++ b/Makefile
+@@ -719,6 +719,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.4/kbuild-clang-disable-address-of-packed-member-warning.patch b/queue-4.4/kbuild-clang-disable-address-of-packed-member-warning.patch
new file mode 100644 (file)
index 0000000..e92a5bb
--- /dev/null
@@ -0,0 +1,32 @@
+From foo@baz Wed Nov 21 18:50:39 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: Nathan Chancellor <natechancellor@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/Makefile
++++ b/Makefile
+@@ -711,6 +711,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.4/kbuild-clang-disable-unused-variable-warnings-only-when-constant.patch b/queue-4.4/kbuild-clang-disable-unused-variable-warnings-only-when-constant.patch
new file mode 100644 (file)
index 0000000..992dff5
--- /dev/null
@@ -0,0 +1,49 @@
+From foo@baz Wed Nov 21 18:50:39 CET 2018
+From: Sodagudi Prasad <psodagud@codeaurora.org>
+Date: Tue, 6 Feb 2018 15:46:51 -0800
+Subject: kbuild: clang: disable unused variable warnings only when constant
+
+From: Sodagudi Prasad <psodagud@codeaurora.org>
+
+commit 0a5f41767444cc3b4fc5573921ab914b4f78baaa upstream.
+
+Currently, GCC disables -Wunused-const-variable, but not
+-Wunused-variable, so warns unused variables if they are
+non-constant.
+
+While, Clang does not warn unused variables at all regardless of
+the const qualifier because -Wno-unused-const-variable is implied
+by the stronger option -Wno-unused-variable.
+
+Disable -Wunused-const-variable instead of -Wunused-variable so that
+GCC and Clang work in the same way.
+
+Signed-off-by: Prasad Sodagudi <psodagud@codeaurora.org>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile |    3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+--- a/Makefile
++++ b/Makefile
+@@ -706,7 +706,6 @@ KBUILD_CFLAGS += $(stackp-flag)
+ ifeq ($(cc-name),clang)
+ KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
+-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)
+@@ -724,9 +723,9 @@ else
+ # These warnings generated too much noise in a regular build.
+ # Use make W=1 to enable them (see scripts/Makefile.extrawarn)
+ KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
+-KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
+ endif
++KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
+ ifdef CONFIG_FRAME_POINTER
+ KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
+ else
diff --git a/queue-4.4/kbuild-clang-fix-build-failures-with-sparse-check.patch b/queue-4.4/kbuild-clang-fix-build-failures-with-sparse-check.patch
new file mode 100644 (file)
index 0000000..1819ecf
--- /dev/null
@@ -0,0 +1,38 @@
+From foo@baz Wed Nov 21 18:50:39 CET 2018
+From: David Lin <dtwlin@google.com>
+Date: Fri, 20 Oct 2017 14:09:13 -0700
+Subject: kbuild: clang: fix build failures with sparse check
+
+From: David Lin <dtwlin@google.com>
+
+commit bb3f38c3c5b759163e09b9152629cc789731de47 upstream.
+
+We should avoid using the space character when passing arguments to
+clang, because static code analysis check tool such as sparse may
+misinterpret the arguments followed by spaces as build targets hence
+cause the build to fail.
+
+Signed-off-by: David Lin <dtwlin@google.com>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/Makefile
++++ b/Makefile
+@@ -614,11 +614,11 @@ all: vmlinux
+ ifeq ($(cc-name),clang)
+ ifneq ($(CROSS_COMPILE),)
+-CLANG_TARGET  := -target $(notdir $(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)
++CLANG_GCC_TC  := --gcc-toolchain=$(GCC_TOOLCHAIN)
+ endif
+ KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
+ KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
diff --git a/queue-4.4/kbuild-clang-remove-crufty-hostcflags.patch b/queue-4.4/kbuild-clang-remove-crufty-hostcflags.patch
new file mode 100644 (file)
index 0000000..fdbfbe9
--- /dev/null
@@ -0,0 +1,45 @@
+From foo@baz Wed Nov 21 18:50:39 CET 2018
+From: Nick Desaulniers <nick.desaulniers@gmail.com>
+Date: Sat, 7 Oct 2017 13:23:23 -0700
+Subject: kbuild: clang: remove crufty HOSTCFLAGS
+
+From: Nick Desaulniers <nick.desaulniers@gmail.com>
+
+commit df16aaac26e92e97ab7234d3f93c953466adc4b5 upstream.
+
+When compiling with `make CC=clang HOSTCC=clang`, I was seeing warnings
+that clang did not recognize -fno-delete-null-pointer-checks for HOSTCC
+targets.  These were added in commit 61163efae020 ("kbuild: LLVMLinux:
+Add Kbuild support for building kernel with Clang").
+
+Clang does not support -fno-delete-null-pointer-checks, so adding it to
+HOSTCFLAGS if HOSTCC is clang does not make sense.
+
+It's not clear why the other warnings were disabled, and just for
+HOSTCFLAGS, but I can remove them, add -Werror to HOSTCFLAGS and compile
+with clang just fine.
+
+Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Signed-off-by: Nick Desaulniers <nick.desaulniers@gmail.com>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+[nc: Adjust context]
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile |    5 -----
+ 1 file changed, 5 deletions(-)
+
+--- a/Makefile
++++ b/Makefile
+@@ -306,11 +306,6 @@ HOSTCXX      = g++
+ 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)
+-HOSTCFLAGS  += -Wno-unused-value -Wno-unused-parameter \
+-              -Wno-missing-field-initializers -fno-delete-null-pointer-checks
+-endif
+-
+ # Decide whether to build built-in, modular, or both.
+ # Normally, just do built-in.
diff --git a/queue-4.4/kbuild-consolidate-header-generation-from-asm-offset-information.patch b/queue-4.4/kbuild-consolidate-header-generation-from-asm-offset-information.patch
new file mode 100644 (file)
index 0000000..cbbeff9
--- /dev/null
@@ -0,0 +1,166 @@
+From foo@baz Wed Nov 21 18:50:39 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: Nathan Chancellor <natechancellor@gmail.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
+@@ -6,31 +6,6 @@
+ # 3) Generate asm-offsets.h (may need bounds.h and timeconst.h)
+ # 4) Check for missing system calls
+-# 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
+@@ -388,3 +388,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
+@@ -5,32 +5,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.4/kbuild-consolidate-redundant-sed-script-asm-offset-generation.patch b/queue-4.4/kbuild-consolidate-redundant-sed-script-asm-offset-generation.patch
new file mode 100644 (file)
index 0000000..bbf8116
--- /dev/null
@@ -0,0 +1,49 @@
+From foo@baz Wed Nov 21 18:50:39 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: Nathan Chancellor <natechancellor@gmail.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
+@@ -395,7 +395,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.4/kbuild-drop-wno-unknown-warning-option-from-clang-options.patch b/queue-4.4/kbuild-drop-wno-unknown-warning-option-from-clang-options.patch
new file mode 100644 (file)
index 0000000..f0623ad
--- /dev/null
@@ -0,0 +1,48 @@
+From foo@baz Wed Nov 21 18:50:39 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: Nathan Chancellor <natechancellor@gmail.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
+@@ -708,7 +708,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
+@@ -61,7 +61,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.4/kbuild-fix-asm-offset-generation-to-work-with-clang.patch b/queue-4.4/kbuild-fix-asm-offset-generation-to-work-with-clang.patch
new file mode 100644 (file)
index 0000000..a17b977
--- /dev/null
@@ -0,0 +1,69 @@
+From foo@baz Wed Nov 21 18:50:39 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: Nathan Chancellor <natechancellor@gmail.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
+@@ -393,10 +393,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.4/kbuild-fix-linker-feature-test-macros-when-cross-compiling-with-clang.patch b/queue-4.4/kbuild-fix-linker-feature-test-macros-when-cross-compiling-with-clang.patch
new file mode 100644 (file)
index 0000000..51bd1fc
--- /dev/null
@@ -0,0 +1,73 @@
+From foo@baz Wed Nov 21 18:50:39 CET 2018
+From: Nick Desaulniers <ndesaulniers@google.com>
+Date: Mon, 6 Nov 2017 10:47:54 -0800
+Subject: kbuild: fix linker feature test macros when cross compiling with Clang
+
+From: Nick Desaulniers <ndesaulniers@google.com>
+
+commit 86a9df597cdd564d2d29c65897bcad42519e3678 upstream.
+
+I was not seeing my linker flags getting added when using ld-option when
+cross compiling with Clang. Upon investigation, this seems to be due to
+a difference in how GCC vs Clang handle cross compilation.
+
+GCC is configured at build time to support one backend, that is implicit
+when compiling.  Clang is explicit via the use of `-target <triple>` and
+ships with all supported backends by default.
+
+GNU Make feature test macros that compile then link will always fail
+when cross compiling with Clang unless Clang's triple is passed along to
+the compiler. For example:
+
+$ clang -x c /dev/null -c -o temp.o
+$ aarch64-linux-android/bin/ld -E temp.o
+aarch64-linux-android/bin/ld:
+unknown architecture of input file `temp.o' is incompatible with
+aarch64 output
+aarch64-linux-android/bin/ld:
+warning: cannot find entry symbol _start; defaulting to
+0000000000400078
+$ echo $?
+1
+
+$ clang -target aarch64-linux-android- -x c /dev/null -c -o temp.o
+$ aarch64-linux-android/bin/ld -E temp.o
+aarch64-linux-android/bin/ld:
+warning: cannot find entry symbol _start; defaulting to 00000000004002e4
+$ echo $?
+0
+
+This causes conditional checks that invoke $(CC) without the target
+triple, then $(LD) on the result, to always fail.
+
+Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+[nc: Fix conflicts due to lack of commit 3298b690b21cd in linux-4.4.y
+     Use KBUILD_CFLAGS instead of CC_OPTION_FLAGS because commit
+     d26e94149276f that introduced that variable isn't in 4.4 either]
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ scripts/Kbuild.include |    5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+--- a/scripts/Kbuild.include
++++ b/scripts/Kbuild.include
+@@ -147,12 +147,13 @@ cc-ifversion = $(shell [ $(cc-version) $
+ # cc-ldoption
+ # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
+ cc-ldoption = $(call try-run,\
+-      $(CC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
++      $(CC) $(1) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
+ # ld-option
+ # Usage: LDFLAGS += $(call ld-option, -X)
+ ld-option = $(call try-run,\
+-      $(CC) -x c /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2))
++      $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -x c /dev/null -c -o "$$TMPO"; \
++      $(LD) $(LDFLAGS) $(1) "$$TMPO" -o "$$TMP",$(1),$(2))
+ # ar-option
+ # Usage: KBUILD_ARFLAGS := $(call ar-option,D)
diff --git a/queue-4.4/kbuild-llvmlinux-add-werror-to-cc-option-to-support-clang.patch b/queue-4.4/kbuild-llvmlinux-add-werror-to-cc-option-to-support-clang.patch
new file mode 100644 (file)
index 0000000..366c62a
--- /dev/null
@@ -0,0 +1,58 @@
+From foo@baz Wed Nov 21 18:50:39 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>
+[nc: Adjust context due to lack of d26e94149276f]
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.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
+@@ -112,12 +112,12 @@ as-instr = $(call try-run,\
+ # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
+ cc-option = $(call try-run,\
+-      $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
++      $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_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) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
++      $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
+ # cc-option-align
+ # Prefix align with either -falign or -malign
+@@ -127,7 +127,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) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
++      $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_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.4/kbuild-move-cc-option-and-cc-disable-warning-after-incl.-arch-makefile.patch b/queue-4.4/kbuild-move-cc-option-and-cc-disable-warning-after-incl.-arch-makefile.patch
new file mode 100644 (file)
index 0000000..0d3a2f1
--- /dev/null
@@ -0,0 +1,93 @@
+From foo@baz Wed Nov 21 18:50:39 CET 2018
+From: Masahiro Yamada <yamada.masahiro@socionext.com>
+Date: Mon, 27 Nov 2017 21:15:13 +0900
+Subject: kbuild: move cc-option and cc-disable-warning after incl. arch Makefile
+
+From: Masahiro Yamada <yamada.masahiro@socionext.com>
+
+commit cfe17c9bbe6a673fdafdab179c32b355ed447f66 upstream.
+
+Geert reported commit ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before
+incl. arch Makefile") broke cross-compilation using a cross-compiler
+that supports less compiler options than the host compiler.
+
+For example,
+
+  cc1: error: unrecognized command line option "-Wno-unused-but-set-variable"
+
+This problem happens on architectures that setup CROSS_COMPILE in their
+arch/*/Makefile.
+
+Move the cc-option and cc-disable-warning back to the original position,
+but keep the Clang target options untouched.
+
+Fixes: ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before incl. arch Makefile")
+Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
+[nc: Adjust context]
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile |   43 +++++++++++++++++++++++--------------------
+ 1 file changed, 23 insertions(+), 20 deletions(-)
+
+--- a/Makefile
++++ b/Makefile
+@@ -622,26 +622,6 @@ CLANG_GCC_TC      := -gcc-toolchain $(GCC_TOO
+ endif
+ KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
+ KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
+-KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
+-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
+-# source of a reference will be _MergedGlobals and not on of the whitelisted names.
+-# 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.
+-# Use make W=1 to enable them (see scripts/Makefile.build)
+-KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
+-KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
+ endif
+ # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
+@@ -729,6 +709,29 @@ endif
+ endif
+ KBUILD_CFLAGS += $(stackp-flag)
++ifeq ($(cc-name),clang)
++KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
++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
++# source of a reference will be _MergedGlobals and not on of the whitelisted names.
++# 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.
++# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
++KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
++KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
++endif
++
+ ifdef CONFIG_FRAME_POINTER
+ KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
+ else
diff --git a/queue-4.4/kbuild-set-kbuild_cflags-before-incl.-arch-makefile.patch b/queue-4.4/kbuild-set-kbuild_cflags-before-incl.-arch-makefile.patch
new file mode 100644 (file)
index 0000000..95f9fea
--- /dev/null
@@ -0,0 +1,108 @@
+From foo@baz Wed Nov 21 18:50:39 CET 2018
+From: Chris Fries <cfries@google.com>
+Date: Tue, 7 Nov 2017 11:46:13 -0800
+Subject: kbuild: Set KBUILD_CFLAGS before incl. arch Makefile
+
+From: Chris Fries <cfries@google.com>
+
+commit ae6b289a37890909fea0e4a1666e19377fa0ed2c upstream.
+
+Set the clang KBUILD_CFLAGS up before including arch/ Makefiles,
+so that ld-options (etc.) can work correctly.
+
+This fixes errors with clang such as ld-options trying to CC
+against your host architecture, but LD trying to link against
+your target architecture.
+
+Signed-off-by: Chris Fries <cfries@google.com>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
+Tested-by: Matthias Kaehlcke <mka@chromium.org>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+[nc: Adjust context]
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile |   64 +++++++++++++++++++++++++++++++--------------------------------
+ 1 file changed, 32 insertions(+), 32 deletions(-)
+
+--- a/Makefile
++++ b/Makefile
+@@ -612,6 +612,38 @@ endif # $(dot-config)
+ # Defaults to vmlinux, but the arch makefile usually adds further targets
+ all: vmlinux
++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_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
++# source of a reference will be _MergedGlobals and not on of the whitelisted names.
++# 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.
++# Use make W=1 to enable them (see scripts/Makefile.build)
++KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
++KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
++endif
++
+ # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
+ # values of the respective KBUILD_* variables
+ ARCH_CPPFLAGS :=
+@@ -697,38 +729,6 @@ endif
+ 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_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
+-# source of a reference will be _MergedGlobals and not on of the whitelisted names.
+-# 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.
+-# Use make W=1 to enable them (see scripts/Makefile.build)
+-KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
+-KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
+-endif
+-
+ ifdef CONFIG_FRAME_POINTER
+ KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
+ else
diff --git a/queue-4.4/kbuild-set-no-integrated-as-before-incl.-arch-makefile.patch b/queue-4.4/kbuild-set-no-integrated-as-before-incl.-arch-makefile.patch
new file mode 100644 (file)
index 0000000..2770405
--- /dev/null
@@ -0,0 +1,43 @@
+From foo@baz Wed Nov 21 18:50:39 CET 2018
+From: Stefan Agner <stefan@agner.ch>
+Date: Mon, 19 Mar 2018 22:12:53 +0100
+Subject: kbuild: set no-integrated-as before incl. arch Makefile
+
+From: Stefan Agner <stefan@agner.ch>
+
+commit 0f0e8de334c54c38818a4a5390a39aa09deff5bf upstream.
+
+In order to make sure compiler flag detection for ARM works
+correctly the no-integrated-as flags need to be set before
+including the arch specific Makefile.
+
+Fixes: cfe17c9bbe6a ("kbuild: move cc-option and cc-disable-warning after incl. arch Makefile")
+Signed-off-by: Stefan Agner <stefan@agner.ch>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+[nc: Adjust context]
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/Makefile
++++ b/Makefile
+@@ -617,6 +617,8 @@ CLANG_GCC_TC       := --gcc-toolchain=$(GCC_TO
+ endif
+ KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
+ KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
++KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
++KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
+ endif
+ # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
+@@ -716,8 +718,6 @@ 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.4/kbuild-use-oz-instead-of-os-when-using-clang.patch b/queue-4.4/kbuild-use-oz-instead-of-os-when-using-clang.patch
new file mode 100644 (file)
index 0000000..b99f0b9
--- /dev/null
@@ -0,0 +1,32 @@
+From foo@baz Wed Nov 21 18:50:39 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>
+[nc: Adjust context due to lack of commit a76bcf557ef4 in linux-4.4.y]
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/Makefile
++++ b/Makefile
+@@ -628,7 +628,7 @@ KBUILD_CFLAGS      += $(call cc-disable-warni
+ KBUILD_CFLAGS += $(call cc-disable-warning, attribute-alias)
+ ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
+-KBUILD_CFLAGS += -Os
++KBUILD_CFLAGS += $(call cc-option,-Oz,-Os)
+ else
+ ifdef CONFIG_PROFILE_ALL_BRANCHES
+ KBUILD_CFLAGS += -O2
diff --git a/queue-4.4/modules-mark-__inittest-__exittest-as-__maybe_unused.patch b/queue-4.4/modules-mark-__inittest-__exittest-as-__maybe_unused.patch
new file mode 100644 (file)
index 0000000..b6d4d85
--- /dev/null
@@ -0,0 +1,45 @@
+From foo@baz Wed Nov 21 18:50:39 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: Nathan Chancellor <natechancellor@gmail.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
+@@ -125,13 +125,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 d4e77db6b7e748e7b6b2faca24f209c4134dbf76..2a70e7170ed6a2bd1610e450a12cd7f2bb45de35 100644 (file)
@@ -3,3 +3,35 @@ ip_tunnel-don-t-force-df-when-mtu-is-locked.patch
 net-gro-reset-skb-pkt_type-in-napi_reuse_skb.patch
 tg3-add-phy-reset-for-5717-5719-5720-in-change-ring-and-flow-control-paths.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
+kbuild-clang-disable-address-of-packed-member-warning.patch
+crypto-arm64-sha-avoid-non-standard-inline-asm-tricks.patch
+efi-libstub-arm64-force-hidden-visibility-for-section-markers.patch
+efi-libstub-arm64-set-fpie-when-building-the-efi-stub.patch
+kbuild-fix-linker-feature-test-macros-when-cross-compiling-with-clang.patch
+kbuild-set-kbuild_cflags-before-incl.-arch-makefile.patch
+kbuild-move-cc-option-and-cc-disable-warning-after-incl.-arch-makefile.patch
+kbuild-clang-fix-build-failures-with-sparse-check.patch
+kbuild-clang-remove-crufty-hostcflags.patch
+kbuild-clang-disable-unused-variable-warnings-only-when-constant.patch
+kbuild-set-no-integrated-as-before-incl.-arch-makefile.patch
+kbuild-allow-to-use-gcc-toolchain-not-in-clang-search-path.patch
+arm64-disable-asm-operand-width-warning-for-clang.patch
+x86-kbuild-use-cc-option-to-enable-falign-jumps-loops.patch
+crypto-x86-aesni-fix-token-pasting-for-clang.patch
+x86-mm-kaslr-use-the-_asm_mul-macro-for-multiplication-to-work-around-clang-incompatibility.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
+x86-boot-undef-memcpy-et-al-in-string.c.patch
+x86-build-fix-stack-alignment-for-clang.patch
+x86-build-use-cc-option-to-validate-stack-alignment-parameter.patch
diff --git a/queue-4.4/x86-boot-undef-memcpy-et-al-in-string.c.patch b/queue-4.4/x86-boot-undef-memcpy-et-al-in-string.c.patch
new file mode 100644 (file)
index 0000000..ff76e1d
--- /dev/null
@@ -0,0 +1,57 @@
+From foo@baz Wed Nov 21 18:50:39 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: Nathan Chancellor <natechancellor@gmail.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)
+ {
+       u8 diff;
diff --git a/queue-4.4/x86-build-fix-stack-alignment-for-clang.patch b/queue-4.4/x86-build-fix-stack-alignment-for-clang.patch
new file mode 100644 (file)
index 0000000..4a32011
--- /dev/null
@@ -0,0 +1,97 @@
+From foo@baz Wed Nov 21 18:50:39 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: Nathan Chancellor <natechancellor@gmail.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.4/x86-build-specify-stack-alignment-for-clang.patch b/queue-4.4/x86-build-specify-stack-alignment-for-clang.patch
new file mode 100644 (file)
index 0000000..b983168
--- /dev/null
@@ -0,0 +1,85 @@
+From foo@baz Wed Nov 21 18:50:39 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: Nathan Chancellor <natechancellor@gmail.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.4/x86-build-use-__cc-option-for-boot-code-compiler-options.patch b/queue-4.4/x86-build-use-__cc-option-for-boot-code-compiler-options.patch
new file mode 100644 (file)
index 0000000..9428438
--- /dev/null
@@ -0,0 +1,53 @@
+From foo@baz Wed Nov 21 18:50:39 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: Nathan Chancellor <natechancellor@gmail.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.4/x86-build-use-cc-option-to-validate-stack-alignment-parameter.patch b/queue-4.4/x86-build-use-cc-option-to-validate-stack-alignment-parameter.patch
new file mode 100644 (file)
index 0000000..15bf22a
--- /dev/null
@@ -0,0 +1,75 @@
+From foo@baz Wed Nov 21 18:50:39 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: Nathan Chancellor <natechancellor@gmail.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.4/x86-kbuild-use-cc-option-to-enable-falign-jumps-loops.patch b/queue-4.4/x86-kbuild-use-cc-option-to-enable-falign-jumps-loops.patch
new file mode 100644 (file)
index 0000000..dc46afe
--- /dev/null
@@ -0,0 +1,43 @@
+From foo@baz Wed Nov 21 18:50:39 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: Nathan Chancellor <natechancellor@gmail.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)
diff --git a/queue-4.4/x86-mm-kaslr-use-the-_asm_mul-macro-for-multiplication-to-work-around-clang-incompatibility.patch b/queue-4.4/x86-mm-kaslr-use-the-_asm_mul-macro-for-multiplication-to-work-around-clang-incompatibility.patch
new file mode 100644 (file)
index 0000000..e997999
--- /dev/null
@@ -0,0 +1,70 @@
+From foo@baz Wed Nov 21 18:50:39 CET 2018
+From: Matthias Kaehlcke <mka@chromium.org>
+Date: Mon, 1 May 2017 15:47:41 -0700
+Subject: x86/mm/kaslr: Use the _ASM_MUL macro for multiplication to work around Clang incompatibility
+
+From: Matthias Kaehlcke <mka@chromium.org>
+
+commit 121843eb02a6e2fa30aefab64bfe183c97230c75 upstream.
+
+The constraint "rm" allows the compiler to put mix_const into memory.
+When the input operand is a memory location then MUL needs an operand
+size suffix, since Clang can't infer the multiplication width from the
+operand.
+
+Add and use the _ASM_MUL macro which determines the operand size and
+resolves to the NUL instruction with the corresponding suffix.
+
+This fixes the following error when building with clang:
+
+  CC      arch/x86/lib/kaslr.o
+  /tmp/kaslr-dfe1ad.s: Assembler messages:
+  /tmp/kaslr-dfe1ad.s:182: Error: no instruction mnemonic suffix given and no register operands; can't size instruction
+
+Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
+Cc: Grant Grundler <grundler@chromium.org>
+Cc: Greg Hackmann <ghackmann@google.com>
+Cc: Kees Cook <keescook@chromium.org>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Michael Davidson <md@google.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Link: http://lkml.kernel.org/r/20170501224741.133938-1-mka@chromium.org
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+[nc: Apply to aslr.c in get_random_long as the kaslr shift didn't happen
+     until 4.8 in commit d899a7d146a2]
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/boot/compressed/aslr.c |    3 ++-
+ arch/x86/include/asm/asm.h      |    1 +
+ 2 files changed, 3 insertions(+), 1 deletion(-)
+
+--- a/arch/x86/boot/compressed/aslr.c
++++ b/arch/x86/boot/compressed/aslr.c
+@@ -1,5 +1,6 @@
+ #include "misc.h"
++#include <asm/asm.h>
+ #include <asm/msr.h>
+ #include <asm/archrandom.h>
+ #include <asm/e820.h>
+@@ -94,7 +95,7 @@ static unsigned long get_random_long(voi
+       }
+       /* Circular multiply for better bit diffusion */
+-      asm("mul %3"
++      asm(_ASM_MUL "%3"
+           : "=a" (random), "=d" (raw)
+           : "a" (random), "rm" (mix_const));
+       random += raw;
+--- a/arch/x86/include/asm/asm.h
++++ b/arch/x86/include/asm/asm.h
+@@ -34,6 +34,7 @@
+ #define _ASM_ADD      __ASM_SIZE(add)
+ #define _ASM_SUB      __ASM_SIZE(sub)
+ #define _ASM_XADD     __ASM_SIZE(xadd)
++#define _ASM_MUL      __ASM_SIZE(mul)
+ #define _ASM_AX               __ASM_REG(ax)
+ #define _ASM_BX               __ASM_REG(bx)