From: Greg Kroah-Hartman Date: Thu, 14 Nov 2019 06:50:11 +0000 (+0800) Subject: 4.4-stable patches X-Git-Tag: v4.4.202~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8bd70854fc8fdabfd71babbdf70412553b045e2c;p=thirdparty%2Fkernel%2Fstable-queue.git 4.4-stable patches added patches: powerpc-boot-request-no-dynamic-linker-for-boot-wrapper.patch powerpc-fix-compiling-a-be-kernel-with-a-powerpc64le-toolchain.patch powerpc-makefile-use-cflags-y-aflags-y-for-setting-endian-options.patch --- diff --git a/queue-4.4/powerpc-boot-request-no-dynamic-linker-for-boot-wrapper.patch b/queue-4.4/powerpc-boot-request-no-dynamic-linker-for-boot-wrapper.patch new file mode 100644 index 00000000000..f88e8b34750 --- /dev/null +++ b/queue-4.4/powerpc-boot-request-no-dynamic-linker-for-boot-wrapper.patch @@ -0,0 +1,76 @@ +From ff45000fcb56b5b0f1a14a865d3541746d838a0a Mon Sep 17 00:00:00 2001 +From: Nicholas Piggin +Date: Mon, 28 Nov 2016 12:42:26 +1100 +Subject: powerpc/boot: Request no dynamic linker for boot wrapper + +From: Nicholas Piggin + +commit ff45000fcb56b5b0f1a14a865d3541746d838a0a upstream. + +The boot wrapper performs its own relocations and does not require +PT_INTERP segment. However currently we don't tell the linker that. + +Prior to binutils 2.28 that works OK. But since binutils commit +1a9ccd70f9a7 ("Fix the linker so that it will not silently generate ELF +binaries with invalid program headers. Fix readelf to report such +invalid binaries.") binutils tries to create a program header segment +due to PT_INTERP, and the link fails because there is no space for it: + + ld: arch/powerpc/boot/zImage.pseries: Not enough room for program headers, try linking with -N + ld: final link failed: Bad value + +So tell the linker not to do that, by passing --no-dynamic-linker. + +Cc: stable@vger.kernel.org +Reported-by: Anton Blanchard +Signed-off-by: Nicholas Piggin +[mpe: Drop dependency on ld-version.sh and massage change log] +Signed-off-by: Michael Ellerman +[ajd: backport to v4.4 (resolve conflict with a comment line)] +Signed-off-by: Andrew Donnellan +Signed-off-by: Greg Kroah-Hartman + +--- + arch/powerpc/boot/wrapper | 24 +++++++++++++++++++++++- + 1 file changed, 23 insertions(+), 1 deletion(-) + +--- a/arch/powerpc/boot/wrapper ++++ b/arch/powerpc/boot/wrapper +@@ -161,6 +161,28 @@ case "$elfformat" in + elf32-powerpc) format=elf32ppc ;; + esac + ++ld_version() ++{ ++ # Poached from scripts/ld-version.sh, but we don't want to call that because ++ # this script (wrapper) is distributed separately from the kernel source. ++ # Extract linker version number from stdin and turn into single number. ++ awk '{ ++ gsub(".*\\)", ""); ++ gsub(".*version ", ""); ++ gsub("-.*", ""); ++ split($1,a, "."); ++ print a[1]*100000000 + a[2]*1000000 + a[3]*10000; ++ exit ++ }' ++} ++ ++# Do not include PT_INTERP segment when linking pie. Non-pie linking ++# just ignores this option. ++LD_VERSION=$(${CROSS}ld --version | ld_version) ++LD_NO_DL_MIN_VERSION=$(echo 2.26 | ld_version) ++if [ "$LD_VERSION" -ge "$LD_NO_DL_MIN_VERSION" ] ; then ++ nodl="--no-dynamic-linker" ++fi + + platformo=$object/"$platform".o + lds=$object/zImage.lds +@@ -412,7 +434,7 @@ if [ "$platform" != "miboot" ]; then + if [ -n "$link_address" ] ; then + text_start="-Ttext $link_address" + fi +- ${CROSS}ld -m $format -T $lds $text_start $pie -o "$ofile" \ ++ ${CROSS}ld -m $format -T $lds $text_start $pie $nodl -o "$ofile" \ + $platformo $tmp $object/wrapper.a + rm $tmp + fi diff --git a/queue-4.4/powerpc-fix-compiling-a-be-kernel-with-a-powerpc64le-toolchain.patch b/queue-4.4/powerpc-fix-compiling-a-be-kernel-with-a-powerpc64le-toolchain.patch new file mode 100644 index 00000000000..4a276f1c5db --- /dev/null +++ b/queue-4.4/powerpc-fix-compiling-a-be-kernel-with-a-powerpc64le-toolchain.patch @@ -0,0 +1,61 @@ +From 4dc831aa88132f835cefe876aa0206977c4d7710 Mon Sep 17 00:00:00 2001 +From: Nicholas Piggin +Date: Sun, 27 Nov 2016 13:46:20 +1100 +Subject: powerpc: Fix compiling a BE kernel with a powerpc64le toolchain + +From: Nicholas Piggin + +commit 4dc831aa88132f835cefe876aa0206977c4d7710 upstream. + +GCC can compile with either endian, but the default ABI version is set +based on the default endianness of the toolchain. Alan Modra says: + + you need both -mbig and -mabi=elfv1 to make a powerpc64le gcc + generate powerpc64 code + +The opposite is true for powerpc64 when generating -mlittle it +requires -mabi=elfv2 to generate v2 ABI, which we were already doing. + +This change adds ABI annotations together with endianness for all cases, +LE and BE. This fixes the case of building a BE kernel with a toolchain +that is LE by default. + +Signed-off-by: Nicholas Piggin +Tested-by: Naveen N. Rao +Signed-off-by: Michael Ellerman +Cc: Andrew Donnellan +Signed-off-by: Greg Kroah-Hartman + +--- + arch/powerpc/Makefile | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +--- a/arch/powerpc/Makefile ++++ b/arch/powerpc/Makefile +@@ -79,8 +79,15 @@ GNUTARGET := powerpc + MULTIPLEWORD := -mmultiple + endif + +-cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) ++ifdef CONFIG_PPC64 ++cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1) ++cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mcall-aixdesc) ++aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1) ++aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2 ++endif ++ + cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian ++cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) + ifneq ($(cc-name),clang) + cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align + endif +@@ -120,7 +127,9 @@ ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y) + CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc)) + AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2) + else ++CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1) + CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcall-aixdesc) ++AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1) + endif + CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc)) + CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions) diff --git a/queue-4.4/powerpc-makefile-use-cflags-y-aflags-y-for-setting-endian-options.patch b/queue-4.4/powerpc-makefile-use-cflags-y-aflags-y-for-setting-endian-options.patch new file mode 100644 index 00000000000..47b3bc35d81 --- /dev/null +++ b/queue-4.4/powerpc-makefile-use-cflags-y-aflags-y-for-setting-endian-options.patch @@ -0,0 +1,84 @@ +From 164af597ce945751e2dcd53d0a86e84203a6d117 Mon Sep 17 00:00:00 2001 +From: Michael Ellerman +Date: Tue, 9 Aug 2016 22:43:46 +1000 +Subject: powerpc/Makefile: Use cflags-y/aflags-y for setting endian options + +From: Michael Ellerman + +commit 164af597ce945751e2dcd53d0a86e84203a6d117 upstream. + +When we introduced the little endian support, we added the endian flags +to CC directly using override. I don't know the history of why we did +that, I suspect no one does. + +Although this mostly works, it has one bug, which is that CROSS32CC +doesn't get -mbig-endian. That means when the compiler is little endian +by default and the user is building big endian, vdso32 is incorrectly +compiled as little endian and the kernel fails to build. + +Instead we can add the endian flags to cflags-y/aflags-y, and then +append those to KBUILD_CFLAGS/KBUILD_AFLAGS. + +This has the advantage of being 1) less ugly, 2) the documented way of +adding flags in the arch Makefile and 3) it fixes building vdso32 with a +LE toolchain. + +Signed-off-by: Michael Ellerman +Cc: Andrew Donnellan +Signed-off-by: Greg Kroah-Hartman + +--- + arch/powerpc/Makefile | 22 ++++++++++++---------- + 1 file changed, 12 insertions(+), 10 deletions(-) + +--- a/arch/powerpc/Makefile ++++ b/arch/powerpc/Makefile +@@ -66,29 +66,28 @@ endif + UTS_MACHINE := $(OLDARCH) + + ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y) +-override CC += -mlittle-endian +-ifneq ($(cc-name),clang) +-override CC += -mno-strict-align +-endif +-override AS += -mlittle-endian + override LD += -EL +-override CROSS32CC += -mlittle-endian + override CROSS32AS += -mlittle-endian + LDEMULATION := lppc + GNUTARGET := powerpcle + MULTIPLEWORD := -mno-multiple + KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect) + else +-ifeq ($(call cc-option-yn,-mbig-endian),y) +-override CC += -mbig-endian +-override AS += -mbig-endian +-endif + override LD += -EB + LDEMULATION := ppc + GNUTARGET := powerpc + MULTIPLEWORD := -mmultiple + endif + ++cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) ++cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian ++ifneq ($(cc-name),clang) ++ cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align ++endif ++ ++aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) ++aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian ++ + ifeq ($(HAS_BIARCH),y) + override AS += -a$(CONFIG_WORD_SIZE) + override LD += -m elf$(CONFIG_WORD_SIZE)$(LDEMULATION) +@@ -212,6 +211,9 @@ cpu-as-$(CONFIG_E200) += -Wa,-me200 + KBUILD_AFLAGS += $(cpu-as-y) + KBUILD_CFLAGS += $(cpu-as-y) + ++KBUILD_AFLAGS += $(aflags-y) ++KBUILD_CFLAGS += $(cflags-y) ++ + head-y := arch/powerpc/kernel/head_$(CONFIG_WORD_SIZE).o + head-$(CONFIG_8xx) := arch/powerpc/kernel/head_8xx.o + head-$(CONFIG_40x) := arch/powerpc/kernel/head_40x.o diff --git a/queue-4.4/series b/queue-4.4/series index 7e96c9b3b2e..3898518b732 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -1,2 +1,5 @@ kvm-mmu-don-t-read-pdptes-when-paging-is-not-enabled.patch mips-bcm63xx-fix-switch-core-reset-on-bcm6368.patch +powerpc-makefile-use-cflags-y-aflags-y-for-setting-endian-options.patch +powerpc-fix-compiling-a-be-kernel-with-a-powerpc64le-toolchain.patch +powerpc-boot-request-no-dynamic-linker-for-boot-wrapper.patch