summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Robinson <pbrobinson@gmail.com>2016-04-11 10:37:43 +0100
committerPeter Robinson <pbrobinson@gmail.com>2016-04-11 10:37:43 +0100
commit0ef5eed43781990438ae866b7f79eb5adcdfed7c (patch)
tree859c03b46acaf16feac93929b401f70e08fc52cd
parent2b5ee7885ac48d21cf2a48a43ad4602a08d6dc54 (diff)
downloadkernel-0ef5eed43781990438ae866b7f79eb5adcdfed7c.tar.gz
kernel-0ef5eed43781990438ae866b7f79eb5adcdfed7c.tar.xz
kernel-0ef5eed43781990438ae866b7f79eb5adcdfed7c.zip
Add upstream patch to fix IDIV issue when booting on Cortex-A7/15/17 devices
-rw-r--r--arm-fix-idiv.patch52
-rw-r--r--config-armv7-generic3
-rw-r--r--kernel.spec5
3 files changed, 58 insertions, 2 deletions
diff --git a/arm-fix-idiv.patch b/arm-fix-idiv.patch
new file mode 100644
index 000000000..26eac32d8
--- /dev/null
+++ b/arm-fix-idiv.patch
@@ -0,0 +1,52 @@
+From 208fae5c3b9431013ad7bcea07cbcee114e7d163 Mon Sep 17 00:00:00 2001
+From: Nicolas Pitre <nicolas.pitre@linaro.org>
+Date: Mon, 14 Mar 2016 02:55:45 +0100
+Subject: ARM: 8550/1: protect idiv patching against undefined gcc behavior
+
+It was reported that a kernel with CONFIG_ARM_PATCH_IDIV=y stopped
+booting when compiled with the upcoming gcc 6. Turns out that turning
+a function address into a writable array is undefined and gcc 6 decided
+it was OK to omit the store to the first word of the function while
+still preserving the store to the second word.
+
+Even though gcc 6 is now fixed to behave more coherently, it is a
+mystery that gcc 4 and gcc 5 actually produce wanted code in the kernel.
+And in fact the reduced test case to illustrate the issue does indeed
+break with gcc < 6 as well.
+
+In any case, let's guard the kernel against undefined compiler behavior
+by hiding the nature of the array location as suggested by gcc
+developers.
+
+Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70128
+
+Signed-off-by: Nicolas Pitre <nico@linaro.org>
+Reported-by: Marcin Juszkiewicz <mjuszkiewicz@redhat.com>
+Cc: Arnd Bergmann <arnd@arndb.de>
+Cc: stable@vger.kernel.org # v4.5
+Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
+---
+ arch/arm/kernel/setup.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
+index 139791e..a28fce0 100644
+--- a/arch/arm/kernel/setup.c
++++ b/arch/arm/kernel/setup.c
+@@ -430,11 +430,13 @@ static void __init patch_aeabi_idiv(void)
+ pr_info("CPU: div instructions available: patching division code\n");
+
+ fn_addr = ((uintptr_t)&__aeabi_uidiv) & ~1;
++ asm ("" : "+g" (fn_addr));
+ ((u32 *)fn_addr)[0] = udiv_instruction();
+ ((u32 *)fn_addr)[1] = bx_lr_instruction();
+ flush_icache_range(fn_addr, fn_addr + 8);
+
+ fn_addr = ((uintptr_t)&__aeabi_idiv) & ~1;
++ asm ("" : "+g" (fn_addr));
+ ((u32 *)fn_addr)[0] = sdiv_instruction();
+ ((u32 *)fn_addr)[1] = bx_lr_instruction();
+ flush_icache_range(fn_addr, fn_addr + 8);
+--
+cgit v0.12
+
diff --git a/config-armv7-generic b/config-armv7-generic
index c7c2d98b9..21cc00f3a 100644
--- a/config-armv7-generic
+++ b/config-armv7-generic
@@ -19,8 +19,7 @@ CONFIG_ARM_UNWIND=y
CONFIG_ARM_THUMB=y
CONFIG_ARM_THUMBEE=y
CONFIG_ARM_ASM_UNIFIED=y
-# see rhbz 1303147
-# CONFIG_ARM_PATCH_IDIV is not set
+CONFIG_ARM_PATCH_IDIV=y
CONFIG_ARM_CPU_TOPOLOGY=y
CONFIG_ARM_DMA_MEM_BUFFERABLE=y
CONFIG_SWP_EMULATE=y
diff --git a/kernel.spec b/kernel.spec
index ce4fa5940..0fa2dc49a 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -510,6 +510,8 @@ Patch423: Initial-AllWinner-A64-and-PINE64-support.patch
# http://www.spinics.net/lists/arm-kernel/msg493431.html
Patch424: efi-arm64-don-t-apply-MEMBLOCK_NOMAP-to-UEFI-memory-map-mapping.patch
+Patch425: arm-fix-idiv.patch
+
# http://patchwork.ozlabs.org/patch/587554/
Patch430: ARM-tegra-usb-no-reset.patch
@@ -2211,6 +2213,9 @@ fi
#
#
%changelog
+* Mon Apr 11 2016 Peter Robinson <pbrobinson@fedoraproject.org>
+- Add upstream patch to fix IDIV issue when booting on Cortex-A7/15/17 devices
+
* Thu Apr 07 2016 Justin M. Forbes <jforbes@fedoraproject.org>
- Enable Full Randomization on 32bit x86 CVE-2016-3672 (rhbz 1324749 1324750)