git: 5cc3fa098856 - main - arm64: Add exception flag for ksiginfo_t and set in trapsignal

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Fri, 05 Jun 2026 16:16:07 UTC
The branch main has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=5cc3fa098856cbb8de72d1027c838ef734030445

commit 5cc3fa098856cbb8de72d1027c838ef734030445
Author:     Alex Arslan <ararslan@comcast.net>
AuthorDate: 2026-03-19 23:30:03 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2026-06-05 16:15:36 +0000

    arm64: Add exception flag for ksiginfo_t and set in trapsignal
    
    The `ksiginfo_t` flag `KSI_TRAP` is set both for exceptions and when
    copying between userspace and the kernel fails. In the latter case, the
    exception syndrome register as captured in `struct trapframe` won't be
    valid. That means we can't use `KSI_TRAP` to determine whether `tf_esr`
    is valid. This motivates the addition of a new flag, here called
    `KSI_EXCEPT`, for specifically identifying signals caused by exceptions.
    It is added to `ksi_flags` via `trapsignal`.
    
    Signed-off-by: Alex Arslan <ararslan@comcast.net>
    Reported by:    andrew
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/2053
---
 sys/arm64/arm64/trap.c | 1 +
 sys/sys/signalvar.h    | 1 +
 2 files changed, 2 insertions(+)

diff --git a/sys/arm64/arm64/trap.c b/sys/arm64/arm64/trap.c
index 1178817108e5..3afeb34abd5f 100644
--- a/sys/arm64/arm64/trap.c
+++ b/sys/arm64/arm64/trap.c
@@ -131,6 +131,7 @@ call_trapsignal(struct thread *td, int sig, int code, void *addr, int trapno)
 	ksi.ksi_code = code;
 	ksi.ksi_addr = addr;
 	ksi.ksi_trapno = trapno;
+	ksi.ksi_flags |= KSI_EXCEPT;
 	trapsignal(td, &ksi);
 }
 
diff --git a/sys/sys/signalvar.h b/sys/sys/signalvar.h
index 8f181b7beee6..9a4009d269af 100644
--- a/sys/sys/signalvar.h
+++ b/sys/sys/signalvar.h
@@ -237,6 +237,7 @@ typedef struct ksiginfo {
 #define	KSI_SIGQ	0x08	/* Generated by sigqueue, might ret EAGAIN. */
 #define	KSI_HEAD	0x10	/* Insert into head, not tail. */
 #define	KSI_PTRACE	0x20	/* Generated by ptrace. */
+#define	KSI_EXCEPT	0x40	/* Generated by an exception. */
 #define	KSI_COPYMASK	(KSI_TRAP | KSI_SIGQ | KSI_PTRACE)
 
 #define	KSI_ONQ(ksi)	((ksi)->ksi_sigq != NULL)