linux-brain/arch
Arnd Bergmann 48a5449c0b ARM: 9081/1: fix gcc-10 thumb2-kernel regression
commit dad7b9896a5dbac5da8275d5a6147c65c81fb5f2 upstream.

When building the kernel wtih gcc-10 or higher using the
CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y flag, the compiler picks a slightly
different set of registers for the inline assembly in cpu_init() that
subsequently results in a corrupt kernel stack as well as remaining in
FIQ mode. If a banked register is used for the last argument, the wrong
version of that register gets loaded into CPSR_c.  When building in Arm
mode, the arguments are passed as immediate values and the bug cannot
happen.

This got introduced when Daniel reworked the FIQ handling and was
technically always broken, but happened to work with both clang and gcc
before gcc-10 as long as they picked one of the lower registers.
This is probably an indication that still very few people build the
kernel in Thumb2 mode.

Marek pointed out the problem on IRC, Arnd narrowed it down to this
inline assembly and Russell pinpointed the exact bug.

Change the constraints to force the final mode switch to use a non-banked
register for the argument to ensure that the correct constant gets loaded.
Another alternative would be to always use registers for the constant
arguments to avoid the #ifdef that has now become more complex.

Cc: <stable@vger.kernel.org> # v3.18+
Cc: Daniel Thompson <daniel.thompson@linaro.org>
Reported-by: Marek Vasut <marek.vasut@gmail.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Fixes: c0e7f7ee71 ("ARM: 8150/3: fiq: Replace default FIQ handler")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-30 08:47:43 -04:00
..
alpha alpha: fix annotation of io{read,write}{16,32}be() 2020-08-26 10:40:58 +02:00
arc ARCv2: save ABI registers across signal handling 2021-06-23 14:41:29 +02:00
arm ARM: 9081/1: fix gcc-10 thumb2-kernel regression 2021-06-30 08:47:43 -04:00
arm64 KVM: arm64: Fix debug register indexing 2021-06-10 13:37:15 +02:00
c6x mm: consolidate pgtable_cache_init() and pgd_cache_init() 2019-09-24 15:54:09 -07:00
csky csky: change a Kconfig symbol name to fix e1000 build error 2021-04-28 13:19:16 +02:00
h8300 h8300: fix PREEMPTION build, TI_PRE_COUNT undefined 2021-02-17 10:35:18 +01:00
hexagon hexagon: define ioremap_uc 2020-05-10 10:31:31 +02:00
ia64 tweewide: Fix most Shebang lines 2021-05-22 11:38:30 +02:00
m68k m68k: mvme147,mvme16x: Don't wipe PCC timer config bits 2021-05-14 09:44:19 +02:00
microblaze microblaze: Prevent the overflow of the start 2020-02-24 08:37:02 +01:00
mips MIPS: Fix kernel hang under FUNCTION_GRAPH_TRACER and PREEMPT_TRACER 2021-06-16 11:59:37 +02:00
nds32 nds32: flush_dcache_page: use page_mapping_file to avoid races with swapoff 2021-04-14 08:24:10 +02:00
nios2 nios2 update for v5.4-rc1 2019-09-27 13:02:19 -07:00
openrisc openrisc: Define memory barrier mb 2021-06-03 08:59:11 +02:00
parisc parisc: avoid a warning on u8 cast for cmpxchg on u8 pointers 2021-04-14 08:24:11 +02:00
powerpc powerpc/fsl: set fsl,i2c-erratum-a004447 flag for P1010 i2c controllers 2021-06-16 11:59:38 +02:00
riscv riscv: Use -mno-relax when using lld linker 2021-06-18 09:58:58 +02:00
s390 KVM: s390: split kvm_s390_real_to_abs 2021-05-14 09:44:15 +02:00
sh sh: dma: fix kconfig dependency for G2_DMA 2021-01-27 11:47:52 +01:00
sparc sparc64: Fix opcode filtering in handling of no fault loads 2021-03-30 14:35:22 +02:00
um um: Disable CONFIG_GCOV with MODULES 2021-05-22 11:38:28 +02:00
unicore32 mm: treewide: clarify pgtable_page_{ctor,dtor}() naming 2019-09-26 10:10:44 -07:00
x86 x86/fpu: Reset state for all signal restore failures 2021-06-23 14:41:29 +02:00
xtensa xtensa: move coprocessor_flush to the .text section 2021-04-07 14:47:42 +02:00
.gitignore
Kconfig Revert: "ring-buffer: Remove HAVE_64BIT_ALIGNED_ACCESS" 2020-12-30 11:51:47 +01:00