]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
aarch64: define macro for calling __libc_arm_za_disable
authorYury Khrustalev <yury.khrustalev@arm.com>
Thu, 25 Sep 2025 14:51:30 +0000 (15:51 +0100)
committerYury Khrustalev <yury.khrustalev@arm.com>
Mon, 20 Oct 2025 12:10:09 +0000 (13:10 +0100)
A common sequence of instructions is used in several places
in assembly files, so define it in one place as an assembly
macro.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit b4b713bd8921aff04773557da94fabb5fb9dd705)

sysdeps/aarch64/__longjmp.S
sysdeps/aarch64/setjmp.S
sysdeps/unix/sysv/linux/aarch64/setcontext.S
sysdeps/unix/sysv/linux/aarch64/sysdep.h

index 70ac02c44b203179720f786b90de891e0a47028d..53b42e1bdc764f22a4bcdde5fb3bc36c7da2b1e9 100644 (file)
 ENTRY (__longjmp)
 
 #if IS_IN(libc)
-       /* Disable ZA state of SME in libc.a and libc.so, but not in ld.so.
-          The calling convention of __libc_arm_za_disable allows to do
-          this thus allowing to avoid saving to and reading from stack.
-          As a result we also don't need to sign the return address and
-          check it after returning because it is not stored to stack.  */
-       mov     x13, x30
-       cfi_register (x30, x13)
-       bl      __libc_arm_za_disable
-       mov     x30, x13
-       cfi_register (x13, x30)
+       /* Disable ZA state of SME in libc.a and libc.so, but not in ld.so.  */
+       CALL_LIBC_ARM_ZA_DISABLE
 #endif
 
        cfi_def_cfa (x0, 0)
index 53c5e7d8ccb1ed6920e46fd52c8266d91936f386..92cedfad830b71a6a8bc45a777867a8d9d3ae89c 100644 (file)
@@ -37,16 +37,8 @@ ENTRY_ALIGN (__sigsetjmp, 2)
 1:
 
 #if IS_IN(libc)
-       /* Disable ZA state of SME in libc.a and libc.so, but not in ld.so.
-          The calling convention of __libc_arm_za_disable allows to do
-          this thus allowing to avoid saving to and reading from stack.
-          As a result we also don't need to sign the return address and
-          check it after returning because it is not stored to stack.  */
-       mov     x13, x30
-       cfi_register (x30, x13)
-       bl      __libc_arm_za_disable
-       mov     x30, x13
-       cfi_register (x13, x30)
+       /* Disable ZA state of SME in libc.a and libc.so, but not in ld.so.  */
+       CALL_LIBC_ARM_ZA_DISABLE
 #endif
 
        stp     x19, x20, [x0, #JB_X19<<3]
index d9716f012ead35fc474c85424b0cc6a059a8b165..8e985946635723c09a336dbe752361501335c9a2 100644 (file)
@@ -49,15 +49,7 @@ ENTRY (__setcontext)
        b       C_SYMBOL_NAME (__syscall_error)
 1:
        /* Clear ZA state of SME.  */
-       /* The calling convention of __libc_arm_za_disable allows to do
-          this thus allowing to avoid saving to and reading from stack.
-          As a result we also don't need to sign the return address and
-          check it after returning because it is not stored to stack.  */
-       mov     x13, x30
-       cfi_register (x30, x13)
-       bl      __libc_arm_za_disable
-       mov     x30, x13
-       cfi_register (x13, x30)
+       CALL_LIBC_ARM_ZA_DISABLE
        /* Restore the general purpose registers.  */
        mov     x0, x9
        cfi_def_cfa (x0, 0)
index f0e8d64eefac3581108d93a96fc60941aec00dc1..fa01386b25c57b7edf96b133dedc8306919ac455 100644 (file)
     mov x8, SYS_ify (syscall_name);            \
     svc 0
 
+/* Clear ZA state of SME (ASM version).  */
+/* The __libc_arm_za_disable function has special calling convention
+   that allows to call it without stack manipulation and preserving
+   most of the registers.  */
+       .macro CALL_LIBC_ARM_ZA_DISABLE
+       mov             x13, x30
+       .cfi_register   x30, x13
+       bl              __libc_arm_za_disable
+       mov             x30, x13
+       .cfi_register   x13, x30
+       .endm
+
 #else /* not __ASSEMBLER__ */
 
 # define VDSO_NAME  "LINUX_2.6.39"