Subject: Re: SA_SIGINFO notes
To: Christos Zoulas <christos@zoulas.com>
From: Jason Thorpe <thorpej@wasabisystems.com>
List: tech-kern
Date: 10/07/2003 10:50:52
--Apple-Mail-10--804976887
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed
On Tuesday, October 7, 2003, at 09:34 AM, Christos Zoulas wrote:
> I was thinking about following suite with linux and defined
> SI_KERNEL as 0x80 and or'ing that in with si_code for kernel
> generated signals, but then we'll have to strip the SI_KERNEL
> bit before sending siginfo_t to userland. Another way it to
> use a separate field, that will have 3 different values:
>
> - caused by a trap
> - sent by the kernel, (io, timer, etc.)
> - sent from another process
Here is my patch that takes a stab a solving this problem. I've
compile-tested it on i386, but I won't be able to run-test it until
later this afternoon.
It's not very invasive... it looks large because it requires the
correct kind of initialization for the ksiginfo_t for trap handlers.
Mostly this is replacing a memset() call with a macro call (and adding
missing initialization of ksiginfo_t to sparc and alpha).
This currently only handles the "caused by trap" case. For "caused by
kernel", you can't use ksi_code < SI_USER because of all the
kernel-sourced signals (SIGCHLD, for example) that have > 0 codes. For
"sent by another process", the absence of both flags or ksi_code ==
SI_USER should be sufficient. Actually, a set of predicate macros
might be nice:
KSI_TRAP_P()
KSI_KERNEL_P()
KSI_USER_P()
which hide how the tests are actually done.
Comments?
-- Jason R. Thorpe <thorpej@wasabisystems.com>
--Apple-Mail-10--804976887
Content-Disposition: attachment;
filename=ksi-trap.patch
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
x-unix-mode=0644;
name="ksi-trap.patch"
Index: arch/alpha/alpha/compat_16_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/alpha/alpha/compat_16_machdep.c,v
retrieving revision 1.1
diff -u -r1.1 compat_16_machdep.c
--- arch/alpha/alpha/compat_16_machdep.c 7 Oct 2003 17:04:18 -0000 1.1
+++ arch/alpha/alpha/compat_16_machdep.c 7 Oct 2003 17:33:30 -0000
@@ -216,10 +216,8 @@
/* sigcontext specific trap frame */
tf->tf_regs[FRAME_A0] = sig;
- /* ksi_code is probably more accurate, but ksi_trap is (closer to) */
- /* binary compatability */
/* tf->tf_regs[FRAME_A1] = ksi->ksi_code; */
- tf->tf_regs[FRAME_A1] = ksi->ksi_trap;
+ tf->tf_regs[FRAME_A1] = KSI_TRAPCODE(ksi);
tf->tf_regs[FRAME_A2] = (u_int64_t)&fp->sf_sc;
/* Remember that we're now on the signal stack. */
Index: arch/alpha/alpha/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/alpha/alpha/trap.c,v
retrieving revision 1.85
diff -u -r1.85 trap.c
--- arch/alpha/alpha/trap.c 7 Oct 2003 17:04:18 -0000 1.85
+++ arch/alpha/alpha/trap.c 7 Oct 2003 17:33:31 -0000
@@ -269,6 +269,7 @@
if (i == 0)
goto out;
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = i;
ksi.ksi_code = BUS_ADRALN;
ksi.ksi_addr = (void *)a0; /* VA */
@@ -298,6 +299,7 @@
i = alpha_fp_complete(a0, a1, l, &ucode);
if (i == 0)
goto out;
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = i;
if (i == SIGSEGV)
ksi.ksi_code = SEGV_MAPERR; /* just pick one */
@@ -339,6 +341,7 @@
switch (a0) {
case ALPHA_IF_CODE_GENTRAP:
if (framep->tf_regs[FRAME_A0] == -2) { /* weird! */
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGFPE;
ksi.ksi_code = alpha_ucode_to_ksiginfo(ucode);
ksi.ksi_addr =
@@ -349,6 +352,7 @@
/* FALLTHROUTH */
case ALPHA_IF_CODE_BPT:
case ALPHA_IF_CODE_BUGCHK:
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGTRAP;
ksi.ksi_code = TRAP_BRKPT;
ksi.ksi_addr = (void *)l->l_md.md_tf->tf_regs[FRAME_PC];
@@ -359,6 +363,7 @@
KERNEL_PROC_LOCK(l);
i = handle_opdec(l, &ucode);
KERNEL_PROC_UNLOCK(l);
+ KSI_INIT_TRAP(&ksi);
if (i == 0)
goto out;
else if (i == SIGSEGV)
@@ -533,6 +538,7 @@
}
goto dopanic;
}
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_addr = (void *)a0;
ksi.ksi_trap = a1; /* MMCSR VALUE */
if (rv == ENOMEM) {
Index: arch/amiga/amiga/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/amiga/amiga/trap.c,v
retrieving revision 1.95
diff -u -r1.95 trap.c
--- arch/amiga/amiga/trap.c 22 Sep 2003 14:27:00 -0000 1.95
+++ arch/amiga/amiga/trap.c 7 Oct 2003 17:33:32 -0000
@@ -346,7 +346,7 @@
u_int nss;
int rv;
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type & ~T_USER;
/*
@@ -609,7 +609,7 @@
l = curlwp;
uvmexp.traps++;
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type & ~T_USER;
/* I have verified that this DOES happen! -gwr */
Index: arch/arm/arm/sig_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/arm/sig_machdep.c,v
retrieving revision 1.21
diff -u -r1.21 sig_machdep.c
--- arch/arm/arm/sig_machdep.c 5 Oct 2003 19:44:58 -0000 1.21
+++ arch/arm/arm/sig_machdep.c 7 Oct 2003 17:33:33 -0000
@@ -97,7 +97,7 @@
struct sigframe_sigcontext *fp, frame;
int onstack;
int sig = ksi->ksi_signo;
- u_long code = ksi->ksi_trap;
+ u_long code = KSI_TRAPCODE(ksi);
sig_t catcher = SIGACTION(p, sig).sa_handler;
tf = process_frame(l);
@@ -256,7 +256,7 @@
}
/* populate the siginfo frame */
- frame.sf_si._info = *ksi;
+ frame.sf_si._info = ksi->ksi_info;
frame.sf_uc.uc_flags = _UC_SIGMASK;
frame.sf_uc.uc_sigmask = *mask;
frame.sf_uc.uc_link = NULL;
Index: arch/arm/arm/syscall.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/arm/syscall.c,v
retrieving revision 1.19
diff -u -r1.19 syscall.c
--- arch/arm/arm/syscall.c 5 Oct 2003 19:44:58 -0000 1.19
+++ arch/arm/arm/syscall.c 7 Oct 2003 17:33:33 -0000
@@ -223,7 +223,7 @@
break;
default:
/* Undefined so illegal instruction */
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGILL;
/* XXX get an ILL_ILLSYSCALL assigned */
ksi.ksi_code = 0;
@@ -241,7 +241,7 @@
break;
default:
/* Undefined so illegal instruction */
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGILL;
/* XXX get an ILL_ILLSYSCALL assigned */
ksi.ksi_code = 0;
@@ -351,7 +351,7 @@
break;
default:
/* Undefined so illegal instruction */
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGILL;
/* XXX get an ILL_ILLSYSCALL assigned */
ksi.ksi_code = 0;
@@ -369,7 +369,7 @@
break;
default:
/* Undefined so illegal instruction */
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGILL;
/* XXX get an ILL_ILLSYSCALL assigned */
ksi.ksi_code = 0;
Index: arch/arm/arm/undefined.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/arm/undefined.c,v
retrieving revision 1.18
diff -u -r1.18 undefined.c
--- arch/arm/arm/undefined.c 5 Oct 2003 19:44:58 -0000 1.18
+++ arch/arm/arm/undefined.c 7 Oct 2003 17:33:34 -0000
@@ -132,7 +132,8 @@
if (insn == GDB_BREAKPOINT || insn == GDB5_BREAKPOINT) {
if (code == FAULT_USER) {
ksiginfo_t ksi;
- (void)memset(&ksi, 0, sizeof(ksi));
+
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGTRAP;
ksi.ksi_code = TRAP_BRKPT;
ksi.ksi_addr = (u_int32_t *)addr;
@@ -281,7 +282,7 @@
Debugger();
#endif
}
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGILL;
ksi.ksi_code = ILL_ILLOPC;
ksi.ksi_addr = (u_int32_t *)fault_pc;
Index: arch/arm/arm32/fault.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/arm32/fault.c,v
retrieving revision 1.34
diff -u -r1.34 fault.c
--- arch/arm/arm32/fault.c 5 Oct 2003 19:44:58 -0000 1.34
+++ arch/arm/arm32/fault.c 7 Oct 2003 17:33:34 -0000
@@ -388,7 +388,7 @@
/* check if this was a failed fixup */
if (error == ABORT_FIXUP_FAILED) {
if (user) {
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGSEGV;
ksi.ksi_code = 0;
ksi.ksi_addr = (u_int32_t *)fault_address;
@@ -462,7 +462,7 @@
if ((frame->tf_spsr & PSR_MODE) == PSR_UND32_MODE) {
report_abort("UND32", fault_status,
fault_address, fault_pc);
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGSEGV;
ksi.ksi_code = fault_status;
ksi.ksi_addr = (u_int32_t *)fault_address;
@@ -564,7 +564,7 @@
report_abort("", fault_status, fault_address, fault_pc);
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGSEGV;
ksi.ksi_code = 0;
ksi.ksi_addr = (u_int32_t *)fault_address;
@@ -682,7 +682,7 @@
printf("prefetch: pc (%08lx) not in user process space\n",
fault_pc);
#endif
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGSEGV;
ksi.ksi_code = SEGV_ACCERR;
ksi.ksi_addr = (u_int32_t *)fault_pc;
@@ -711,7 +711,7 @@
if (error == 0)
goto prefetch_out;
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGSEGV;
ksi.ksi_code = 0;
ksi.ksi_errno = error;
Index: arch/atari/atari/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/atari/atari/trap.c,v
retrieving revision 1.71
diff -u -r1.71 trap.c
--- arch/atari/atari/trap.c 22 Sep 2003 14:27:03 -0000 1.71
+++ arch/atari/atari/trap.c 7 Oct 2003 17:33:36 -0000
@@ -395,7 +395,7 @@
uvmexp.traps++;
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type & ~T_USER;
/* I have verified that this DOES happen! -gwr */
Index: arch/cesfic/cesfic/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/cesfic/cesfic/trap.c,v
retrieving revision 1.14
diff -u -r1.14 trap.c
--- arch/cesfic/cesfic/trap.c 22 Sep 2003 14:27:05 -0000 1.14
+++ arch/cesfic/cesfic/trap.c 7 Oct 2003 17:33:37 -0000
@@ -333,7 +333,7 @@
uvmexp.traps++;
l = curlwp;
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type & ~T_USER;
/* I have verified that this DOES happen! -gwr */
Index: arch/hp300/hp300/hpux_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/hp300/hp300/hpux_machdep.c,v
retrieving revision 1.38
diff -u -r1.38 hpux_machdep.c
--- arch/hp300/hp300/hpux_machdep.c 25 Sep 2003 22:00:48 -0000 1.38
+++ arch/hp300/hp300/hpux_machdep.c 7 Oct 2003 17:33:41 -0000
@@ -454,7 +454,7 @@
void
hpux_sendsig(const ksiginfo_t *ksi, const sigset_t *mask)
{
- u_long code = ksi->ksi_trap;
+ u_long code = KSI_TRAPCODE(ksi);
int sig = ksi->ksi_signo;
struct lwp *l = curlwp;
struct proc *p = l->l_proc;
Index: arch/hp300/hp300/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/hp300/hp300/trap.c,v
retrieving revision 1.103
diff -u -r1.103 trap.c
--- arch/hp300/hp300/trap.c 22 Sep 2003 14:26:57 -0000 1.103
+++ arch/hp300/hp300/trap.c 7 Oct 2003 17:33:42 -0000
@@ -326,7 +326,7 @@
uvmexp.traps++;
l = curlwp;
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type & ~T_USER;
/* I have verified that this DOES happen! -gwr */
Index: arch/i386/i386/compat_16_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/compat_16_machdep.c,v
retrieving revision 1.4
diff -u -r1.4 compat_16_machdep.c
--- arch/i386/i386/compat_16_machdep.c 25 Sep 2003 22:01:31 -0000 1.4
+++ arch/i386/i386/compat_16_machdep.c 7 Oct 2003 17:33:47 -0000
@@ -175,7 +175,7 @@
struct trapframe *tf = l->l_md.md_regs;
int onstack;
int sig = ksi->ksi_signo;
- u_long code = ksi->ksi_trap;
+ u_long code = KSI_TRAPCODE(ksi);
struct sigframe_sigcontext *fp = getframe(l, sig, &onstack), frame;
sig_t catcher = SIGACTION(p, sig).sa_handler;
Index: arch/i386/i386/freebsd_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/freebsd_machdep.c,v
retrieving revision 1.40
diff -u -r1.40 freebsd_machdep.c
--- arch/i386/i386/freebsd_machdep.c 25 Sep 2003 22:01:31 -0000 1.40
+++ arch/i386/i386/freebsd_machdep.c 7 Oct 2003 17:33:47 -0000
@@ -96,7 +96,7 @@
freebsd_sendsig(const ksiginfo_t *ksi, const sigset_t *mask)
{
int sig = ksi->ksi_signo;
- u_long code = ksi->ksi_trap;
+ u_long code = KSI_TRAPCODE(ksi);
struct lwp *l = curlwp;
struct proc *p = l->l_proc;
int onstack;
Index: arch/i386/i386/ibcs2_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/ibcs2_machdep.c,v
retrieving revision 1.26
diff -u -r1.26 ibcs2_machdep.c
--- arch/i386/i386/ibcs2_machdep.c 25 Sep 2003 22:01:31 -0000 1.26
+++ arch/i386/i386/ibcs2_machdep.c 7 Oct 2003 17:33:47 -0000
@@ -103,7 +103,7 @@
ibcs2_sendsig(const ksiginfo_t *ksi, const sigset_t *mask)
{
int sig = ksi->ksi_signo;
- u_long code = ksi->ksi_trap;
+ u_long code = KSI_TRAPCODE(ksi);
struct lwp *l = curlwp;
struct proc *p = l->l_proc;
int onstack;
Index: arch/i386/i386/linux_trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/linux_trap.c,v
retrieving revision 1.8
diff -u -r1.8 linux_trap.c
--- arch/i386/i386/linux_trap.c 25 Sep 2003 22:01:31 -0000 1.8
+++ arch/i386/i386/linux_trap.c 7 Oct 2003 17:33:48 -0000
@@ -145,6 +145,7 @@
case SIGBUS:
case SIGFPE:
case SIGSEGV:
+ KASSERT((ksi->ksi_flags & KSI_TRAP) != 0);
if (ksi->ksi_trap <= ASIZE(trapno_to_x86_vec)) {
ksiginfo_t nksi = *ksi;
nksi.ksi_trap = trapno_to_x86_vec[ksi->ksi_trap];
Index: arch/i386/i386/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.539
diff -u -r1.539 machdep.c
--- arch/i386/i386/machdep.c 25 Sep 2003 22:01:31 -0000 1.539
+++ arch/i386/i386/machdep.c 7 Oct 2003 17:33:49 -0000
@@ -658,7 +658,7 @@
frame.sf_signum = sig;
frame.sf_sip = &fp->sf_si;
frame.sf_ucp = &fp->sf_uc;
- frame.sf_si._info = *ksi;
+ frame.sf_si._info = ksi->ksi_info;
frame.sf_uc.uc_flags = _UC_SIGMASK|_UC_VM;
frame.sf_uc.uc_sigmask = *mask;
frame.sf_uc.uc_link = NULL;
Index: arch/i386/i386/math_emulate.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/math_emulate.c,v
retrieving revision 1.26
diff -u -r1.26 math_emulate.c
--- arch/i386/i386/math_emulate.c 6 Sep 2003 22:08:15 -0000 1.26
+++ arch/i386/i386/math_emulate.c 7 Oct 2003 17:33:50 -0000
@@ -56,7 +56,7 @@
#define PST(x) ((const temp_real *) __st((x)))
#define math_abort(tfp, ksi, signo, code) \
do { \
- (void)memset(ksi, 0, sizeof(*ksi)); \
+ KSI_INIT_TRAP(ksi); \
ksi->ksi_signo = signo; \
ksi->ksi_code = code; \
ksi->ksi_addr = (void *)info->tf_eip;\
Index: arch/i386/i386/svr4_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/svr4_machdep.c,v
retrieving revision 1.71
diff -u -r1.71 svr4_machdep.c
--- arch/i386/i386/svr4_machdep.c 25 Sep 2003 22:01:31 -0000 1.71
+++ arch/i386/i386/svr4_machdep.c 7 Oct 2003 17:33:50 -0000
@@ -373,7 +373,7 @@
void
svr4_sendsig(const ksiginfo_t *ksi, const sigset_t *mask)
{
- u_long code = ksi->ksi_trap;
+ u_long code = KSI_TRAPCODE(ksi);
int sig = ksi->ksi_signo;
struct lwp *l = curlwp;
struct proc *p = l->l_proc;
Index: arch/i386/i386/syscall.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/syscall.c,v
retrieving revision 1.23
diff -u -r1.23 syscall.c
--- arch/i386/i386/syscall.c 6 Sep 2003 22:08:15 -0000 1.23
+++ arch/i386/i386/syscall.c 7 Oct 2003 17:33:51 -0000
@@ -282,7 +282,8 @@
struct lwp *l;
struct proc *p;
ksiginfo_t ksi;
- memset(&ksi, 0, sizeof(ksi));
+
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGBUS;
ksi.ksi_code = BUS_OBJERR;
ksi.ksi_trap = T_PROTFLT;
Index: arch/i386/i386/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/trap.c,v
retrieving revision 1.188
diff -u -r1.188 trap.c
--- arch/i386/i386/trap.c 16 Sep 2003 13:57:47 -0000 1.188
+++ arch/i386/i386/trap.c 7 Oct 2003 17:33:51 -0000
@@ -405,7 +405,7 @@
case T_STKFLT|T_USER:
case T_ALIGNFLT|T_USER:
case T_NMI|T_USER:
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGBUS;
ksi.ksi_trap = type & ~T_USER;
ksi.ksi_addr = (void *)rcr2();
@@ -430,7 +430,7 @@
case T_PRIVINFLT|T_USER: /* privileged instruction fault */
case T_FPOPFLT|T_USER: /* coprocessor operand fault */
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGILL;
ksi.ksi_trap = type & ~T_USER;
ksi.ksi_addr = (void *)rcr2();
@@ -470,7 +470,7 @@
ksi.ksi_trap = type & ~T_USER;
goto trapsignal;
#else
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGKILL;
ksi.ksi_trap = type & ~T_USER;
ksi.ksi_addr = (void *)frame->tf_eip;
@@ -483,7 +483,7 @@
case T_BOUND|T_USER:
case T_OFLOW|T_USER:
case T_DIVIDE|T_USER:
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGFPE;
ksi.ksi_trap = type & ~T_USER;
ksi.ksi_addr = (void *)frame->tf_eip;
@@ -502,7 +502,7 @@
goto trapsignal;
case T_ARITHTRAP|T_USER:
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGFPE;
ksi.ksi_trap = frame->tf_err & ~TC_FLAGMASK;
ksi.ksi_addr = (void *)frame->tf_eip;
@@ -614,7 +614,7 @@
KERNEL_PROC_UNLOCK(l);
goto out;
}
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type & ~T_USER;
ksi.ksi_addr = (void *)cr2;
if (error == EACCES) {
@@ -672,7 +672,7 @@
*/
if ((p->p_nras == 0) ||
(ras_lookup(p, (caddr_t)frame->tf_eip) == (caddr_t)-1)) {
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGTRAP;
ksi.ksi_trap = type & ~T_USER;
if (type == (T_BPTFLT|T_USER))
Index: arch/i386/i386/vm86.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/vm86.c,v
retrieving revision 1.33
diff -u -r1.33 vm86.c
--- arch/i386/i386/vm86.c 11 Sep 2003 19:15:13 -0000 1.33
+++ arch/i386/i386/vm86.c 7 Oct 2003 17:33:52 -0000
@@ -235,7 +235,7 @@
} else {
ksiginfo_t ksi;
- memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGURG;
ksi.ksi_trap = retval;
(*p->p_emul->e_trapsignal)(l, &ksi);
@@ -361,7 +361,7 @@
if (trace && tf->tf_eflags & PSL_VM) {
ksiginfo_t ksi;
- memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGTRAP;
ksi.ksi_code = TRAP_TRACE;
ksi.ksi_trap = T_TRCTRAP;
Index: arch/luna68k/luna68k/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/luna68k/luna68k/trap.c,v
retrieving revision 1.25
diff -u -r1.25 trap.c
--- arch/luna68k/luna68k/trap.c 22 Sep 2003 14:27:06 -0000 1.25
+++ arch/luna68k/luna68k/trap.c 7 Oct 2003 17:33:53 -0000
@@ -293,7 +293,7 @@
uvmexp.traps++;
l = curlwp;
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type & ~T_USER;
/* I have verified that this DOES happen! -gwr */
Index: arch/m68k/m68k/compat_16_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/m68k/m68k/compat_16_machdep.c,v
retrieving revision 1.2
diff -u -r1.2 compat_16_machdep.c
--- arch/m68k/m68k/compat_16_machdep.c 25 Sep 2003 22:04:17 -0000 1.2
+++ arch/m68k/m68k/compat_16_machdep.c 7 Oct 2003 17:33:54 -0000
@@ -126,7 +126,7 @@
struct frame *frame = (struct frame *)l->l_md.md_regs;
int onstack;
int sig = ksi->ksi_signo;
- u_long code = ksi->ksi_trap;
+ u_long code = KSI_TRAPCODE(ksi);
struct sigframe_sigcontext *fp = getframe(l, sig, &onstack), kf;
sig_t catcher = SIGACTION(p, sig).sa_handler;
short ft = frame->f_format;
Index: arch/m68k/m68k/sig_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/m68k/m68k/sig_machdep.c,v
retrieving revision 1.23
diff -u -r1.23 sig_machdep.c
--- arch/m68k/m68k/sig_machdep.c 25 Sep 2003 22:04:17 -0000 1.23
+++ arch/m68k/m68k/sig_machdep.c 7 Oct 2003 17:33:54 -0000
@@ -201,7 +201,7 @@
kf.sf_signum = sig;
kf.sf_sip = &fp->sf_si;
kf.sf_ucp = &fp->sf_uc;
- kf.sf_si._info = *ksi;
+ kf.sf_si._info = ksi->ksi_info;
kf.sf_uc.uc_flags = _UC_SIGMASK;
kf.sf_uc.uc_sigmask = *mask;
kf.sf_uc.uc_link = NULL;
Index: arch/m68k/m68k/sunos_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/m68k/m68k/sunos_machdep.c,v
retrieving revision 1.26
diff -u -r1.26 sunos_machdep.c
--- arch/m68k/m68k/sunos_machdep.c 25 Sep 2003 22:04:17 -0000 1.26
+++ arch/m68k/m68k/sunos_machdep.c 7 Oct 2003 17:33:54 -0000
@@ -134,7 +134,7 @@
void
sunos_sendsig(const ksiginfo_t *ksi, const sigset_t *mask)
{
- u_long code = ksi->ksi_trap;
+ u_long code = KSI_TRAPCODE(ksi);
int sig = ksi->ksi_signo;
struct lwp *l = curlwp;
struct proc *p = l->l_proc;
Index: arch/m68k/m68k/svr4_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/m68k/m68k/svr4_machdep.c,v
retrieving revision 1.14
diff -u -r1.14 svr4_machdep.c
--- arch/m68k/m68k/svr4_machdep.c 25 Sep 2003 22:04:17 -0000 1.14
+++ arch/m68k/m68k/svr4_machdep.c 7 Oct 2003 17:33:54 -0000
@@ -250,7 +250,7 @@
void
svr4_sendsig(const ksiginfo_t *ksi, const sigset_t *mask)
{
- u_long code = ksi->ksi_trap;
+ u_long code = KSI_TRAPCODE(ksi);
int sig = ksi->ksi_signo;
struct lwp *l = curlwp;
struct proc *p = l->l_proc;
Index: arch/mac68k/mac68k/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mac68k/mac68k/trap.c,v
retrieving revision 1.106
diff -u -r1.106 trap.c
--- arch/mac68k/mac68k/trap.c 22 Sep 2003 14:27:07 -0000 1.106
+++ arch/mac68k/mac68k/trap.c 7 Oct 2003 17:33:55 -0000
@@ -308,7 +308,7 @@
uvmexp.traps++;
l = curlwp;
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type & ~T_USER;
/* I have verified that this DOES happen! -gwr */
Index: arch/mvme68k/mvme68k/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mvme68k/mvme68k/trap.c,v
retrieving revision 1.69
diff -u -r1.69 trap.c
--- arch/mvme68k/mvme68k/trap.c 22 Sep 2003 14:27:09 -0000 1.69
+++ arch/mvme68k/mvme68k/trap.c 7 Oct 2003 17:33:57 -0000
@@ -346,7 +346,7 @@
uvmexp.traps++;
l = curlwp;
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type & ~T_USER;
/* I have verified that this DOES happen! -gwr */
Index: arch/news68k/news68k/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/news68k/news68k/trap.c,v
retrieving revision 1.31
diff -u -r1.31 trap.c
--- arch/news68k/news68k/trap.c 22 Sep 2003 14:27:10 -0000 1.31
+++ arch/news68k/news68k/trap.c 7 Oct 2003 17:33:58 -0000
@@ -316,7 +316,7 @@
uvmexp.traps++;
l = curlwp;
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type & ~T_USER;
/* I have verified that this DOES happen! -gwr */
Index: arch/next68k/next68k/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/next68k/next68k/trap.c,v
retrieving revision 1.45
diff -u -r1.45 trap.c
--- arch/next68k/next68k/trap.c 22 Sep 2003 14:27:11 -0000 1.45
+++ arch/next68k/next68k/trap.c 7 Oct 2003 17:33:59 -0000
@@ -342,7 +342,7 @@
uvmexp.traps++;
l = curlwp;
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type & ~T_USER;
/* I have verified that this DOES happen! -gwr */
Index: arch/powerpc/ibm4xx/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/ibm4xx/trap.c,v
retrieving revision 1.18
diff -u -r1.18 trap.c
--- arch/powerpc/ibm4xx/trap.c 26 Sep 2003 00:00:17 -0000 1.18
+++ arch/powerpc/ibm4xx/trap.c 7 Oct 2003 17:34:01 -0000
@@ -164,7 +164,7 @@
*/
case EXC_TRC|EXC_USER:
frame->srr1 &= ~PSL_SE;
- memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGTRAP;
ksi.ksi_trap = EXC_TRC;
ksi.ksi_addr = (void *)frame->srr0;
@@ -252,7 +252,7 @@
KERNEL_PROC_UNLOCK(l);
break;
}
- memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGSEGV;
ksi.ksi_trap = EXC_DSI;
ksi.ksi_addr = (void *)frame->dar;
@@ -288,7 +288,7 @@
KERNEL_PROC_UNLOCK(l);
break;
}
- memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGSEGV;
ksi.ksi_trap = EXC_ISI;
ksi.ksi_addr = (void *)frame->srr0;
@@ -315,7 +315,7 @@
case EXC_ALI|EXC_USER:
KERNEL_PROC_LOCK(l);
if (fix_unaligned(l, frame) != 0) {
- memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGBUS;
ksi.ksi_trap = EXC_ALI;
ksi.ksi_addr = (void *)frame->dar;
@@ -340,7 +340,7 @@
if ((rv = fpu_emulate(frame,
(struct fpreg *)&l->l_addr->u_pcb.pcb_fpu))) {
- memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = rv;
ksi.ksi_trap = EXC_PGM;
ksi.ksi_addr = (void *)frame->srr0;
Index: arch/powerpc/powerpc/sig_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/powerpc/sig_machdep.c,v
retrieving revision 1.17
diff -u -r1.17 sig_machdep.c
--- arch/powerpc/powerpc/sig_machdep.c 27 Sep 2003 03:51:54 -0000 1.17
+++ arch/powerpc/powerpc/sig_machdep.c 7 Oct 2003 17:34:02 -0000
@@ -67,7 +67,7 @@
if (sd->sd_vers < 2) {
#ifdef COMPAT_16
- sendsig_sigcontext(ksi->ksi_signo, mask, ksi->ksi_trap);
+ sendsig_sigcontext(ksi->ksi_signo, mask, KSI_TRAPCODE(ksi));
return;
#else
goto nosupport;
Index: arch/powerpc/powerpc/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/powerpc/trap.c,v
retrieving revision 1.89
diff -u -r1.89 trap.c
--- arch/powerpc/powerpc/trap.c 27 Sep 2003 04:44:42 -0000 1.89
+++ arch/powerpc/powerpc/trap.c 7 Oct 2003 17:34:02 -0000
@@ -99,7 +99,7 @@
frame->srr1 &= ~PSL_SE;
if (p->p_nras == 0 ||
ras_lookup(p, (caddr_t)frame->srr0) == (caddr_t) -1) {
- memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGTRAP;
ksi.ksi_trap = EXC_TRC;
ksi.ksi_addr = (void *)frame->srr0;
@@ -229,7 +229,7 @@
(frame->dsisr & DSISR_STORE) ? "write" : "read",
frame->dar, frame->srr0, frame->dsisr, rv);
}
- memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGSEGV;
ksi.ksi_trap = EXC_DSI;
ksi.ksi_addr = (void *)frame->dar;
@@ -289,7 +289,7 @@
"(SRR1=%#lx)\n", p->p_pid, l->l_lid, p->p_comm,
frame->srr0, frame->srr1);
}
- memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGSEGV;
ksi.ksi_trap = EXC_ISI;
ksi.ksi_addr = (void *)frame->srr0;
@@ -332,7 +332,7 @@
p->p_pid, l->l_lid, p->p_comm,
frame->dar, frame->srr0, frame->dsisr);
}
- memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGBUS;
ksi.ksi_trap = EXC_ALI;
ksi.ksi_addr = (void *)frame->dar;
@@ -360,7 +360,7 @@
p->p_pid, l->l_lid, p->p_comm,
frame->srr0, frame->srr1);
}
- memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGILL;
ksi.ksi_trap = EXC_PGM;
ksi.ksi_addr = (void *)frame->srr0;
@@ -377,7 +377,7 @@
"(SSR1=%#lx)\n",
p->p_pid, p->p_comm, frame->srr0, frame->srr1);
}
- memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGBUS;
ksi.ksi_trap = EXC_MCHK;
ksi.ksi_addr = (void *)frame->srr0;
@@ -391,7 +391,7 @@
if (frame->srr1 & 0x00020000) { /* Bit 14 is set if trap */
if (p->p_nras == 0 ||
ras_lookup(p, (caddr_t)frame->srr0) == (caddr_t) -1) {
- memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGTRAP;
ksi.ksi_trap = EXC_PGM;
ksi.ksi_addr = (void *)frame->srr0;
@@ -406,7 +406,7 @@
printf("trap: pid %d.%d (%s): user PGM trap @"
" %#lx (SSR1=%#lx)\n", p->p_pid, l->l_lid,
p->p_comm, frame->srr0, frame->srr1);
- memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGILL;
ksi.ksi_trap = EXC_PGM;
ksi.ksi_addr = (void *)frame->srr0;
Index: arch/sh5/sh5/sig_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sh5/sh5/sig_machdep.c,v
retrieving revision 1.17
diff -u -r1.17 sig_machdep.c
--- arch/sh5/sh5/sig_machdep.c 5 Oct 2003 09:57:47 -0000 1.17
+++ arch/sh5/sh5/sig_machdep.c 7 Oct 2003 17:34:03 -0000
@@ -95,7 +95,7 @@
ssp = (struct sigframe_siginfo *)((caddr_t)ssp - ((fsize + 15) & ~15));
/* Build stack frame for signal trampoline. */
- kss.sf_si._info = *ksi;
+ kss.sf_si._info = ksi->ksi_info;
kss.sf_uc.uc_flags = _UC_SIGMASK;
kss.sf_uc.uc_sigmask = *returnmask;
kss.sf_uc.uc_link = NULL;
Index: arch/sh5/sh5/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sh5/sh5/trap.c,v
retrieving revision 1.28
diff -u -r1.28 trap.c
--- arch/sh5/sh5/trap.c 5 Oct 2003 09:57:47 -0000 1.28
+++ arch/sh5/sh5/trap.c 7 Oct 2003 17:34:04 -0000
@@ -215,7 +215,7 @@
printf("ksp=0x%lx\n", (vaddr_t)tf);
if (traptype & T_USER) {
/* This shouldn't happen ... */
- (void) memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGILL;
ksi.ksi_code = ILL_ILLTRP;
ksi.ksi_addr = (void *)(uintptr_t)tf->tf_state.sf_tea;
@@ -234,7 +234,7 @@
case T_EXECPROT|T_USER:
case T_READPROT|T_USER:
- (void) memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGSEGV;
ksi.ksi_code = SEGV_ACCERR;
ksi.ksi_addr = (void *)(uintptr_t)tf->tf_state.sf_tea;
@@ -244,7 +244,7 @@
case T_IADDERR|T_USER:
case T_RADDERR|T_USER:
case T_WADDERR|T_USER:
- (void) memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGBUS;
ksi.ksi_code = BUS_ADRERR;
ksi.ksi_addr = (void *)(uintptr_t)tf->tf_state.sf_tea;
@@ -352,7 +352,7 @@
if ((traptype & T_USER) == 0)
goto copyfault;
- (void) memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGSEGV;
ksi.ksi_code = SEGV_MAPERR;
ksi.ksi_addr = (void *)(uintptr_t)tf->tf_state.sf_tea;
@@ -397,7 +397,7 @@
return;
case T_BREAK|T_USER:
- (void) memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGTRAP;
ksi.ksi_code = TRAP_BRKPT;
ksi.ksi_addr = (void *)(uintptr_t)tf->tf_state.sf_spc;
@@ -406,7 +406,7 @@
case T_RESINST|T_USER:
case T_FPUDIS|T_USER:
- (void) memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGILL;
ksi.ksi_code = ILL_ILLOPC;
ksi.ksi_addr = (void *)(uintptr_t)tf->tf_state.sf_spc;
@@ -415,7 +415,7 @@
case T_ILLSLOT|T_USER:
case T_SLOTFPUDIS|T_USER:
- (void) memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGILL;
ksi.ksi_code = ILL_ILLOPC; /* XXX: Could do with ILL_DELAYSLOT */
ksi.ksi_addr = (void *)(uintptr_t)tf->tf_state.sf_spc;
@@ -423,7 +423,7 @@
break;
case T_FPUEXC|T_USER:
- (void) memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGFPE;
ksi.ksi_addr = (void *)(uintptr_t)tf->tf_state.sf_spc;
ksi.ksi_trap = T_FPUEXC;
@@ -486,7 +486,7 @@
/*FALLTHROUGH*/
case T_TRAP|T_USER:
- (void) memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGILL;
ksi.ksi_code = ILL_ILLTRP;
ksi.ksi_addr = (void *)(uintptr_t)tf->tf_state.sf_spc;
@@ -494,7 +494,7 @@
break;
case T_DIVZERO|T_USER:
- (void) memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGFPE;
ksi.ksi_code = FPE_INTDIV;
ksi.ksi_addr = (void *)(uintptr_t)tf->tf_state.sf_spc;
Index: arch/sparc/sparc/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc/sparc/machdep.c,v
retrieving revision 1.234
diff -u -r1.234 machdep.c
--- arch/sparc/sparc/machdep.c 5 Oct 2003 21:13:23 -0000 1.234
+++ arch/sparc/sparc/machdep.c 7 Oct 2003 17:34:06 -0000
@@ -540,7 +540,7 @@
int addr, onstack, oldsp, newsp;
struct sigframe_sigcontext sf;
int sig = ksi->ksi_signo;
- u_long code = ksi->ksi_trap;
+ u_long code = KSI_TRAPCODE(ksi);
sig_t catcher = SIGACTION(p, sig).sa_handler;
tf = l->l_md.md_tf;
@@ -723,7 +723,7 @@
*/
sf.sf_sip = &fp->sf_si;
sf.sf_ucp = &fp->sf_uc;
- sf.sf_si._info = *ksi;
+ sf.sf_si._info = ksi->ksi_info;
sf.sf_uc.uc_flags = _UC_SIGMASK /*|
((p->p_sigctx.ps_sigstk.ss_flags & SS_ONSTACK)
? _UC_SETSTACK : _UC_CLRSTACK)*/;
Index: arch/sparc/sparc/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc/sparc/trap.c,v
retrieving revision 1.143
diff -u -r1.143 trap.c
--- arch/sparc/sparc/trap.c 5 Oct 2003 21:13:23 -0000 1.143
+++ arch/sparc/sparc/trap.c 7 Oct 2003 17:34:08 -0000
@@ -448,6 +448,7 @@
PSR_BITS, bits, sizeof(bits)));
sig = SIGILL;
ucode = type;
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type;
ksi.ksi_code = ILL_ILLTRP;
ksi.ksi_addr = (void *)pc;
@@ -463,6 +464,7 @@
p->p_comm, p->p_pid, type);
#endif
sig = SIGILL;
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type;
ksi.ksi_code = ILL_ILLTRP;
ksi.ksi_addr = (void *)pc;
@@ -490,6 +492,7 @@
ADVANCE;
break;
}
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type;
ksi.ksi_code = ILL_ILLOPC;
ksi.ksi_addr = (void *)pc;
@@ -497,6 +500,7 @@
case T_PRIVINST:
sig = SIGILL;
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type;
ksi.ksi_code = ILL_PRVOPC;
ksi.ksi_addr = (void *)pc;
@@ -530,6 +534,7 @@
#else
sig = SIGFPE;
/* XXX - ucode? */
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type;
ksi.ksi_code = 0;
ksi.ksi_addr = (void *)pc;
@@ -667,6 +672,7 @@
}
}
sig = SIGBUS;
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type;
ksi.ksi_code = BUS_ADRALN;
ksi.ksi_addr = (void *)pc;
@@ -700,6 +706,7 @@
case T_TAGOF:
sig = SIGEMT;
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type;
ksi.ksi_code = 0;
ksi.ksi_addr = (void *)pc;
@@ -708,6 +715,7 @@
case T_CPDISABLED:
uprintf("coprocessor instruction\n"); /* XXX */
sig = SIGILL;
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type;
ksi.ksi_code = ILL_COPROC;
ksi.ksi_addr = (void *)pc;
@@ -715,6 +723,7 @@
case T_BREAKPOINT:
sig = SIGTRAP;
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type;
ksi.ksi_code = TRAP_BRKPT;
ksi.ksi_addr = (void *)pc;
@@ -724,6 +733,7 @@
case T_IDIV0:
ADVANCE;
sig = SIGFPE;
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type;
ksi.ksi_code = FPE_INTDIV;
ksi.ksi_addr = (void *)pc;
@@ -749,6 +759,7 @@
uprintf("T_RANGECHECK\n"); /* XXX */
ADVANCE;
sig = SIGILL;
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type;
ksi.ksi_code = ILL_ILLADR;
ksi.ksi_addr = (void *)pc;
@@ -768,6 +779,7 @@
uprintf("T_INTOF\n"); /* XXX */
ADVANCE;
sig = SIGFPE;
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type;
ksi.ksi_code = FPE_INTOVF;
ksi.ksi_addr = (void *)pc;
@@ -1039,6 +1051,7 @@
ksi.ksi_code = (rv == EACCES
? SEGV_ACCERR : SEGV_MAPERR);
}
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type;
ksi.ksi_addr = (void *)v;
trapsignal(l, &ksi);
@@ -1324,6 +1337,7 @@
ksi.ksi_code = (rv == EACCES)
? SEGV_ACCERR : SEGV_MAPERR;
}
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type;
ksi.ksi_addr = (void *)sfva;
trapsignal(l, &ksi);
Index: arch/sun2/sun2/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sun2/sun2/trap.c,v
retrieving revision 1.13
diff -u -r1.13 trap.c
--- arch/sun2/sun2/trap.c 22 Sep 2003 14:27:15 -0000 1.13
+++ arch/sun2/sun2/trap.c 7 Oct 2003 17:34:08 -0000
@@ -273,7 +273,7 @@
uvmexp.traps++;
l = curlwp;
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type & ~T_USER;
/* I have verified that this DOES happen! -gwr */
Index: arch/sun3/sun3/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sun3/sun3/trap.c,v
retrieving revision 1.112
diff -u -r1.112 trap.c
--- arch/sun3/sun3/trap.c 22 Sep 2003 14:27:13 -0000 1.112
+++ arch/sun3/sun3/trap.c 7 Oct 2003 17:34:09 -0000
@@ -282,7 +282,7 @@
uvmexp.traps++;
l = curlwp;
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type & ~T_USER;
/* I have verified that this DOES happen! -gwr */
Index: arch/vax/vax/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/vax/vax/trap.c,v
retrieving revision 1.85
diff -u -r1.85 trap.c
--- arch/vax/vax/trap.c 29 Sep 2003 22:24:53 -0000 1.85
+++ arch/vax/vax/trap.c 7 Oct 2003 17:34:10 -0000
@@ -371,7 +371,7 @@
p->p_pid, l->l_lid, p->p_comm, sig, frame->trap,
frame->code, frame->pc, frame->psl);
KERNEL_PROC_LOCK(l);
- memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = sig;
ksi.ksi_trap = frame->trap;
ksi.ksi_addr = (void *)frame->code;
Index: arch/x68k/x68k/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x68k/x68k/trap.c,v
retrieving revision 1.66
diff -u -r1.66 trap.c
--- arch/x68k/x68k/trap.c 22 Sep 2003 14:27:14 -0000 1.66
+++ arch/x68k/x68k/trap.c 7 Oct 2003 17:34:11 -0000
@@ -329,7 +329,7 @@
uvmexp.traps++;
l = curlwp;
- (void)memset(&ksi, 0, sizeof(ksi));
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_trap = type & ~T_USER;
/* I have verified that this DOES happen! -gwr */
Index: kern/kern_ktrace.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_ktrace.c,v
retrieving revision 1.79
diff -u -r1.79 kern_ktrace.c
--- kern/kern_ktrace.c 25 Sep 2003 21:59:18 -0000 1.79
+++ kern/kern_ktrace.c 7 Oct 2003 17:34:20 -0000
@@ -317,9 +317,9 @@
kbuf.kp.mask = *mask;
kth.ktr_buf = (caddr_t)&kbuf;
if (ksi) {
- kbuf.kp.code = ksi->ksi_code > 0 ? ksi->ksi_trap : 0;
+ kbuf.kp.code = KSI_TRAPCODE(ksi);
(void)memset(&kbuf.si, 0, sizeof(kbuf.si));
- kbuf.si._info = *ksi;
+ kbuf.si._info = ksi->ksi_info;
kth.ktr_len = sizeof(kbuf);
} else {
kbuf.kp.code = 0;
Index: kern/kern_sig.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_sig.c,v
retrieving revision 1.165
diff -u -r1.165 kern_sig.c
--- kern/kern_sig.c 7 Oct 2003 00:23:17 -0000 1.165
+++ kern/kern_sig.c 7 Oct 2003 17:34:22 -0000
@@ -870,7 +870,8 @@
{
#define trapsignal _trapsignal
ksiginfo_t ksi;
- memset(&ksi, 0, sizeof(ksi));
+
+ KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = signum;
ksi.ksi_trap = (int)code;
trapsignal(l, &ksi);
@@ -884,6 +885,8 @@
struct sigacts *ps;
int signum = ksi->ksi_signo;
+ KASSERT((ksi->ksi_flags & KSI_TRAP) != 0);
+
p = l->l_proc;
ps = p->p_sigacts;
if ((p->p_flag & P_TRACED) == 0 &&
@@ -1306,9 +1309,9 @@
f = l->l_flag & L_SA;
l->l_flag &= ~L_SA;
si = pool_get(&siginfo_pool, PR_WAITOK);
- si->_info = *ksi;
+ si->_info = ksi->ksi_info;
le = li = NULL;
- if (ksi->ksi_trap)
+ if (ksi->ksi_flags & KSI_TRAP)
le = l;
else
li = l;
@@ -1322,7 +1325,7 @@
#ifdef __HAVE_SIGINFO
(*p->p_emul->e_sendsig)(ksi, mask);
#else
- (*p->p_emul->e_sendsig)(ksi->ksi_signo, mask, ksi->ksi_trap);
+ (*p->p_emul->e_sendsig)(ksi->ksi_signo, mask, KSI_TRAPCODE(ksi));
#endif
}
Index: kern/kern_time.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_time.c,v
retrieving revision 1.76
diff -u -r1.76 kern_time.c
--- kern/kern_time.c 14 Sep 2003 06:56:22 -0000 1.76
+++ kern/kern_time.c 7 Oct 2003 17:34:24 -0000
@@ -889,7 +889,7 @@
f = l->l_flag & L_SA;
l->l_flag &= ~L_SA;
si = pool_get(&siginfo_pool, PR_WAITOK);
- si->_info = pt->pts_timers[i]->pt_info;
+ si->_info = pt->pts_timers[i]->pt_info.ksi_info;
if (sa_upcall(l, SA_UPCALL_SIGEV | SA_UPCALL_DEFER, NULL, l,
sizeof(*si), si) == 0)
done |= mask;
Index: sys/siginfo.h
===================================================================
RCS file: /cvsroot/src/sys/sys/siginfo.h,v
retrieving revision 1.4
diff -u -r1.4 siginfo.h
--- sys/siginfo.h 16 Sep 2003 12:04:58 -0000 1.4
+++ sys/siginfo.h 7 Oct 2003 17:34:32 -0000
@@ -47,7 +47,7 @@
void *sival_ptr;
} sigval_t;
-struct ksiginfo {
+struct _ksiginfo {
int _signo;
int _code;
int _errno;
@@ -80,12 +80,39 @@
int _fd;
} _poll;
} _reason;
- CIRCLEQ_ENTRY(ksiginfo) _list;
};
+#ifdef _KERNEL
+typedef struct ksiginfo {
+ u_long ksi_flags; /* 4 or 8 bytes, depending on LP64 */
+ CIRCLEQ_ENTRY(ksiginfo) ksi_list;
+ struct _ksiginfo ksi_info;
+} ksiginfo_t;
+
+#define KSI_TRAP 0x01 /* signal caused by trap */
+
+/* Macros to initialize a ksiginfo_t. */
+#define KSI_INIT(ksi) \
+do { \
+ memset((ksi), 0, sizeof(*(ksi))); \
+} while (/*CONSTCOND*/0)
+
+#define KSI_INIT_TRAP(ksi) \
+do { \
+ KSI_INIT((ksi)); \
+ (ksi)->ksi_flags |= KSI_TRAP; \
+} while (/*CONSTCOND*/0)
+
+/*
+ * Old-style signal handler "code" arguments were only non-zero for
+ * signals caused by traps.
+ */
+#define KSI_TRAPCODE(ksi) (((ksi)->ksi_flags & KSI_TRAP) ? ksi->ksi_trap : 0)
+#endif /* _KERNEL */
+
typedef union siginfo {
char si_pad[128]; /* Total size; for future expansion */
- struct ksiginfo _info;
+ struct _ksiginfo _info;
} siginfo_t;
/** Field access macros */
@@ -107,27 +134,24 @@
#define si_fd _info._reason._poll._fd
#ifdef _KERNEL
-typedef struct ksiginfo ksiginfo_t;
/** Field access macros */
-#define ksi_signo _signo
-#define ksi_code _code
-#define ksi_errno _errno
-
-#define ksi_sigval _reason._rt._sigval
-#define ksi_pid _reason._child._pid
-#define ksi_uid _reason._child._uid
-#define ksi_status _reason._child._status
-#define ksi_utime _reason._child._utime
-#define ksi_stime _reason._child._stime
-
-#define ksi_addr _reason._fault._addr
-#define ksi_trap _reason._fault._trap
-
-#define ksi_band _reason._poll._band
-#define ksi_fd _reason._poll._fd
-
-#define ksi_list _list
-#endif
+#define ksi_signo ksi_info._signo
+#define ksi_code ksi_info._code
+#define ksi_errno ksi_info._errno
+
+#define ksi_sigval ksi_info._reason._rt._sigval
+#define ksi_pid ksi_info._reason._child._pid
+#define ksi_uid ksi_info._reason._child._uid
+#define ksi_status ksi_info._reason._child._status
+#define ksi_utime ksi_info._reason._child._utime
+#define ksi_stime ksi_info._reason._child._stime
+
+#define ksi_addr ksi_info._reason._fault._addr
+#define ksi_trap ksi_info._reason._fault._trap
+
+#define ksi_band ksi_info._reason._poll._band
+#define ksi_fd ksi_info._reason._poll._fd
+#endif /* _KERNEL */
/** si_code */
/* SIGILL */
--Apple-Mail-10--804976887--