aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Arslan <ararslan@comcast.net>2026-03-19 23:30:03 +0000
committerAndrew Turner <andrew@FreeBSD.org>2026-06-05 16:15:36 +0000
commit5cc3fa098856cbb8de72d1027c838ef734030445 (patch)
treeb25fc99615f151482cb7d9566fbfd1c7598bcac4
parent8f6c577c9f706aea6f138fa1bec27029d4ab587d (diff)
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
-rw-r--r--sys/arm64/arm64/trap.c1
-rw-r--r--sys/sys/signalvar.h1
2 files changed, 2 insertions, 0 deletions
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)