[04/20] aarch64: Fix the extension header write in getcontext and swapcontext

Message ID 4f72249e1bd2b5a772973f9faf3b88e62596fdde.1666877952.git.szabolcs.nagy@arm.com
State Committed
Commit 09c6c6073c925235b385af1d8edf6bc853eeaf60
Headers
Series patches from the morello port |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Szabolcs Nagy Oct. 27, 2022, 3:32 p.m. UTC
  The extension header is two 32bit words and in the last header both
should be 0. There is plenty space in the __reserved area, but it's
better not to write more than we mean to.
---
 sysdeps/unix/sysv/linux/aarch64/getcontext.S  | 4 ++--
 sysdeps/unix/sysv/linux/aarch64/swapcontext.S | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
  

Comments

Adhemerval Zanella Oct. 28, 2022, 2:03 p.m. UTC | #1
On 27/10/22 12:32, Szabolcs Nagy via Libc-alpha wrote:
> The extension header is two 32bit words and in the last header both
> should be 0. There is plenty space in the __reserved area, but it's
> better not to write more than we mean to.

LGTM, thanks.

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

> ---
>  sysdeps/unix/sysv/linux/aarch64/getcontext.S  | 4 ++--
>  sysdeps/unix/sysv/linux/aarch64/swapcontext.S | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/aarch64/getcontext.S b/sysdeps/unix/sysv/linux/aarch64/getcontext.S
> index 15fbd2d1a0..3109cbd99a 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/getcontext.S
> +++ b/sysdeps/unix/sysv/linux/aarch64/getcontext.S
> @@ -86,8 +86,8 @@ ENTRY(__getcontext)
>  	/* Write the termination context extension header.  */
>  	add	x2, x2, #FPSIMD_CONTEXT_SIZE
>  
> -	str	xzr, [x2, #oHEAD + oMAGIC]
> -	str	xzr, [x2, #oHEAD + oSIZE]
> +	str	wzr, [x2, #oHEAD + oMAGIC]
> +	str	wzr, [x2, #oHEAD + oSIZE]
>  
>  	/* Grab the signal mask */
>  	/* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */
> diff --git a/sysdeps/unix/sysv/linux/aarch64/swapcontext.S b/sysdeps/unix/sysv/linux/aarch64/swapcontext.S
> index 1ee2e40272..e3ec9da35d 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/swapcontext.S
> +++ b/sysdeps/unix/sysv/linux/aarch64/swapcontext.S
> @@ -75,8 +75,8 @@ ENTRY(__swapcontext)
>  	/* Write the termination context extension header.  */
>  	add	x2, x2, #FPSIMD_CONTEXT_SIZE
>  
> -	str	xzr, [x2, #oHEAD + oMAGIC]
> -	str	xzr, [x2, #oHEAD + oSIZE]
> +	str	wzr, [x2, #oHEAD + oMAGIC]
> +	str	wzr, [x2, #oHEAD + oSIZE]
>  
>  	/* Preserve ucp.  */
>  	mov	x21, x1
  

Patch

diff --git a/sysdeps/unix/sysv/linux/aarch64/getcontext.S b/sysdeps/unix/sysv/linux/aarch64/getcontext.S
index 15fbd2d1a0..3109cbd99a 100644
--- a/sysdeps/unix/sysv/linux/aarch64/getcontext.S
+++ b/sysdeps/unix/sysv/linux/aarch64/getcontext.S
@@ -86,8 +86,8 @@  ENTRY(__getcontext)
 	/* Write the termination context extension header.  */
 	add	x2, x2, #FPSIMD_CONTEXT_SIZE
 
-	str	xzr, [x2, #oHEAD + oMAGIC]
-	str	xzr, [x2, #oHEAD + oSIZE]
+	str	wzr, [x2, #oHEAD + oMAGIC]
+	str	wzr, [x2, #oHEAD + oSIZE]
 
 	/* Grab the signal mask */
 	/* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */
diff --git a/sysdeps/unix/sysv/linux/aarch64/swapcontext.S b/sysdeps/unix/sysv/linux/aarch64/swapcontext.S
index 1ee2e40272..e3ec9da35d 100644
--- a/sysdeps/unix/sysv/linux/aarch64/swapcontext.S
+++ b/sysdeps/unix/sysv/linux/aarch64/swapcontext.S
@@ -75,8 +75,8 @@  ENTRY(__swapcontext)
 	/* Write the termination context extension header.  */
 	add	x2, x2, #FPSIMD_CONTEXT_SIZE
 
-	str	xzr, [x2, #oHEAD + oMAGIC]
-	str	xzr, [x2, #oHEAD + oSIZE]
+	str	wzr, [x2, #oHEAD + oMAGIC]
+	str	wzr, [x2, #oHEAD + oSIZE]
 
 	/* Preserve ucp.  */
 	mov	x21, x1