]> git.baikalelectronics.ru Git - kernel.git/commit
arm64: lse: deal with clobbered IP registers after branch via PLT
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 25 Feb 2016 19:48:53 +0000 (20:48 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 26 Feb 2016 18:35:02 +0000 (18:35 +0000)
commite723cac6ab8e43e0900a6c72167a5345d8fa5ba0
treecf0e7c75c56791c07c5905286fec7fc95437b151
parent9b0f977d9a3387f31b72e5d7195120da1e3fa6b8
arm64: lse: deal with clobbered IP registers after branch via PLT

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 15d9bb42246c ("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>
arch/arm64/include/asm/atomic_lse.h
arch/arm64/include/asm/lse.h
arch/arm64/lib/Makefile