Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add kernel support for having userland provide the signa...



details:   https://anonhg.NetBSD.org/src/rev/ab080eebabe3
branches:  trunk
changeset: 533601:ab080eebabe3
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Jul 04 23:32:02 2002 +0000

description:
Add kernel support for having userland provide the signal trampoline:

* struct sigacts gets a new sigact_sigdesc structure, which has the
  sigaction and the trampoline/version.  Version 0 means "legacy kernel
  provided trampoline".  Other versions are coordinated with machine-
  dependent code in libc.
* sigaction1() grows two more arguments -- the trampoline pointer and
  the trampoline version.
* A new __sigaction_sigtramp() system call is provided to register a
  trampoline along with a signal handler.
* The handler is no longer passed to sensig() functions.  Instead,
  sendsig() looks up the handler by peeking in the sigacts for the
  process getting the signal (since it has to look in there for the
  trampoline anyway).
* Native sendsig() functions now select the appropriate trampoline and
  its arguments based on the trampoline version in the sigacts.

Changes to libc to use the new facility will be checked in later.  Kernel
version not bumped; we will ride the 1.6C bump made recently.

diffstat:

 sys/arch/alpha/alpha/machdep.c                |  35 ++++++++++++---
 sys/arch/arm/arm/sig_machdep.c                |  47 ++++++++++++++++-----
 sys/arch/hp300/hp300/hpux_machdep.c           |   8 +-
 sys/arch/hp300/include/hpux_machdep.h         |   4 +-
 sys/arch/hppa/hppa/sig_machdep.c              |  31 +++++++++++--
 sys/arch/i386/i386/freebsd_machdep.c          |   8 +-
 sys/arch/i386/i386/ibcs2_machdep.c            |   8 +-
 sys/arch/i386/i386/machdep.c                  |  30 ++++++++++--
 sys/arch/i386/i386/svr4_machdep.c             |   8 +-
 sys/arch/i386/include/freebsd_machdep.h       |   4 +-
 sys/arch/i386/include/ibcs2_machdep.h         |   4 +-
 sys/arch/m68k/m68k/sig_machdep.c              |  24 +++++++++-
 sys/arch/m68k/m68k/sunos_machdep.c            |   6 +-
 sys/arch/m68k/m68k/svr4_machdep.c             |   6 +-
 sys/arch/mips/mips/mips_machdep.c             |  34 +++++++++++---
 sys/arch/pc532/pc532/machdep.c                |  29 ++++++++++--
 sys/arch/powerpc/powerpc/sig_machdep.c        |  41 ++++++++++++++----
 sys/arch/sh3/sh3/sh3_machdep.c                |  23 +++++++++-
 sys/arch/sparc/sparc/machdep.c                |  24 +++++++++-
 sys/arch/sparc/sparc/sunos_machdep.c          |   6 +-
 sys/arch/sparc/sparc/svr4_machdep.c           |   6 +-
 sys/arch/sparc64/include/netbsd32_machdep.h   |   4 +-
 sys/arch/sparc64/sparc64/machdep.c            |  24 +++++++++-
 sys/arch/sparc64/sparc64/netbsd32_machdep.c   |   4 +-
 sys/arch/sparc64/sparc64/sunos32_machdep.c    |   6 +-
 sys/arch/sparc64/sparc64/sunos_machdep.c      |   6 +-
 sys/arch/sparc64/sparc64/svr4_32_machdep.c    |   6 +-
 sys/arch/sparc64/sparc64/svr4_machdep.c       |   6 +-
 sys/arch/vax/include/ibcs2_machdep.h          |   4 +-
 sys/arch/vax/vax/ibcs2_machdep.c              |   7 +-
 sys/arch/vax/vax/machdep.c                    |  27 ++++++++++-
 sys/arch/x86_64/include/netbsd32_machdep.h    |   4 +-
 sys/arch/x86_64/x86_64/machdep.c              |  23 ++++++++-
 sys/arch/x86_64/x86_64/netbsd32_machdep.c     |   5 +-
 sys/compat/common/kern_sig_13.c               |   7 +-
 sys/compat/common/kern_sig_43.c               |   7 +-
 sys/compat/freebsd/freebsd_misc.c             |   7 +-
 sys/compat/hpux/hpux_sig.c                    |  11 ++--
 sys/compat/ibcs2/ibcs2_signal.c               |  11 ++--
 sys/compat/irix/irix_signal.c                 |   8 +-
 sys/compat/irix/irix_signal.h                 |   4 +-
 sys/compat/linux/arch/alpha/linux_machdep.c   |   8 +-
 sys/compat/linux/arch/arm/linux_machdep.c     |   8 +-
 sys/compat/linux/arch/i386/linux_machdep.c    |   8 +-
 sys/compat/linux/arch/i386/linux_machdep.h    |   4 +-
 sys/compat/linux/arch/m68k/linux_machdep.c    |   8 +-
 sys/compat/linux/arch/mips/linux_machdep.c    |   8 +-
 sys/compat/linux/arch/powerpc/linux_machdep.c |   8 +-
 sys/compat/linux/common/linux_machdep.h       |   4 +-
 sys/compat/linux/common/linux_sig_notalpha.c  |   6 +-
 sys/compat/linux/common/linux_sigaction.c     |   7 +-
 sys/compat/linux/common/linux_signal.c        |   8 ++-
 sys/compat/netbsd32/netbsd32_signal.c         |  10 ++-
 sys/compat/sunos/sunos.h                      |   4 +-
 sys/compat/sunos/sunos_misc.c                 |   7 +-
 sys/compat/sunos32/sunos32.h                  |   4 +-
 sys/compat/sunos32/sunos32_misc.c             |   7 +-
 sys/compat/svr4/svr4_signal.c                 |  11 ++--
 sys/compat/svr4/svr4_signal.h                 |   4 +-
 sys/compat/svr4_32/svr4_32_signal.c           |  11 ++--
 sys/compat/svr4_32/svr4_32_signal.h           |   4 +-
 sys/compat/ultrix/ultrix_misc.c               |   7 +-
 sys/kern/kern_sig.c                           |  59 +++++++++++++++++++++++---
 sys/kern/syscalls.master                      |   6 ++-
 sys/sys/proc.h                                |   4 +-
 sys/sys/signalvar.h                           |  17 +++++--
 66 files changed, 552 insertions(+), 247 deletions(-)

diffs (truncated from 2424 to 300 lines):

diff -r 868c2f41b166 -r ab080eebabe3 sys/arch/alpha/alpha/machdep.c
--- a/sys/arch/alpha/alpha/machdep.c    Thu Jul 04 23:30:39 2002 +0000
+++ b/sys/arch/alpha/alpha/machdep.c    Thu Jul 04 23:32:02 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.255 2002/07/01 03:10:01 thorpej Exp $ */
+/* $NetBSD: machdep.c,v 1.256 2002/07/04 23:32:02 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.255 2002/07/01 03:10:01 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.256 2002/07/04 23:32:02 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1497,16 +1497,17 @@
  * Send an interrupt to process.
  */
 void
-sendsig(catcher, sig, mask, code)
-       sig_t catcher;
+sendsig(sig, mask, code)
        int sig;
        sigset_t *mask;
        u_long code;
 {
        struct proc *p = curproc;
+       struct sigacts *ps = p->p_sigacts;
        struct sigcontext *scp, ksc;
        struct trapframe *frame;
        int onstack, fsize, rndfsize;
+       sig_t catcher = SIGACTION(p, sig).sa_handler;
 
        frame = p->p_md.md_tf;
 
@@ -1598,13 +1599,33 @@
                    scp, code);
 #endif
 
-       /* Set up the registers to return to sigcode. */
+       /*
+        * Set up the registers to directly invoke the signal handler.  The
+        * signal trampoline is then used to return from the signal.  Note
+        * the trampoline version numbers are coordinated with machine-
+        * dependent code in libc.
+        */
+       switch (ps->sa_sigdesc[sig].sd_vers) {
+#if 1 /* COMPAT_16 */
+       case 0:         /* legacy on-stack sigtramp */
+               frame->tf_regs[FRAME_RA] = (u_int64_t)p->p_sigctx.ps_sigcode;
+               break;
+#endif /* COMPAT_16 */
+
+       case 1:
+               frame->tf_regs[FRAME_RA] =
+                   (u_int64_t)ps->sa_sigdesc[sig].sd_tramp;
+               break;
+
+       default:
+               /* Don't know what trampoline version; kill it. */
+               sigexit(p, SIGILL);
+       }
        frame->tf_regs[FRAME_PC] = (u_int64_t)catcher;
        frame->tf_regs[FRAME_A0] = sig;
        frame->tf_regs[FRAME_A1] = code;
        frame->tf_regs[FRAME_A2] = (u_int64_t)scp;
-       frame->tf_regs[FRAME_T12] = (u_int64_t)catcher;         /* t12 is pv */
-       frame->tf_regs[FRAME_RA] = (u_int64_t)p->p_sigctx.ps_sigcode;
+       frame->tf_regs[FRAME_T12] = (u_int64_t)catcher;
        alpha_pal_wrusp((unsigned long)scp);
 
        /* Remember that we're now on the signal stack. */
diff -r 868c2f41b166 -r ab080eebabe3 sys/arch/arm/arm/sig_machdep.c
--- a/sys/arch/arm/arm/sig_machdep.c    Thu Jul 04 23:30:39 2002 +0000
+++ b/sys/arch/arm/arm/sig_machdep.c    Thu Jul 04 23:32:02 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sig_machdep.c,v 1.13 2002/06/23 19:16:43 thorpej Exp $ */
+/*     $NetBSD: sig_machdep.c,v 1.14 2002/07/04 23:32:03 thorpej Exp $ */
 
 /*
  * Copyright (c) 1994-1998 Mark Brinicombe.
@@ -44,7 +44,7 @@
 
 #include <sys/param.h>
 
-__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.13 2002/06/23 19:16:43 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.14 2002/07/04 23:32:03 thorpej Exp $");
 
 #include <sys/mount.h>         /* XXX only needed by syscallargs.h */
 #include <sys/proc.h>
@@ -79,12 +79,14 @@
  * frame pointer, it returns to the user specified pc.
  */
 void
-sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
+sendsig(int sig, sigset_t *mask, u_long code)
 {
        struct proc *p = curproc;
+       struct sigacts *ps = p->p_sigacts;
        struct trapframe *tf;
        struct sigframe *fp, frame;
        int onstack;
+       sig_t catcher = SIGACTION(p, sig).sa_handler;
 
        tf = process_frame(p);
 
@@ -149,18 +151,39 @@
 
        /*
         * Build context to run handler in.  We invoke the handler
-        * directly, only returning via the trampoline.
+        * dorectly, only returning via the trampoline.  Note the
+        * trampoline version numbers are coordinated with machine-
+        * depdent code in libc.
         */
-       tf->tf_r0 = sig;
-       tf->tf_r1 = code;
-       tf->tf_r2 = (int)&fp->sf_sc;
-       tf->tf_pc = (int)catcher;
-       tf->tf_usr_sp = (int)fp;
-       tf->tf_usr_lr = (int)p->p_sigctx.ps_sigcode;
+       switch (ps->sa_sigdesc[sig].sd_vers) {
+#if 1 /* COMPAT_16 */
+       case 0:         /* legacy on-stack sigtramp */
+               tf->tf_r0 = sig;
+               tf->tf_r1 = code;
+               tf->tf_r2 = (int)&fp->sf_sc;
+               tf->tf_pc = (int)catcher;
+               tf->tf_usr_sp = (int)fp;
+               tf->tf_usr_lr = (int)p->p_sigctx.ps_sigcode;
 #ifndef acorn26
-       /* XXX This should not be needed. */
-       cpu_icache_sync_all();
+               /* XXX This should not be needed. */
+               cpu_icache_sync_all();
 #endif
+               break;
+#endif /* COMPAT_16 */
+
+       case 1:
+               tf->tf_r0 = sig;
+               tf->tf_r1 = code;
+               tf->tf_r2 = (int)&fp->sf_sc;
+               tf->tf_pc = (int)catcher;
+               tf->tf_usr_sp = (int)fp;
+               tf->tf_usr_lr = (int)ps->sa_sigdesc[sig].sd_tramp;
+               break;
+
+       default:
+               /* Don't know what trampoline version; kill it. */
+               sigexit(p, SIGILL);
+       }
 
        /* Remember that we're now on the signal stack. */
        if (onstack)
diff -r 868c2f41b166 -r ab080eebabe3 sys/arch/hp300/hp300/hpux_machdep.c
--- a/sys/arch/hp300/hp300/hpux_machdep.c       Thu Jul 04 23:30:39 2002 +0000
+++ b/sys/arch/hp300/hp300/hpux_machdep.c       Thu Jul 04 23:32:02 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hpux_machdep.c,v 1.28 2002/03/15 05:55:37 gmcgarry Exp $       */
+/*     $NetBSD: hpux_machdep.c,v 1.29 2002/07/04 23:32:03 thorpej Exp $        */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hpux_machdep.c,v 1.28 2002/03/15 05:55:37 gmcgarry Exp $");                                                  
+__KERNEL_RCSID(0, "$NetBSD: hpux_machdep.c,v 1.29 2002/07/04 23:32:03 thorpej Exp $");                                                  
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -418,8 +418,7 @@
  * Send an interrupt to process.
  */
 void
-hpux_sendsig(catcher, sig, mask, code)
-       sig_t catcher;
+hpux_sendsig(sig, mask, code)
        int sig;
        sigset_t *mask;
        u_long code;
@@ -429,6 +428,7 @@
        struct frame *frame;
        short ft;
        int onstack, fsize;
+       sig_t catcher = SIGACTION(p, sig).sa_handler;
 
        frame = (struct frame *)p->p_md.md_regs;
        ft = frame->f_format;
diff -r 868c2f41b166 -r ab080eebabe3 sys/arch/hp300/include/hpux_machdep.h
--- a/sys/arch/hp300/include/hpux_machdep.h     Thu Jul 04 23:30:39 2002 +0000
+++ b/sys/arch/hp300/include/hpux_machdep.h     Thu Jul 04 23:32:02 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hpux_machdep.h,v 1.11 1998/10/01 08:28:30 thorpej Exp $        */
+/*     $NetBSD: hpux_machdep.h,v 1.12 2002/07/04 23:32:03 thorpej Exp $        */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
 int    hpux_cpu_sysconf_arch __P((void));
 int    hpux_to_bsd_uoff __P((int *, int *, struct proc *));
 
-void   hpux_sendsig __P((sig_t, int, sigset_t *, u_long));
+void   hpux_sendsig __P((int, sigset_t *, u_long));
 void   hpux_setregs __P((struct proc *, struct exec_package *,
            u_long));
 #endif /* _KERNEL */
diff -r 868c2f41b166 -r ab080eebabe3 sys/arch/hppa/hppa/sig_machdep.c
--- a/sys/arch/hppa/hppa/sig_machdep.c  Thu Jul 04 23:30:39 2002 +0000
+++ b/sys/arch/hppa/hppa/sig_machdep.c  Thu Jul 04 23:32:02 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sig_machdep.c,v 1.1 2002/06/05 01:04:20 fredette Exp $ */
+/*     $NetBSD: sig_machdep.c,v 1.2 2002/07/04 23:32:04 thorpej Exp $  */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -107,17 +107,18 @@
  * Send an interrupt to process.
  */
 void
-sendsig(catcher, sig, mask, code)
-       sig_t catcher;
+sendsig(sig, mask, code)
        int sig;
        sigset_t *mask;
        u_long code;
 {
        struct proc *p = curproc;
+       struct sigacts *ps = p->p_sigacts;
        struct sigframe *fp, kf;
        caddr_t sp;
        struct trapframe *tf;
        int onstack, fsize;
+       sig_t catcher = SIGACTION(p, sig).sa_handler;
 
        tf = (struct trapframe *)p->p_md.md_regs;
 
@@ -198,15 +199,33 @@
 #endif
 
        /* Set up the registers to return to sigcode. */
+       switch (ps->sa_sigdesc[sig].sd_vers) {
+#if 1 /* COMPAT_16 */
+       case 0:         /* legacy on-stack sigtramp */
+               tf->tf_iioq_head =
+                   (int)p->p_sigctx.ps_sigcode | HPPA_PC_PRIV_USER;
+               tf->tf_iioq_tail = tf->tf_iioq_head + 4;
+               break;
+#endif
+
+       case 1:
+               tf->tf_iioq_head =
+                   (int)ps->sa_sigdesc[sig].sd_tramp | HPPA_PC_PRIV_USER;
+               tf->tf_iioq_tail = tf->tf_iioq_head + 4;
+               break;
+
+       default:
+               /* Don't know what trampoline version; kill it. */
+               sigexit(p, SIGILL);
+       }
+
        tf->tf_sp = (int)sp;
        tf->tf_r3 = (int)&fp->sf_sc;
-       tf->tf_iioq_head = (int)p->p_sigctx.ps_sigcode | HPPA_PC_PRIV_USER;
-       tf->tf_iioq_tail = tf->tf_iioq_head + 4;
        tf->tf_arg0 = sig;
        tf->tf_arg1 = code;
        tf->tf_arg2 = (int)&fp->sf_sc;
        tf->tf_arg3 = (int)catcher;
-       
+
        /* Remember that we're now on the signal stack. */
        if (onstack)
                p->p_sigctx.ps_sigstk.ss_flags |= SS_ONSTACK;
diff -r 868c2f41b166 -r ab080eebabe3 sys/arch/i386/i386/freebsd_machdep.c
--- a/sys/arch/i386/i386/freebsd_machdep.c      Thu Jul 04 23:30:39 2002 +0000
+++ b/sys/arch/i386/i386/freebsd_machdep.c      Thu Jul 04 23:32:02 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: freebsd_machdep.c,v 1.32 2002/04/02 22:33:19 christos Exp $    */
+/*     $NetBSD: freebsd_machdep.c,v 1.33 2002/07/04 23:32:04 thorpej Exp $     */
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: freebsd_machdep.c,v 1.32 2002/04/02 22:33:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: freebsd_machdep.c,v 1.33 2002/07/04 23:32:04 thorpej Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vm86.h"
@@ -92,8 +92,7 @@
  * specified pc, psl.
  */



Home | Main Index | Thread Index | Old Index