[3/4] aarch64: Add setcontext support for SME

Message ID 4d546102e14a17458005727b7c8a692bcd74e435.1702051831.git.szabolcs.nagy@arm.com
State Committed
Commit 9d30e5cf9687559d942514c780332d53b0617f0b
Headers
Series aarch64: Add SME support |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Testing passed

Commit Message

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

Also fixes swapcontext which uses setcontext internally.
---
 sysdeps/unix/sysv/linux/aarch64/setcontext.S | 19 +++++++++++++++++++
 1 file changed, 19 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, setcontext has to call
> __libc_arm_za_disable.
> 
> Also fixes swapcontext which uses setcontext internally.

LGTM, thanks.

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

> ---
>  sysdeps/unix/sysv/linux/aarch64/setcontext.S | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/sysdeps/unix/sysv/linux/aarch64/setcontext.S b/sysdeps/unix/sysv/linux/aarch64/setcontext.S
> index d7756015c5..fe75adf61e 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/setcontext.S
> +++ b/sysdeps/unix/sysv/linux/aarch64/setcontext.S
> @@ -49,6 +49,25 @@ ENTRY (__setcontext)
>  	cbz	x0, 1f
>  	b	C_SYMBOL_NAME (__syscall_error)
>  1:
> +	/* Disable ZA of SME.  */
> +#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
>  	/* Restore the general purpose registers.  */
>  	mov	x0, x9
>  	cfi_def_cfa (x0, 0)
  

Patch

diff --git a/sysdeps/unix/sysv/linux/aarch64/setcontext.S b/sysdeps/unix/sysv/linux/aarch64/setcontext.S
index d7756015c5..fe75adf61e 100644
--- a/sysdeps/unix/sysv/linux/aarch64/setcontext.S
+++ b/sysdeps/unix/sysv/linux/aarch64/setcontext.S
@@ -49,6 +49,25 @@  ENTRY (__setcontext)
 	cbz	x0, 1f
 	b	C_SYMBOL_NAME (__syscall_error)
 1:
+	/* Disable ZA of SME.  */
+#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
 	/* Restore the general purpose registers.  */
 	mov	x0, x9
 	cfi_def_cfa (x0, 0)