mirror of
https://github.com/torvalds/linux.git
synced 2024-12-13 06:32:50 +00:00
5be8b70af1
The LSE atomics implementation uses runtime patching to patch in calls
to out of line non-LSE atomics implementations on cores that lack hardware
support for LSE. To avoid paying the overhead cost of a function call even
if no call ends up being made, the bl instruction is kept invisible to the
compiler, and the out of line implementations preserve all registers, not
just the ones that they are required to preserve as per the AAPCS64.
However, commit fd045f6cd9
("arm64: add support for module PLTs") added
support for routing branch instructions via veneers if the branch target
offset exceeds the range of the ordinary relative branch instructions.
Since this deals with jump and call instructions that are exposed to ELF
relocations, the PLT code uses x16 to hold the address of the branch target
when it performs an indirect branch-to-register, something which is
explicitly allowed by the AAPCS64 (and ordinary compiler generated code
does not expect register x16 or x17 to retain their values across a bl
instruction).
Since the lse runtime patched bl instructions don't adhere to the AAPCS64,
they don't deal with this clobbering of registers x16 and x17. So add them
to the clobber list of the asm() statements that perform the call
instructions, and drop x16 and x17 from the list of registers that are
callee saved in the out of line non-LSE implementations.
In addition, since we have given these functions two scratch registers,
they no longer need to stack/unstack temp registers.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
[will: factored clobber list into #define, updated Makefile comment]
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
20 lines
1006 B
Makefile
20 lines
1006 B
Makefile
lib-y := bitops.o clear_user.o delay.o copy_from_user.o \
|
|
copy_to_user.o copy_in_user.o copy_page.o \
|
|
clear_page.o memchr.o memcpy.o memmove.o memset.o \
|
|
memcmp.o strcmp.o strncmp.o strlen.o strnlen.o \
|
|
strchr.o strrchr.o
|
|
|
|
# Tell the compiler to treat all general purpose registers (with the
|
|
# exception of the IP registers, which are already handled by the caller
|
|
# in case of a PLT) as callee-saved, which allows for efficient runtime
|
|
# patching of the bl instruction in the caller with an atomic instruction
|
|
# when supported by the CPU. Result and argument registers are handled
|
|
# correctly, based on the function prototype.
|
|
lib-$(CONFIG_ARM64_LSE_ATOMICS) += atomic_ll_sc.o
|
|
CFLAGS_atomic_ll_sc.o := -fcall-used-x0 -ffixed-x1 -ffixed-x2 \
|
|
-ffixed-x3 -ffixed-x4 -ffixed-x5 -ffixed-x6 \
|
|
-ffixed-x7 -fcall-saved-x8 -fcall-saved-x9 \
|
|
-fcall-saved-x10 -fcall-saved-x11 -fcall-saved-x12 \
|
|
-fcall-saved-x13 -fcall-saved-x14 -fcall-saved-x15 \
|
|
-fcall-saved-x18
|