On Fri, Jun 05, 2026 at 04:16:07PM +0000, Andrew Turner wrote: > The branch main has been updated by andrew: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=5cc3fa098856cbb8de72d1027c838ef734030445 > > commit 5cc3fa098856cbb8de72d1027c838ef734030445 > Author: Alex Arslan <[email protected]> > AuthorDate: 2026-03-19 23:30:03 +0000 > Commit: Andrew Turner <[email protected]> > 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 <[email protected]> > 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. */ This bit is MD, its proper place is in struct trapframe. That is, trapframe should grow a flags field if it needs some additional information about validity of the members.
This is how x86 arches handle its optional content like segment registers, segment bases, and FRED fields in uncommitted changes. I do not see why the MD bit should leak into the ksi. > #define KSI_COPYMASK (KSI_TRAP | KSI_SIGQ | KSI_PTRACE) > > #define KSI_ONQ(ksi) ((ksi)->ksi_sigq != NULL)
