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
This commit is contained in:
Alex Arslan
2026-03-19 16:30:03 -07:00
committed by Andrew Turner
parent 8f6c577c9f
commit 5cc3fa0988
2 changed files with 2 additions and 0 deletions
+1
View File
@@ -131,6 +131,7 @@ call_trapsignal(struct thread *td, int sig, int code, void *addr, int trapno)
ksi.ksi_code = code; ksi.ksi_code = code;
ksi.ksi_addr = addr; ksi.ksi_addr = addr;
ksi.ksi_trapno = trapno; ksi.ksi_trapno = trapno;
ksi.ksi_flags |= KSI_EXCEPT;
trapsignal(td, &ksi); trapsignal(td, &ksi);
} }
+1
View File
@@ -237,6 +237,7 @@ typedef struct ksiginfo {
#define KSI_SIGQ 0x08 /* Generated by sigqueue, might ret EAGAIN. */ #define KSI_SIGQ 0x08 /* Generated by sigqueue, might ret EAGAIN. */
#define KSI_HEAD 0x10 /* Insert into head, not tail. */ #define KSI_HEAD 0x10 /* Insert into head, not tail. */
#define KSI_PTRACE 0x20 /* Generated by ptrace. */ #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_COPYMASK (KSI_TRAP | KSI_SIGQ | KSI_PTRACE)
#define KSI_ONQ(ksi) ((ksi)->ksi_sigq != NULL) #define KSI_ONQ(ksi) ((ksi)->ksi_sigq != NULL)