From: Greg Kroah-Hartman Date: Wed, 21 Nov 2018 17:55:42 +0000 (+0100) Subject: 4.4-stable patches X-Git-Tag: v3.18.126~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=22b748810ee113af68fa6e12c0e1f7d0058c25d3;p=thirdparty%2Fkernel%2Fstable-queue.git 4.4-stable patches 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 --- 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 index 00000000000..b6f2a561e35 --- /dev/null +++ b/queue-4.4/arm64-disable-asm-operand-width-warning-for-clang.patch @@ -0,0 +1,41 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Matthias Kaehlcke +Date: Fri, 21 Apr 2017 16:00:56 -0700 +Subject: arm64: Disable asm-operand-width warning for clang + +From: Matthias Kaehlcke + +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 + +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 +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..f575392c84f --- /dev/null +++ b/queue-4.4/crypto-arm64-sha-avoid-non-standard-inline-asm-tricks.patch @@ -0,0 +1,140 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Ard Biesheuvel +Date: Wed, 26 Apr 2017 17:11:32 +0100 +Subject: crypto: arm64/sha - avoid non-standard inline asm tricks + +From: Ard Biesheuvel + +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 +Tested-by: Matthias Kaehlcke +Signed-off-by: Herbert Xu +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 + #include + +-#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 "); + 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 + #include + +-#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 "); + 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 index 00000000000..7c26320dcfd --- /dev/null +++ b/queue-4.4/crypto-x86-aesni-fix-token-pasting-for-clang.patch @@ -0,0 +1,63 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Michael Davidson +Date: Wed, 15 Mar 2017 15:36:00 -0700 +Subject: crypto, x86: aesni - fix token pasting for clang + +From: Michael Davidson + +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 +Signed-off-by: Herbert Xu +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 + #include + +-#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 index 00000000000..a51adc6fa2d --- /dev/null +++ b/queue-4.4/efi-libstub-arm64-force-hidden-visibility-for-section-markers.patch @@ -0,0 +1,50 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Ard Biesheuvel +Date: Fri, 18 Aug 2017 20:49:36 +0100 +Subject: efi/libstub/arm64: Force 'hidden' visibility for section markers + +From: Ard Biesheuvel + +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 +Signed-off-by: Ard Biesheuvel +Cc: Linus Torvalds +Cc: Matt Fleming +Cc: Peter Zijlstra +Cc: Thomas Gleixner +Cc: linux-efi@vger.kernel.org +Link: http://lkml.kernel.org/r/20170818194947.19347-4-ard.biesheuvel@linaro.org +Signed-off-by: Ingo Molnar +[nc: Fix conflict due to lack of commit 42b55734030c1 in linux-4.4.y] +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 ++#pragma GCC visibility pop ++ + #include + #include +-#include + + 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 index 00000000000..24bd34d6a0a --- /dev/null +++ b/queue-4.4/efi-libstub-arm64-set-fpie-when-building-the-efi-stub.patch @@ -0,0 +1,49 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Ard Biesheuvel +Date: Fri, 18 Aug 2017 20:49:37 +0100 +Subject: efi/libstub/arm64: Set -fpie when building the EFI stub + +From: Ard Biesheuvel + +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 +Signed-off-by: Ard Biesheuvel +Cc: Linus Torvalds +Cc: Matt Fleming +Cc: Peter Zijlstra +Cc: Thomas Gleixner +Cc: linux-efi@vger.kernel.org +Link: http://lkml.kernel.org/r/20170818194947.19347-5-ard.biesheuvel@linaro.org +Signed-off-by: Ingo Molnar +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..da52c6d2492 --- /dev/null +++ b/queue-4.4/kbuild-add-__cc-option-macro.patch @@ -0,0 +1,69 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Matthias Kaehlcke +Date: Wed, 21 Jun 2017 16:28:03 -0700 +Subject: kbuild: Add __cc-option macro + +From: Matthias Kaehlcke + +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 +Suggested-by: Masahiro Yamada +Signed-off-by: Matthias Kaehlcke +Acked-by: Arnd Bergmann +Acked-by: Michal Marek +Signed-off-by: Masahiro Yamada +[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 +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..c45d6e05803 --- /dev/null +++ b/queue-4.4/kbuild-add-better-clang-cross-build-support.patch @@ -0,0 +1,48 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Behan Webster +Date: Fri, 21 Apr 2017 11:20:01 -0700 +Subject: kbuild: Add better clang cross build support + +From: Behan Webster + +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 +Reviewed-by: Jan-Simon Möller +Reviewed-by: Mark Charlebois +Signed-off-by: Greg Hackmann +Signed-off-by: Matthias Kaehlcke +Signed-off-by: Masahiro Yamada +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..aabc5d2d86c --- /dev/null +++ b/queue-4.4/kbuild-add-support-to-generate-llvm-assembly-files.patch @@ -0,0 +1,83 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: "Vinícius Tinti" +Date: Mon, 24 Apr 2017 13:04:58 -0700 +Subject: kbuild: Add support to generate LLVM assembly files + +From: "Vinícius Tinti" + +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 +Signed-off-by: Behan Webster +Signed-off-by: Matthias Kaehlcke +Signed-off-by: Masahiro Yamada +[nc: Fix conflicts due to lack of commit 6b90bd4ba40b3 in linux-4.4.y] +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + .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 index 00000000000..ef6b4fe1c6b --- /dev/null +++ b/queue-4.4/kbuild-allow-to-use-gcc-toolchain-not-in-clang-search-path.patch @@ -0,0 +1,55 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Stefan Agner +Date: Mon, 17 Sep 2018 19:31:57 -0700 +Subject: kbuild: allow to use GCC toolchain not in Clang search path + +From: Stefan Agner + +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 +Reviewed-and-tested-by: Nick Desaulniers +Signed-off-by: Masahiro Yamada +[nc: Adjust context] +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..93374529dc0 --- /dev/null +++ b/queue-4.4/kbuild-clang-add-no-integrated-as-to-kbuild_flags.patch @@ -0,0 +1,37 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Michael Davidson +Date: Tue, 25 Apr 2017 15:47:35 -0700 +Subject: kbuild: clang: add -no-integrated-as to KBUILD_[AC]FLAGS + +From: Michael Davidson + +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 +Signed-off-by: Michael Davidson +Signed-off-by: Matthias Kaehlcke +Signed-off-by: Masahiro Yamada +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..e92a5bb65d9 --- /dev/null +++ b/queue-4.4/kbuild-clang-disable-address-of-packed-member-warning.patch @@ -0,0 +1,32 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Matthias Kaehlcke +Date: Fri, 21 Apr 2017 14:39:30 -0700 +Subject: kbuild: clang: Disable 'address-of-packed-member' warning + +From: Matthias Kaehlcke + +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 +Reviewed-by: Douglas Anderson +Signed-off-by: Masahiro Yamada +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..992dff5251d --- /dev/null +++ b/queue-4.4/kbuild-clang-disable-unused-variable-warnings-only-when-constant.patch @@ -0,0 +1,49 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Sodagudi Prasad +Date: Tue, 6 Feb 2018 15:46:51 -0800 +Subject: kbuild: clang: disable unused variable warnings only when constant + +From: Sodagudi Prasad + +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 +Signed-off-by: Masahiro Yamada +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..1819ecf8a4c --- /dev/null +++ b/queue-4.4/kbuild-clang-fix-build-failures-with-sparse-check.patch @@ -0,0 +1,38 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: David Lin +Date: Fri, 20 Oct 2017 14:09:13 -0700 +Subject: kbuild: clang: fix build failures with sparse check + +From: David Lin + +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 +Signed-off-by: Masahiro Yamada +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..fdbfbe95cd9 --- /dev/null +++ b/queue-4.4/kbuild-clang-remove-crufty-hostcflags.patch @@ -0,0 +1,45 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Nick Desaulniers +Date: Sat, 7 Oct 2017 13:23:23 -0700 +Subject: kbuild: clang: remove crufty HOSTCFLAGS + +From: Nick Desaulniers + +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 +Signed-off-by: Nick Desaulniers +Signed-off-by: Masahiro Yamada +[nc: Adjust context] +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..cbbeff94bd2 --- /dev/null +++ b/queue-4.4/kbuild-consolidate-header-generation-from-asm-offset-information.patch @@ -0,0 +1,166 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Matthias Kaehlcke +Date: Wed, 12 Apr 2017 12:43:52 -0700 +Subject: kbuild: Consolidate header generation from ASM offset information + +From: Matthias Kaehlcke + +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 +Signed-off-by: Masahiro Yamada +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..bbf8116aa26 --- /dev/null +++ b/queue-4.4/kbuild-consolidate-redundant-sed-script-asm-offset-generation.patch @@ -0,0 +1,49 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Masahiro Yamada +Date: Fri, 21 Apr 2017 15:21:10 +0900 +Subject: kbuild: consolidate redundant sed script ASM offset generation + +From: Masahiro Yamada + +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 +Reviewed-by: Matthias Kaehlcke +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..f0623ad9146 --- /dev/null +++ b/queue-4.4/kbuild-drop-wno-unknown-warning-option-from-clang-options.patch @@ -0,0 +1,48 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Masahiro Yamada +Date: Thu, 13 Apr 2017 07:25:21 +0900 +Subject: kbuild: drop -Wno-unknown-warning-option from clang options + +From: Masahiro Yamada + +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 +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..a17b977b901 --- /dev/null +++ b/queue-4.4/kbuild-fix-asm-offset-generation-to-work-with-clang.patch @@ -0,0 +1,69 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Jeroen Hofstee +Date: Fri, 21 Apr 2017 15:21:11 +0900 +Subject: kbuild: fix asm-offset generation to work with clang + +From: Jeroen Hofstee + +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 +Signed-off-by: Masahiro Yamada +Reviewed-by: Matthias Kaehlcke +Tested-by: Matthias Kaehlcke +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 around ++# the .ascii directive whereas GCC keeps the 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 index 00000000000..51bd1fca2a0 --- /dev/null +++ b/queue-4.4/kbuild-fix-linker-feature-test-macros-when-cross-compiling-with-clang.patch @@ -0,0 +1,73 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Nick Desaulniers +Date: Mon, 6 Nov 2017 10:47:54 -0800 +Subject: kbuild: fix linker feature test macros when cross compiling with Clang + +From: Nick Desaulniers + +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 ` 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 +Signed-off-by: Nick Desaulniers +Reviewed-by: Matthias Kaehlcke +Signed-off-by: Masahiro Yamada +[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 +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..366c62a1e17 --- /dev/null +++ b/queue-4.4/kbuild-llvmlinux-add-werror-to-cc-option-to-support-clang.patch @@ -0,0 +1,58 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Mark Charlebois +Date: Fri, 31 Mar 2017 22:38:13 +0200 +Subject: kbuild, LLVMLinux: Add -Werror to cc-option to support clang + +From: Mark Charlebois + +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 +Signed-off-by: Behan Webster +Reviewed-by: Jan-Simon Möller +Signed-off-by: Arnd Bergmann +Acked-by: Kees Cook +Signed-off-by: Masahiro Yamada +[nc: Adjust context due to lack of d26e94149276f] +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..0d3a2f145a0 --- /dev/null +++ b/queue-4.4/kbuild-move-cc-option-and-cc-disable-warning-after-incl.-arch-makefile.patch @@ -0,0 +1,93 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Masahiro Yamada +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 + +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 +Signed-off-by: Masahiro Yamada +Tested-by: Geert Uytterhoeven +[nc: Adjust context] +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..95f9fea5d48 --- /dev/null +++ b/queue-4.4/kbuild-set-kbuild_cflags-before-incl.-arch-makefile.patch @@ -0,0 +1,108 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Chris Fries +Date: Tue, 7 Nov 2017 11:46:13 -0800 +Subject: kbuild: Set KBUILD_CFLAGS before incl. arch Makefile + +From: Chris Fries + +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 +Signed-off-by: Nick Desaulniers +Reviewed-by: Matthias Kaehlcke +Tested-by: Matthias Kaehlcke +Signed-off-by: Masahiro Yamada +[nc: Adjust context] +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..27704052431 --- /dev/null +++ b/queue-4.4/kbuild-set-no-integrated-as-before-incl.-arch-makefile.patch @@ -0,0 +1,43 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Stefan Agner +Date: Mon, 19 Mar 2018 22:12:53 +0100 +Subject: kbuild: set no-integrated-as before incl. arch Makefile + +From: Stefan Agner + +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 +Signed-off-by: Masahiro Yamada +[nc: Adjust context] +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..b99f0b90548 --- /dev/null +++ b/queue-4.4/kbuild-use-oz-instead-of-os-when-using-clang.patch @@ -0,0 +1,32 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Behan Webster +Date: Mon, 27 Mar 2017 18:19:09 -0700 +Subject: kbuild: use -Oz instead of -Os when using clang + +From: Behan Webster + +commit 6748cb3c299de1ffbe56733647b01dbcc398c419 upstream. + +This generates smaller resulting object code when compiled with clang. + +Signed-off-by: Behan Webster +Signed-off-by: Matthias Kaehlcke +Signed-off-by: Masahiro Yamada +[nc: Adjust context due to lack of commit a76bcf557ef4 in linux-4.4.y] +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..b6d4d859b6e --- /dev/null +++ b/queue-4.4/modules-mark-__inittest-__exittest-as-__maybe_unused.patch @@ -0,0 +1,45 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Arnd Bergmann +Date: Wed, 1 Feb 2017 18:00:14 +0100 +Subject: modules: mark __inittest/__exittest as __maybe_unused + +From: Arnd Bergmann + +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 +Reviewed-by: Miroslav Benes +Acked-by: Rusty Russell +Signed-off-by: Jessica Yu +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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))); + diff --git a/queue-4.4/series b/queue-4.4/series index d4e77db6b7e..2a70e7170ed 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -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 index 00000000000..ff76e1d439b --- /dev/null +++ b/queue-4.4/x86-boot-undef-memcpy-et-al-in-string.c.patch @@ -0,0 +1,57 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Michael Davidson +Date: Mon, 24 Jul 2017 16:51:55 -0700 +Subject: x86/boot: #undef memcpy() et al in string.c + +From: Michael Davidson + +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 +Signed-off-by: Matthias Kaehlcke +Acked-by: H. Peter Anvin +Cc: Arnd Bergmann +Cc: Bernhard.Rosenkranzer@linaro.org +Cc: Greg Hackmann +Cc: Kees Cook +Cc: Linus Torvalds +Cc: Nick Desaulniers +Cc: Peter Zijlstra +Cc: Thomas Gleixner +Link: http://lkml.kernel.org/r/20170724235155.79255-1-mka@chromium.org +Signed-off-by: Ingo Molnar +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..4a3201171d8 --- /dev/null +++ b/queue-4.4/x86-build-fix-stack-alignment-for-clang.patch @@ -0,0 +1,97 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Matthias Kaehlcke +Date: Wed, 16 Aug 2017 17:47:40 -0700 +Subject: x86/build: Fix stack alignment for CLang + +From: Matthias Kaehlcke + +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 +Cc: Arnd Bergmann +Cc: Bernhard.Rosenkranzer@linaro.org +Cc: Greg Hackmann +Cc: Kees Cook +Cc: Linus Torvalds +Cc: Masahiro Yamada +Cc: Michael Davidson +Cc: Nick Desaulniers +Cc: Peter Zijlstra +Cc: Stephen Hines +Cc: Thomas Gleixner +Cc: dianders@chromium.org +Link: http://lkml.kernel.org/r/20170817004740.170588-1-mka@chromium.org +Signed-off-by: Ingo Molnar +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..b983168df43 --- /dev/null +++ b/queue-4.4/x86-build-specify-stack-alignment-for-clang.patch @@ -0,0 +1,85 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Matthias Kaehlcke +Date: Wed, 21 Jun 2017 16:28:05 -0700 +Subject: x86/build: Specify stack alignment for clang + +From: Matthias Kaehlcke + +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 +Acked-by: Ingo Molnar +Signed-off-by: Masahiro Yamada +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..94284380936 --- /dev/null +++ b/queue-4.4/x86-build-use-__cc-option-for-boot-code-compiler-options.patch @@ -0,0 +1,53 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Matthias Kaehlcke +Date: Wed, 21 Jun 2017 16:28:04 -0700 +Subject: x86/build: Use __cc-option for boot code compiler options + +From: Matthias Kaehlcke + +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 +Acked-by: Ingo Molnar +Signed-off-by: Masahiro Yamada +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..15bf22a066c --- /dev/null +++ b/queue-4.4/x86-build-use-cc-option-to-validate-stack-alignment-parameter.patch @@ -0,0 +1,75 @@ +From foo@baz Wed Nov 21 18:50:39 CET 2018 +From: Matthias Kaehlcke +Date: Thu, 17 Aug 2017 11:20:47 -0700 +Subject: x86/build: Use cc-option to validate stack alignment parameter + +From: Matthias Kaehlcke + +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 +