Re: [PATCH 06/14] ARM: disallow CONFIG_THUMB with ARMv4
From: Nick Desaulniers <hidden>
Date: 2021-09-29 18:52:27
Also in:
lkml, llvm
On Tue, Sep 28, 2021 at 8:42 AM Arnd Bergmann [off-list ref] wrote:
From: Arnd Bergmann <arnd@arndb.de> 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
does `mov pc, lr` work here, with a preprocessor guard on CPU_32v4? Or better yet... If `ret` is just an assembler macro (arch/arm/include/asm/assembler.h#L449), then perhaps always just using `ret` would be preferable here? In that case, it looks like `usr_ret` could be outright replaced with just expansions of `ret`? Just spitballing ideas; like you said, maybe not worth fixing.
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.
I suspect this is a Clang's integrated assembler vs GAS difference
(compiler irrelevant); clang's assembler is more strict that `bx lr`
requires armvt (CPU_32v4T). Though I can reproduce that exact message
in local testing with GAS:
$ cat foo.s
bx lr
$ arm-linux-gnueabi-as -march=armv4 -c foo.s
foo.s: Assembler messages:
foo.s:1: Error: selected processor does not support `bx lr' in ARM mode
$ arm-linux-gnueabi-as -march=armv4t -c foo.s
$ arm-linux-gnueabi-objdump -dr a.out
...
00000000 <.text>:
0: e12fff1e bx lr
0: R_ARM_V4BX *ABS*
The `<instantiation>:2:2` makes me think of inline asm.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Nick Desaulniers <redacted>
quoted hunk ↗ jump to hunk
--- arch/arm/mm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig index 82aa990c4180..58afba346729 100644 --- a/arch/arm/mm/Kconfig +++ b/arch/arm/mm/Kconfig@@ -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 --2.29.2
-- Thanks, ~Nick Desaulniers _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel