diff mbox series

[2/4] aarch64: Add longjmp support for SME

Message ID 199b96a9d02f8cab61c4465cf4dbfaa191588063.1702051831.git.szabolcs.nagy@arm.com
State New
Headers show
Series aarch64: Add SME support | expand

Commit Message

Szabolcs Nagy Dec. 8, 2023, 4:32 p.m. UTC
For the ZA lazy saving scheme to work, longjmp has to call
__libc_arm_za_disable.

In ld.so we assume ZA is not used so longjmp does not need
special support there.
---
 sysdeps/aarch64/__longjmp.S | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Comments

Adhemerval Zanella Netto Dec. 28, 2023, 1:42 p.m. UTC | #1
On 08/12/23 13:32, Szabolcs Nagy wrote:
> For the ZA lazy saving scheme to work, longjmp has to call
> __libc_arm_za_disable.
> 
> In ld.so we assume ZA is not used so longjmp does not need
> special support there.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  sysdeps/aarch64/__longjmp.S | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/sysdeps/aarch64/__longjmp.S b/sysdeps/aarch64/__longjmp.S
> index d743e7478d..659199d7d4 100644
> --- a/sysdeps/aarch64/__longjmp.S
> +++ b/sysdeps/aarch64/__longjmp.S
> @@ -49,6 +49,28 @@ ENTRY (__longjmp)
>  
>  	PTR_ARG (0)
>  
> +#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
> +
>  	ldp	x19, x20, [x0, #JB_X19<<3]
>  	ldp	x21, x22, [x0, #JB_X21<<3]
>  	ldp	x23, x24, [x0, #JB_X23<<3]
diff mbox series

Patch

diff --git a/sysdeps/aarch64/__longjmp.S b/sysdeps/aarch64/__longjmp.S
index d743e7478d..659199d7d4 100644
--- a/sysdeps/aarch64/__longjmp.S
+++ b/sysdeps/aarch64/__longjmp.S
@@ -49,6 +49,28 @@  ENTRY (__longjmp)
 
 	PTR_ARG (0)
 
+#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
+
 	ldp	x19, x20, [x0, #JB_X19<<3]
 	ldp	x21, x22, [x0, #JB_X21<<3]
 	ldp	x23, x24, [x0, #JB_X23<<3]