mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-05 19:35:52 +03:00
aarch64: simplify calls to __libc_arm_za_disable in assembly
There is no functional change in this patch. We remove stores and loads to stack, return address signing, and redundant CFI directives before and after call to __libc_arm_za_disable(). The __libc_arm_za_disable implementation follows special calling convention that allows to avoid most of the operations that would be necessary for a call to a normal function (see [1] for details). First, we rely on __libc_arm_za_disable() not clobbering certain registers, and we put return address into one of these registers. Now we don't need to store it on stack, so we don't need to sign return address using PAC. Second, as a result of the above, we don't need to update the CFI offset. This patch provides small optimisation avoiding unnecessary store and load on stack also simplifies assembly code and CFI directives. [1]: https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
@@ -26,21 +26,16 @@
|
|||||||
ENTRY (__longjmp)
|
ENTRY (__longjmp)
|
||||||
|
|
||||||
#if IS_IN(libc)
|
#if IS_IN(libc)
|
||||||
/* Disable ZA state of SME in libc.a and libc.so, but not in ld.so. */
|
/* Disable ZA state of SME in libc.a and libc.so, but not in ld.so.
|
||||||
paciasp
|
The calling convention of __libc_arm_za_disable allows to do
|
||||||
cfi_negate_ra_state
|
this thus allowing to avoid saving to and reading from stack.
|
||||||
stp x29, x30, [sp, -16]!
|
As a result we also don't need to sign the return address and
|
||||||
cfi_adjust_cfa_offset (16)
|
check it after returning because it is not stored to stack. */
|
||||||
cfi_rel_offset (x29, 0)
|
mov x13, x30
|
||||||
cfi_rel_offset (x30, 8)
|
cfi_register (x30, x13)
|
||||||
mov x29, sp
|
|
||||||
bl __libc_arm_za_disable
|
bl __libc_arm_za_disable
|
||||||
ldp x29, x30, [sp], 16
|
mov x30, x13
|
||||||
cfi_adjust_cfa_offset (-16)
|
cfi_register (x13, x30)
|
||||||
cfi_restore (x29)
|
|
||||||
cfi_restore (x30)
|
|
||||||
autiasp
|
|
||||||
cfi_negate_ra_state
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cfi_def_cfa (x0, 0)
|
cfi_def_cfa (x0, 0)
|
||||||
|
@@ -37,21 +37,16 @@ ENTRY_ALIGN (__sigsetjmp, 2)
|
|||||||
1:
|
1:
|
||||||
|
|
||||||
#if IS_IN(libc)
|
#if IS_IN(libc)
|
||||||
/* Disable ZA state of SME in libc.a and libc.so, but not in ld.so. */
|
/* Disable ZA state of SME in libc.a and libc.so, but not in ld.so.
|
||||||
paciasp
|
The calling convention of __libc_arm_za_disable allows to do
|
||||||
cfi_negate_ra_state
|
this thus allowing to avoid saving to and reading from stack.
|
||||||
stp x29, x30, [sp, -16]!
|
As a result we also don't need to sign the return address and
|
||||||
cfi_adjust_cfa_offset (16)
|
check it after returning because it is not stored to stack. */
|
||||||
cfi_rel_offset (x29, 0)
|
mov x13, x30
|
||||||
cfi_rel_offset (x30, 8)
|
cfi_register (x30, x13)
|
||||||
mov x29, sp
|
|
||||||
bl __libc_arm_za_disable
|
bl __libc_arm_za_disable
|
||||||
ldp x29, x30, [sp], 16
|
mov x30, x13
|
||||||
cfi_adjust_cfa_offset (-16)
|
cfi_register (x13, x30)
|
||||||
cfi_restore (x29)
|
|
||||||
cfi_restore (x30)
|
|
||||||
autiasp
|
|
||||||
cfi_negate_ra_state
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
stp x19, x20, [x0, #JB_X19<<3]
|
stp x19, x20, [x0, #JB_X19<<3]
|
||||||
|
@@ -48,21 +48,16 @@ ENTRY (__setcontext)
|
|||||||
cbz x0, 1f
|
cbz x0, 1f
|
||||||
b C_SYMBOL_NAME (__syscall_error)
|
b C_SYMBOL_NAME (__syscall_error)
|
||||||
1:
|
1:
|
||||||
/* Disable ZA of SME. */
|
/* Clear ZA state of SME. */
|
||||||
paciasp
|
/* The calling convention of __libc_arm_za_disable allows to do
|
||||||
cfi_negate_ra_state
|
this thus allowing to avoid saving to and reading from stack.
|
||||||
stp x29, x30, [sp, -16]!
|
As a result we also don't need to sign the return address and
|
||||||
cfi_adjust_cfa_offset (16)
|
check it after returning because it is not stored to stack. */
|
||||||
cfi_rel_offset (x29, 0)
|
mov x13, x30
|
||||||
cfi_rel_offset (x30, 8)
|
cfi_register (x30, x13)
|
||||||
mov x29, sp
|
|
||||||
bl __libc_arm_za_disable
|
bl __libc_arm_za_disable
|
||||||
ldp x29, x30, [sp], 16
|
mov x30, x13
|
||||||
cfi_adjust_cfa_offset (-16)
|
cfi_register (x13, x30)
|
||||||
cfi_restore (x29)
|
|
||||||
cfi_restore (x30)
|
|
||||||
autiasp
|
|
||||||
cfi_negate_ra_state
|
|
||||||
/* Restore the general purpose registers. */
|
/* Restore the general purpose registers. */
|
||||||
mov x0, x9
|
mov x0, x9
|
||||||
cfi_def_cfa (x0, 0)
|
cfi_def_cfa (x0, 0)
|
||||||
|
Reference in New Issue
Block a user