]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
aarch64: Disable ZA state of SME in setjmp and sigsetjmp
authorYury Khrustalev <yury.khrustalev@arm.com>
Mon, 28 Apr 2025 14:12:04 +0000 (15:12 +0100)
committerYury Khrustalev <yury.khrustalev@arm.com>
Thu, 15 May 2025 13:23:03 +0000 (14:23 +0100)
Due to the nature of the ZA state, setjmp() should clear it in the
same manner as it is already done by longjmp.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
sysdeps/aarch64/setjmp.S

index d82d62c0a1c4f718982d9d8c4d4144ef94cac4e5..83d1e342bc368e76272b11f282775ec1ee9b19e7 100644 (file)
@@ -35,6 +35,29 @@ libc_hidden_def (_setjmp)
 
 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.  */
+# if HAVE_AARCH64_PAC_RET
+       PACIASP
+       cfi_window_save
+# endif
+       stp     x29, x30, [sp, -16]!
+       cfi_adjust_cfa_offset (16)
+       cfi_rel_offset (x29, 0)
+       cfi_rel_offset (x30, 8)
+       mov     x29, sp
+       bl      __libc_arm_za_disable
+       ldp     x29, x30, [sp], 16
+       cfi_adjust_cfa_offset (-16)
+       cfi_restore (x29)
+       cfi_restore (x30)
+# if HAVE_AARCH64_PAC_RET
+       AUTIASP
+       cfi_window_save
+# endif
+#endif
+
        stp     x19, x20, [x0, #JB_X19<<3]
        stp     x21, x22, [x0, #JB_X21<<3]
        stp     x23, x24, [x0, #JB_X23<<3]