ARM: 9137/1: disallow CONFIG_THUMB with ARMv4
authorArnd Bergmann <arnd@arndb.de>
Mon, 18 Oct 2021 14:30:07 +0000 (15:30 +0100)
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Mon, 25 Oct 2021 12:12:33 +0000 (13:12 +0100)
We can currently build a multi-cpu enabled kernel that allows both ARMv4
and ARMv5 CPUs, and also supports THUMB mode in user space.

However, returning to user space in this configuration with the usr_ret
macro requires the use of the 'bx' instruction, which is refused by
the assembler:

arch/arm/kernel/entry-armv.S: Assembler messages:
arch/arm/kernel/entry-armv.S:937: Error: selected processor does not support `bx lr' in ARM mode
arch/arm/kernel/entry-armv.S:960: Error: selected processor does not support `bx lr' in ARM mode
arch/arm/kernel/entry-armv.S:1003: Error: selected processor does not support `bx lr' in ARM mode
<instantiation>:2:2: note: instruction requires: armv4t
 bx lr

While it would be possible to handle this correctly in principle, doing so
seems to not be worth it, if we can simply avoid the problem by enforcing
that a kernel supporting both ARMv4 and a later CPU architecture cannot
run THUMB binaries.

This turned up while build-testing with clang; for some reason,
gcc never triggered the problem.

Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
arch/arm/mm/Kconfig

index 82aa990c4180cc3669bdc1f23f9cd842c2634b8b..58afba346729960e2101f4d26f682f58ce187398 100644 (file)
@@ -675,7 +675,7 @@ config ARM_PV_FIXUP
 
 config ARM_THUMB
        bool "Support Thumb user binaries" if !CPU_THUMBONLY && EXPERT
-       depends on CPU_THUMB_CAPABLE
+       depends on CPU_THUMB_CAPABLE && !CPU_32v4
        default y
        help
          Say Y if you want to include kernel support for running user space