Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Jan 2026 13:04:31 +0100 (CET)
From:      Ronald Klop <ronald-lists@klop.ws>
To:        Andrew Turner <andrew@FreeBSD.org>
Cc:        dev-commits-src-all@FreeBSD.org, src-committers@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   Re: git: a9e77eb7016d - main - arm64: Correctly align the SVE signal context
Message-ID:  <64525372.1244.1767701071189@localhost>
In-Reply-To: <695cec3f.31a54.43e19fd1@gitrepo.freebsd.org>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
Hi.

Can this be related to this issue?

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=292195
"arm64: panic on coredump with sve instructions"

Regards,
Ronald.

 
Van: Andrew Turner <andrew@FreeBSD.org>
Datum: dinsdag, 6 januari 2026 12:04
Aan: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Onderwerp: git: a9e77eb7016d - main - arm64: Correctly align the SVE signal context
> 
> The branch main has been updated by andrew:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=a9e77eb7016df70723c208fc09fbd01ec23a732d
> 
> commit a9e77eb7016df70723c208fc09fbd01ec23a732d
> Author:     Andrew Turner <andrew@FreeBSD.org>
> AuthorDate: 2026-01-06 10:35:55 +0000
> Commit:     Andrew Turner <andrew@FreeBSD.org>
> CommitDate: 2026-01-06 10:36:37 +0000
> 
>     arm64: Correctly align the SVE signal context
>     
>     The SVE signal context needs to be correctly aligned. Fix this by
>     creating a new macro to calculate the needed size to provide this
>     alignment, and use it when setting and checking the saved SVE signal
>     context.
>     
>     Reported by:    cperciva
>     Reviewed by:    cperciva, markj
>     Sponsored by:   Arm Ltd
>     Differential Revision:  https://reviews.freebsd.org/D54396
> ---
>  sys/arm64/arm64/exec_machdep.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/sys/arm64/arm64/exec_machdep.c b/sys/arm64/arm64/exec_machdep.c
> index 7c50dc93fdb4..207e10ede96c 100644
> --- a/sys/arm64/arm64/exec_machdep.c
> +++ b/sys/arm64/arm64/exec_machdep.c
> @@ -60,6 +60,10 @@
>  #include <machine/vfp.h>
>  #endif
>  
> +#define    CTX_SIZE_SVE(buf_size)                  \
> +    roundup2(sizeof(struct sve_context) + (buf_size),      \
> +      _Alignof(struct sve_context))
> +
>  _Static_assert(sizeof(mcontext_t) == 880, "mcontext_t size incorrect");
>  _Static_assert(sizeof(ucontext_t) == 960, "ucontext_t size incorrect");
>  _Static_assert(sizeof(siginfo_t) == 80, "siginfo_t size incorrect");
> @@ -585,8 +589,7 @@ set_mcontext(struct thread *td, mcontext_t *mcp)
>  
>                 buf_size = sve_buf_size(td);
>                 /* Check the size is valid */
> -               if (ctx.ctx_size !=
> -                   (sizeof(sve_ctx) + buf_size))
> +               if (ctx.ctx_size != CTX_SIZE_SVE(buf_size))
>                     return (EINVAL);
>  
>                 memset(pcb->pcb_svesaved, 0,
> @@ -729,7 +732,7 @@ sendsig_ctx_sve(struct thread *td, vm_offset_t *addrp)
>  {
>     struct sve_context ctx;
>     struct pcb *pcb;
> -   size_t buf_size;
> +   size_t buf_size, ctx_size;
>     vm_offset_t ctx_addr;
>  
>     pcb = td->td_pcb;
> @@ -740,14 +743,15 @@ sendsig_ctx_sve(struct thread *td, vm_offset_t *addrp)
>     MPASS(pcb->pcb_svesaved != NULL);
>  
>     buf_size = sve_buf_size(td);
> +   ctx_size = CTX_SIZE_SVE(buf_size);
>  
>     /* Address for the full context */
> -   *addrp -= sizeof(ctx) + buf_size;
> +   *addrp -= ctx_size;
>     ctx_addr = *addrp;
>  
>     memset(&ctx, 0, sizeof(ctx));
>     ctx.sve_ctx.ctx_id = ARM64_CTX_SVE;
> -   ctx.sve_ctx.ctx_size = sizeof(ctx) + buf_size;
> +   ctx.sve_ctx.ctx_size = ctx_size;
>     ctx.sve_vector_len = pcb->pcb_sve_len;
>     ctx.sve_flags = 0;
>  
>  
> 
> 
> 

 
[-- Attachment #2 --]
<html><head></head><body>Hi.<br>
<br>
Can this be related to this issue?<br>
<br>
<a href="https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=292195">https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=292195</a><br>;
"<span id="summary_container"><span id="short_desc_nonedit_display">arm64: panic on coredump with sve instructions"</span></span><br>
<br>
Regards,<br>
Ronald.<br>
<br>
&nbsp;
<p><strong>Van:</strong> Andrew Turner &lt;andrew@FreeBSD.org&gt;<br>
<strong>Datum:</strong> dinsdag, 6 januari 2026 12:04<br>
<strong>Aan:</strong> src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org<br>
<strong>Onderwerp:</strong> git: a9e77eb7016d - main - arm64: Correctly align the SVE signal context</p>

<blockquote style="padding-right: 0px; padding-left: 5px; margin-left: 5px; border-left: #000000 2px solid; margin-right: 0px">
<div class="MessageRFC822Viewer" id="P">
<div class="TextPlainViewer" id="P.P">The branch main has been updated by andrew:<br>
<br>
URL: <a href="https://cgit.FreeBSD.org/src/commit/?id=a9e77eb7016df70723c208fc09fbd01ec23a732d">https://cgit.FreeBSD.org/src/commit/?id=a9e77eb7016df70723c208fc09fbd01ec23a732d</a><br>;
<br>
commit a9e77eb7016df70723c208fc09fbd01ec23a732d<br>
Author: &nbsp;&nbsp;&nbsp;&nbsp;Andrew Turner &lt;andrew@FreeBSD.org&gt;<br>
AuthorDate: 2026-01-06 10:35:55 +0000<br>
Commit: &nbsp;&nbsp;&nbsp;&nbsp;Andrew Turner &lt;andrew@FreeBSD.org&gt;<br>
CommitDate: 2026-01-06 10:36:37 +0000<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;arm64: Correctly align the SVE signal context<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;The SVE signal context needs to be correctly aligned. Fix this by<br>
&nbsp;&nbsp;&nbsp;&nbsp;creating a new macro to calculate the needed size to provide this<br>
&nbsp;&nbsp;&nbsp;&nbsp;alignment, and use it when setting and checking the saved SVE signal<br>
&nbsp;&nbsp;&nbsp;&nbsp;context.<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;Reported by: &nbsp;&nbsp;&nbsp;cperciva<br>
&nbsp;&nbsp;&nbsp;&nbsp;Reviewed by: &nbsp;&nbsp;&nbsp;cperciva, markj<br>
&nbsp;&nbsp;&nbsp;&nbsp;Sponsored by: &nbsp;&nbsp;Arm Ltd<br>
&nbsp;&nbsp;&nbsp;&nbsp;Differential Revision: &nbsp;<a href="https://reviews.freebsd.org/D54396">https://reviews.freebsd.org/D54396</a><br>;
---<br>
&nbsp;sys/arm64/arm64/exec_machdep.c | 14 +++++++++-----<br>
&nbsp;1 file changed, 9 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/sys/arm64/arm64/exec_machdep.c b/sys/arm64/arm64/exec_machdep.c<br>
index 7c50dc93fdb4..207e10ede96c 100644<br>
--- a/sys/arm64/arm64/exec_machdep.c<br>
+++ b/sys/arm64/arm64/exec_machdep.c<br>
@@ -60,6 +60,10 @@<br>
&nbsp;#include &lt;machine/vfp.h&gt;<br>
&nbsp;#endif<br>
&nbsp;<br>
+#define &nbsp;&nbsp;&nbsp;CTX_SIZE_SVE(buf_size) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<br>
+ &nbsp;&nbsp;&nbsp;roundup2(sizeof(struct sve_context) + (buf_size), &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_Alignof(struct sve_context))<br>
+<br>
&nbsp;_Static_assert(sizeof(mcontext_t) == 880, "mcontext_t size incorrect");<br>
&nbsp;_Static_assert(sizeof(ucontext_t) == 960, "ucontext_t size incorrect");<br>
&nbsp;_Static_assert(sizeof(siginfo_t) == 80, "siginfo_t size incorrect");<br>
@@ -585,8 +589,7 @@ set_mcontext(struct thread *td, mcontext_t *mcp)<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buf_size = sve_buf_size(td);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Check the size is valid */<br>
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (ctx.ctx_size !=<br>
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(sizeof(sve_ctx) + buf_size))<br>
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (ctx.ctx_size != CTX_SIZE_SVE(buf_size))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return (EINVAL);<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memset(pcb-&gt;pcb_svesaved, 0,<br>
@@ -729,7 +732,7 @@ sendsig_ctx_sve(struct thread *td, vm_offset_t *addrp)<br>
&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;struct sve_context ctx;<br>
&nbsp;&nbsp;&nbsp;&nbsp;struct pcb *pcb;<br>
- &nbsp;&nbsp;size_t buf_size;<br>
+ &nbsp;&nbsp;size_t buf_size, ctx_size;<br>
&nbsp;&nbsp;&nbsp;&nbsp;vm_offset_t ctx_addr;<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;pcb = td-&gt;td_pcb;<br>
@@ -740,14 +743,15 @@ sendsig_ctx_sve(struct thread *td, vm_offset_t *addrp)<br>
&nbsp;&nbsp;&nbsp;&nbsp;MPASS(pcb-&gt;pcb_svesaved != NULL);<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;buf_size = sve_buf_size(td);<br>
+ &nbsp;&nbsp;ctx_size = CTX_SIZE_SVE(buf_size);<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;/* Address for the full context */<br>
- &nbsp;&nbsp;*addrp -= sizeof(ctx) + buf_size;<br>
+ &nbsp;&nbsp;*addrp -= ctx_size;<br>
&nbsp;&nbsp;&nbsp;&nbsp;ctx_addr = *addrp;<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;memset(&amp;ctx, 0, sizeof(ctx));<br>
&nbsp;&nbsp;&nbsp;&nbsp;ctx.sve_ctx.ctx_id = ARM64_CTX_SVE;<br>
- &nbsp;&nbsp;ctx.sve_ctx.ctx_size = sizeof(ctx) + buf_size;<br>
+ &nbsp;&nbsp;ctx.sve_ctx.ctx_size = ctx_size;<br>
&nbsp;&nbsp;&nbsp;&nbsp;ctx.sve_vector_len = pcb-&gt;pcb_sve_len;<br>
&nbsp;&nbsp;&nbsp;&nbsp;ctx.sve_flags = 0;<br>
&nbsp;<br>
&nbsp;</div>

<hr></div>
</blockquote>
<br>
&nbsp;</body></html>
home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?64525372.1244.1767701071189>