diff options
author | Ard Biesheuvel <ardb@kernel.org> | 2021-10-05 09:15:35 +0200 |
---|---|---|
committer | Ard Biesheuvel <ardb@kernel.org> | 2021-12-03 15:11:31 +0100 |
commit | b3ab60b1794c20fe7033d2c8f7dcdef87ada1a23 (patch) | |
tree | 8095c4e134c96662cd2933e19dd0b92f3a919e80 /arch/arm/include/asm | |
parent | 08572cd41955166e387d9b4984294d37f8f7526c (diff) | |
download | linux-next-b3ab60b1794c20fe7033d2c8f7dcdef87ada1a23.tar.gz |
ARM: assembler: introduce bl_r macro
Add a bl_r macro that abstract the difference between the ways indirect
calls are performed on older and newer ARM architecture revisions.
The main difference is to prefer blx instructions over explicit LR
assignments when possible, as these tend to confuse the prediction logic
in out-of-order cores when speculating across a function return.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Keith Packard <keithpac@amazon.com>
Tested-by: Marc Zyngier <maz@kernel.org>
Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
Diffstat (limited to 'arch/arm/include/asm')
-rw-r--r-- | arch/arm/include/asm/assembler.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h index 7d23d4bb2168..870bfaea4318 100644 --- a/arch/arm/include/asm/assembler.h +++ b/arch/arm/include/asm/assembler.h @@ -624,4 +624,19 @@ THUMB( orr \reg , \reg , #PSR_T_BIT ) .endif .endm + /* + * bl_r - branch and link to register + * + * @dst: target to branch to + * @c: conditional opcode suffix + */ + .macro bl_r, dst:req, c + .if __LINUX_ARM_ARCH__ < 6 + mov\c lr, pc + mov\c pc, \dst + .else + blx\c \dst + .endif + .endm + #endif /* __ASM_ASSEMBLER_H__ */ |