From: deraadt Date: Mon, 3 Feb 1997 15:04:50 +0000 (+0000) Subject: More siginfo implementations (alpha and mips might even work) X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2bf9c1551d503f29f0ff3148dd08fd9117eb6a39;p=openbsd More siginfo implementations (alpha and mips might even work) move "siginfo_t *" to 2nd arg of signal handler as 1003.1b requires. I really wish I had 1003.1b documentation. --- diff --git a/sys/arch/alpha/alpha/machdep.c b/sys/arch/alpha/alpha/machdep.c index 87cb15c33af..26b8ac2d50d 100644 --- a/sys/arch/alpha/alpha/machdep.c +++ b/sys/arch/alpha/alpha/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.16 1997/02/03 13:09:14 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.17 1997/02/03 15:05:02 deraadt Exp $ */ /* $NetBSD: machdep.c,v 1.61 1996/12/07 01:54:49 cgd Exp $ */ /* @@ -1145,14 +1145,20 @@ sendsig(catcher, sig, mask, code, type, val) struct sigcontext *scp, ksc; struct trapframe *frame; struct sigacts *psp = p->p_sigacts; - int oonstack, fsize, rndfsize; + int oonstack, fsize, rndfsize, kscsize; extern char sigcode[], esigcode[]; extern struct proc *fpcurproc; + siginfo_t *sip, ksi; frame = p->p_md.md_tf; oonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK; fsize = sizeof ksc; rndfsize = ((fsize + 15) / 16) * 16; + kscsize = rndfsize; + if (psp->ps_siginfo & sigmask(sig)) { + fsize += sizeof ksi; + rndfsize = ((fsize + 15) / 16) * 16; + } /* * Allocate and validate space for the signal handler * context. Note that if the stack is in P0 space, the @@ -1227,10 +1233,16 @@ sendsig(catcher, sig, mask, code, type, val) */ #endif + if (psp->ps_siginfo & sigmask(sig)) { + initsiginfo(&ksi, sig, code, type, val); + sip = (void *)scp + kscsize; + (void) copyout((caddr_t)&ksi, (caddr_t)sip, fsize - kscsize); + } + /* * copy the frame out to userland. */ - (void) copyout((caddr_t)&ksc, (caddr_t)scp, fsize); + (void) copyout((caddr_t)&ksc, (caddr_t)scp, kscsize); #ifdef DEBUG if (sigdebug & SDB_FOLLOW) printf("sendsig(%d): sig %d scp %p code %lx\n", p->p_pid, sig, @@ -1243,7 +1255,8 @@ sendsig(catcher, sig, mask, code, type, val) frame->tf_regs[FRAME_PC] = (u_int64_t)PS_STRINGS - (esigcode - sigcode); frame->tf_regs[FRAME_A0] = sig; - frame->tf_regs[FRAME_A1] = code; + frame->tf_regs[FRAME_A1] = (psp->ps_siginfo & sigmask(sig)) ? + (u_int64_t)sip : NULL; frame->tf_regs[FRAME_A2] = (u_int64_t)scp; frame->tf_regs[FRAME_T12] = (u_int64_t)catcher; /* t12 is pv */ alpha_pal_wrusp((unsigned long)scp); diff --git a/sys/arch/amiga/amiga/locore.s b/sys/arch/amiga/amiga/locore.s index ec274be347c..f63557eeb69 100644 --- a/sys/arch/amiga/amiga/locore.s +++ b/sys/arch/amiga/amiga/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.14 1997/02/03 11:38:05 deraadt Exp $ */ +/* $OpenBSD: locore.s,v 1.15 1997/02/03 15:05:04 deraadt Exp $ */ /* $NetBSD: locore.s,v 1.72 1996/12/17 11:09:10 is Exp $ */ /* @@ -1147,9 +1147,8 @@ _proc_trampoline: * Stack looks like: * * sp+0 -> signal number - * sp+4 signal specific code + * sp+4 pointer to siginfo (sip) * sp+8 pointer to signal context frame (scp) - * sp+12 pointer to siginfo (sip) * sp+16 address of handler * sp+30 saved hardware state * . @@ -1159,7 +1158,7 @@ _proc_trampoline: .globl _sigcode, _esigcode .data _sigcode: - movl sp@(16),a0 | signal handler addr (4 bytes) + movl sp@(12),a0 | signal handler addr (4 bytes) jsr a0@ | call signal handler (2 bytes) addql #4,sp | pop signo (2 bytes) trap #1 | special syscall entry (2 bytes) diff --git a/sys/arch/amiga/amiga/machdep.c b/sys/arch/amiga/amiga/machdep.c index 223ce297bba..f154dd77e87 100644 --- a/sys/arch/amiga/amiga/machdep.c +++ b/sys/arch/amiga/amiga/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.20 1997/02/03 12:48:35 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.21 1997/02/03 15:05:06 deraadt Exp $ */ /* $NetBSD: machdep.c,v 1.82 1996/12/17 07:32:54 is Exp $ */ /* @@ -725,13 +725,12 @@ struct sigstate { */ struct sigframe { int sf_signum; /* signo for handler */ - int sf_code; /* additional info for handler */ + siginfo_t *sf_sip; /* pointer to siginfo_t */ struct sigcontext *sf_scp; /* context ptr for handler */ - siginfo_t *sf_sip; sig_t sf_handler; /* handler addr for u_sigc */ struct sigstate sf_state; /* state of the hardware */ struct sigcontext sf_sc; /* actual context */ - siginfo_t sf_si; + siginfo_t sf_si; /* actual siginfo_t */ }; #ifdef DEBUG @@ -815,7 +814,7 @@ printf("sendsig %d %d %x %x %x\n", p->p_pid, sig, mask, code, catcher); * Build the argument list for the signal handler. */ kfp->sf_signum = sig; - kfp->sf_code = code; + kfp->sf_sip = NULL; kfp->sf_scp = &fp->sf_sc; kfp->sf_handler = catcher; /* diff --git a/sys/arch/arc/arc/machdep.c b/sys/arch/arc/arc/machdep.c index 77f3414f72b..508d98a27bb 100644 --- a/sys/arch/arc/arc/machdep.c +++ b/sys/arch/arc/arc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.19 1997/02/02 00:47:42 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.20 1997/02/03 15:05:08 deraadt Exp $ */ /* * Copyright (c) 1988 University of Utah. * Copyright (c) 1992, 1993 @@ -38,7 +38,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 8.3 (Berkeley) 1/12/94 - * $Id: machdep.c,v 1.19 1997/02/02 00:47:42 deraadt Exp $ + * $Id: machdep.c,v 1.20 1997/02/03 15:05:08 deraadt Exp $ */ /* from: Utah Hdr: machdep.c 1.63 91/04/24 */ @@ -725,10 +725,11 @@ setregs(p, pack, stack, retval) */ struct sigframe { int sf_signum; /* signo for handler */ - int sf_code; /* additional info for handler */ + siginfo_t *sf_sip; /* pointer to siginfo_t */ struct sigcontext *sf_scp; /* context ptr for handler */ sig_t sf_handler; /* handler addr for u_sigc */ struct sigcontext sf_sc; /* actual context */ + siginfo_t sf_si; }; #ifdef DEBUG @@ -768,6 +769,8 @@ sendsig(catcher, sig, mask, code, type, val) * the space with a `brk'. */ fsize = sizeof(struct sigframe); + if (!(psp->ps_siginfo & sigmask(sig))) + fsize -= sizeof(siginfo_t); if ((psp->ps_flags & SAS_ALTSTACK) && (psp->ps_sigstk.ss_flags & SA_ONSTACK) == 0 && (psp->ps_sigonstack & sigmask(sig))) { @@ -805,7 +808,17 @@ sendsig(catcher, sig, mask, code, type, val) bcopy((caddr_t)&p->p_md.md_regs[F0], (caddr_t)ksc.sc_fpregs, sizeof(ksc.sc_fpregs)); } + + if (psp->ps_siginfo & sigmask(sig)) { + siginfo_t si; + + initsiginfo(&si, sig, code, type, val); + if (copyout((caddr_t)&si, (caddr_t)&fp->sf_si, sizeof si)) + goto bail; + } + if (copyout((caddr_t)&ksc, (caddr_t)&fp->sf_sc, sizeof(ksc))) { +bail: /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. @@ -822,7 +835,7 @@ sendsig(catcher, sig, mask, code, type, val) * Build the argument list for the signal handler. */ regs[A0] = sig; - regs[A1] = code; + regs[A1] = (psp->ps_siginfo & sigmask(sig)) ? (int)&fp->sf_si : NULL; regs[A2] = (int)&fp->sf_sc; regs[A3] = (int)catcher; diff --git a/sys/arch/i386/i386/locore.s b/sys/arch/i386/i386/locore.s index 752c612d51b..ef1675332b7 100644 --- a/sys/arch/i386/i386/locore.s +++ b/sys/arch/i386/i386/locore.s @@ -2040,7 +2040,7 @@ IDTVEC(fpu) pushl %esp incl _cnt+V_TRAP call _npxintr - addl $4,%esp + addl $8,%esp INTRFASTEXIT #else ZTRAP(T_ARITHTRAP) diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index b90136c2ceb..5564f0c4953 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.40 1997/02/03 12:48:58 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.41 1997/02/03 15:04:50 deraadt Exp $ */ /* $NetBSD: machdep.c,v 1.202 1996/05/18 15:54:59 christos Exp $ */ /*- @@ -631,10 +631,9 @@ sendsig(catcher, sig, mask, code, type, val) fp = (struct sigframe *)tf->tf_esp - 1; } - frame.sf_code = code; frame.sf_scp = &fp->sf_sc; - frame.sf_handler = catcher; frame.sf_sip = NULL; + frame.sf_handler = catcher; /* * Build the signal context to be used by sigreturn. diff --git a/sys/arch/i386/include/frame.h b/sys/arch/i386/include/frame.h index 8b9d043d00d..d2bea05400f 100644 --- a/sys/arch/i386/include/frame.h +++ b/sys/arch/i386/include/frame.h @@ -115,9 +115,8 @@ struct switchframe { */ struct sigframe { int sf_signum; - int sf_code; - struct sigcontext *sf_scp; siginfo_t *sf_sip; + struct sigcontext *sf_scp; sig_t sf_handler; struct sigcontext sf_sc; siginfo_t sf_si; diff --git a/sys/arch/mvme68k/mvme68k/locore.s b/sys/arch/mvme68k/mvme68k/locore.s index 8ac53ca9b19..89f4dfd53c8 100644 --- a/sys/arch/mvme68k/mvme68k/locore.s +++ b/sys/arch/mvme68k/mvme68k/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.11 1997/01/28 09:01:02 deraadt Exp $ */ +/* $OpenBSD: locore.s,v 1.12 1997/02/03 15:04:57 deraadt Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -527,11 +527,10 @@ _proc_trampoline: * Stack looks like: * * sp+0 -> signal number - * sp+4 signal specific code + * sp+4 pointer to siginfo (sip) * sp+8 pointer to signal context frame (scp) - * sp+12 pointer to siginfo (sip) - * sp+16 address of handler - * sp+20 saved hardware state + * sp+12 address of handler + * sp+16 saved hardware state * . * . * scp+0-> beginning of signal context frame @@ -539,7 +538,7 @@ _proc_trampoline: .globl _sigcode, _esigcode, _sigcodetrap .data _sigcode: - movl sp@(16),a0 | signal handler addr (4 bytes) + movl sp@(12),a0 | signal handler addr (4 bytes) jsr a0@ | call signal handler (2 bytes) addql #4,sp | pop signo (2 bytes) _sigcodetrap: diff --git a/sys/arch/mvme68k/mvme68k/machdep.c b/sys/arch/mvme68k/mvme68k/machdep.c index 73723971129..4f2dd54ab4c 100644 --- a/sys/arch/mvme68k/mvme68k/machdep.c +++ b/sys/arch/mvme68k/mvme68k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.17 1997/02/03 12:48:52 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.18 1997/02/03 15:04:58 deraadt Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -631,9 +631,8 @@ struct sigstate { */ struct sigframe { int sf_signum; /* signo for handler */ - int sf_code; /* additional info for handler */ - struct sigcontext *sf_scp; /* context ptr for handler */ siginfo_t *sf_sip; + struct sigcontext *sf_scp; /* context ptr for handler */ sig_t sf_handler; /* handler addr for u_sigc */ struct sigstate sf_state; /* state of the hardware */ struct sigcontext sf_sc; /* actual context */ @@ -751,10 +750,9 @@ sendsig(catcher, sig, mask, code, type, val) * Build the argument list for the signal handler. */ kfp->sf_signum = sig; - kfp->sf_code = code; + kfp->sf_sip = NULL; kfp->sf_scp = &fp->sf_sc; kfp->sf_handler = catcher; - kfp->sf_sip = NULL; /* * Save necessary hardware state. Currently this includes: diff --git a/sys/arch/pmax/pmax/machdep.c b/sys/arch/pmax/pmax/machdep.c index e1ca75aa662..932b07f0fba 100644 --- a/sys/arch/pmax/pmax/machdep.c +++ b/sys/arch/pmax/pmax/machdep.c @@ -925,10 +925,11 @@ setregs(p, pack, stack, retval) */ struct sigframe { int sf_signum; /* signo for handler */ - int sf_code; /* additional info for handler */ + siginfo_t *sf_sip; /* pointer to siginfo_t */ struct sigcontext *sf_scp; /* context ptr for handler */ sig_t sf_handler; /* handler addr for u_sigc */ struct sigcontext sf_sc; /* actual context */ + siginfo_t sf_si; }; #ifdef DEBUG @@ -968,6 +969,8 @@ sendsig(catcher, sig, mask, code, type, val) * the space with a `brk'. */ fsize = sizeof(struct sigframe); + if (!(psp->ps_siginfo & sigmask(sig))) + fsize -= sizeof(siginfo_t); if ((psp->ps_flags & SAS_ALTSTACK) && (psp->ps_sigstk.ss_flags & SS_ONSTACK) == 0 && (psp->ps_sigonstack & sigmask(sig))) { @@ -1005,7 +1008,17 @@ sendsig(catcher, sig, mask, code, type, val) bcopy((caddr_t)&p->p_md.md_regs[F0], (caddr_t)ksc.sc_fpregs, sizeof(ksc.sc_fpregs)); } + + if (psp->ps_siginfo & sigmask(sig)) { + siginfo_t si; + + initsiginfo(&si, sig, code, type, val); + if (copyout((caddr_t)&si, (caddr_t)&fp->sf_si, sizeof si)) + goto bail; + } + if (copyout((caddr_t)&ksc, (caddr_t)&fp->sf_sc, sizeof(ksc))) { +bail: /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. @@ -1022,7 +1035,7 @@ sendsig(catcher, sig, mask, code, type, val) * Build the argument list for the signal handler. */ regs[A0] = sig; - regs[A1] = code; + regs[A1] = (psp->ps_siginfo & sigmask(sig)) ? (int)&fp->sf_si : NULL; regs[A2] = (int)&fp->sf_sc; regs[A3] = (int)catcher; diff --git a/sys/arch/sparc/sparc/locore.s b/sys/arch/sparc/sparc/locore.s index be852c9725e..54791a51b42 100644 --- a/sys/arch/sparc/sparc/locore.s +++ b/sys/arch/sparc/sparc/locore.s @@ -3711,7 +3711,7 @@ noplab: nop * When this code is run, the stack looks like: * [%sp] 64 bytes to which registers can be dumped * [%sp + 64] signal number (goes in %o0) - * [%sp + 64 + 4] signal code (goes in %o1) + * [%sp + 64 + 4] siginfo_t pointer (goes in %o1) * [%sp + 64 + 8] placeholder * [%sp + 64 + 12] argument for %o3, currently unsupported (always 0) * [%sp + 64 + 16] first word of saved state (sigcontext) diff --git a/sys/arch/sparc/sparc/machdep.c b/sys/arch/sparc/sparc/machdep.c index 9aa15c27dec..f0054117fd9 100644 --- a/sys/arch/sparc/sparc/machdep.c +++ b/sys/arch/sparc/sparc/machdep.c @@ -420,16 +420,13 @@ int sigpid = 0; struct sigframe { int sf_signo; /* signal number */ - int sf_code; /* code */ + siginfo_t *sf_sip; /* points to siginfo_t */ #ifdef COMPAT_SUNOS struct sigcontext *sf_scp; /* points to user addr of sigcontext */ #else int sf_xxx; /* placeholder */ #endif - union { - caddr_t sfu_addr; /* SunOS compat */ - siginfo_t *sfu_sip; /* native */ - } sf_u; + caddr_t sf_addr; /* SunOS compat */ struct sigcontext sf_sc; /* actual sigcontext */ siginfo_t sf_si; }; @@ -509,12 +506,12 @@ sendsig(catcher, sig, mask, code, type, val) * directly in user space.... */ sf.sf_signo = sig; - sf.sf_code = code; - sf.sf_u.sfu_sip = NULL; + sf.sf_sip = NULL; #ifdef COMPAT_SUNOS if (p->p_emul == &emul_sunos) { + sf.sf_sip = (void *)code; /* SunOS has "int code" */ sf.sf_scp = &fp->sf_sc; - sf.sf_u.sfu_addr = val.sival_ptr; + sf.sf_addr = val.sival_ptr; } #endif @@ -531,7 +528,7 @@ sendsig(catcher, sig, mask, code, type, val) sf.sf_sc.sc_o0 = tf->tf_out[0]; if (psp->ps_siginfo & sigmask(sig)) { - sf.sf_u.sfu_sip = &fp->sf_si; + sf.sf_sip = &fp->sf_si; initsiginfo(&sf.sf_si, sig, code, type, val); }