Source-Changes-HG archive

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

[src/trunk]: src/sys * Shuffle some data structures so, and add a flags word ...



details:   https://anonhg.NetBSD.org/src/rev/9826b74a3094
branches:  trunk
changeset: 552968:9826b74a3094
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Oct 08 00:28:40 2003 +0000

description:
* Shuffle some data structures so, and add a flags word to ksiginfo_t.
  Right now the only flag is used to indicate if a ksiginfo_t is a
  result of a trap.  Add a predicate macro to test for this flag.
* Add initialization macros for ksiginfo_t's.
* Add accssor macro for ksi_trap.  Expands to 0 if the ksiginfo_t was
  not the result of a trap.  This matches the sigcontext trapcode semantics.
* In kpsendsig(), use KSI_TRAP_P() to select the lwp that gets the signal.
  Inspired by Matthias Drochner's fix to kpsendsig(), but correctly handles
  the case of non-trap-generated signals that have a > 0 si_code.

This patch fixes a signal delivery problem with threaded programs noted by
Matthias Drochner on tech-kern.

As discussed on tech-kern.  Reviewed and OK's by Christos.

diffstat:

 sys/arch/alpha/alpha/compat_16_machdep.c |   8 +--
 sys/arch/alpha/alpha/trap.c              |  10 +++-
 sys/arch/amiga/amiga/trap.c              |   8 +-
 sys/arch/arm/arm/sig_machdep.c           |   8 +-
 sys/arch/arm/arm/syscall.c               |  12 ++--
 sys/arch/arm/arm/undefined.c             |   9 ++-
 sys/arch/arm/arm32/fault.c               |  14 +++---
 sys/arch/atari/atari/trap.c              |   6 +-
 sys/arch/cesfic/cesfic/trap.c            |   6 +-
 sys/arch/hp300/hp300/hpux_machdep.c      |   6 +-
 sys/arch/hp300/hp300/trap.c              |   6 +-
 sys/arch/i386/i386/compat_16_machdep.c   |   6 +-
 sys/arch/i386/i386/freebsd_machdep.c     |   6 +-
 sys/arch/i386/i386/ibcs2_machdep.c       |   6 +-
 sys/arch/i386/i386/linux_trap.c          |   5 +-
 sys/arch/i386/i386/machdep.c             |   6 +-
 sys/arch/i386/i386/math_emulate.c        |   6 +-
 sys/arch/i386/i386/svr4_machdep.c        |   6 +-
 sys/arch/i386/i386/syscall.c             |   7 +-
 sys/arch/i386/i386/trap.c                |  18 ++++----
 sys/arch/i386/i386/vm86.c                |   8 +-
 sys/arch/luna68k/luna68k/trap.c          |   6 +-
 sys/arch/m68k/m68k/compat_16_machdep.c   |   6 +-
 sys/arch/m68k/m68k/sig_machdep.c         |   6 +-
 sys/arch/m68k/m68k/sunos_machdep.c       |   6 +-
 sys/arch/m68k/m68k/svr4_machdep.c        |   6 +-
 sys/arch/mac68k/mac68k/trap.c            |   6 +-
 sys/arch/mvme68k/mvme68k/trap.c          |   6 +-
 sys/arch/news68k/news68k/trap.c          |   6 +-
 sys/arch/next68k/next68k/trap.c          |   6 +-
 sys/arch/powerpc/ibm4xx/trap.c           |  14 +++---
 sys/arch/powerpc/powerpc/sig_machdep.c   |   6 +-
 sys/arch/powerpc/powerpc/trap.c          |  20 ++++----
 sys/arch/sh5/sh5/sig_machdep.c           |   6 +-
 sys/arch/sh5/sh5/trap.c                  |  24 +++++-----
 sys/arch/sparc/sparc/machdep.c           |   8 +-
 sys/arch/sparc/sparc/trap.c              |  18 +++++++-
 sys/arch/sun2/sun2/trap.c                |   6 +-
 sys/arch/sun3/sun3/trap.c                |   6 +-
 sys/arch/vax/vax/trap.c                  |   6 +-
 sys/arch/x68k/x68k/trap.c                |   6 +-
 sys/kern/kern_ktrace.c                   |   8 +-
 sys/kern/kern_sig.c                      |  15 ++++--
 sys/kern/kern_time.c                     |   6 +-
 sys/sys/siginfo.h                        |  70 ++++++++++++++++++++++---------
 45 files changed, 246 insertions(+), 194 deletions(-)

diffs (truncated from 1816 to 300 lines):

diff -r 4054f25ff469 -r 9826b74a3094 sys/arch/alpha/alpha/compat_16_machdep.c
--- a/sys/arch/alpha/alpha/compat_16_machdep.c  Tue Oct 07 21:47:57 2003 +0000
+++ b/sys/arch/alpha/alpha/compat_16_machdep.c  Wed Oct 08 00:28:40 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_16_machdep.c,v 1.1 2003/10/07 17:04:18 skd Exp $ */
+/* $NetBSD: compat_16_machdep.c,v 1.2 2003/10/08 00:28:40 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -88,7 +88,7 @@
 #include <machine/cpu.h>
 #include <machine/reg.h>
 
-__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.1 2003/10/07 17:04:18 skd Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.2 2003/10/08 00:28:40 thorpej Exp $");
 
 
 #ifdef DEBUG
@@ -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. */
diff -r 4054f25ff469 -r 9826b74a3094 sys/arch/alpha/alpha/trap.c
--- a/sys/arch/alpha/alpha/trap.c       Tue Oct 07 21:47:57 2003 +0000
+++ b/sys/arch/alpha/alpha/trap.c       Wed Oct 08 00:28:40 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.85 2003/10/07 17:04:18 skd Exp $ */
+/* $NetBSD: trap.c,v 1.86 2003/10/08 00:28:41 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -100,7 +100,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.85 2003/10/07 17:04:18 skd Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.86 2003/10/08 00:28:41 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -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) {
diff -r 4054f25ff469 -r 9826b74a3094 sys/arch/amiga/amiga/trap.c
--- a/sys/arch/amiga/amiga/trap.c       Tue Oct 07 21:47:57 2003 +0000
+++ b/sys/arch/amiga/amiga/trap.c       Wed Oct 08 00:28:40 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.95 2003/09/22 14:27:00 cl Exp $     */
+/*     $NetBSD: trap.c,v 1.96 2003/10/08 00:28:41 thorpej Exp $        */
 
 /*
  * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
@@ -83,7 +83,7 @@
 #include "opt_fpu_emulate.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.95 2003/09/22 14:27:00 cl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.96 2003/10/08 00:28:41 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -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 */
diff -r 4054f25ff469 -r 9826b74a3094 sys/arch/arm/arm/sig_machdep.c
--- a/sys/arch/arm/arm/sig_machdep.c    Tue Oct 07 21:47:57 2003 +0000
+++ b/sys/arch/arm/arm/sig_machdep.c    Wed Oct 08 00:28:40 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sig_machdep.c,v 1.21 2003/10/05 19:44:58 matt Exp $    */
+/*     $NetBSD: sig_machdep.c,v 1.22 2003/10/08 00:28:41 thorpej Exp $ */
 
 /*
  * Copyright (c) 1994-1998 Mark Brinicombe.
@@ -45,7 +45,7 @@
 
 #include <sys/param.h>
 
-__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.21 2003/10/05 19:44:58 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.22 2003/10/08 00:28:41 thorpej Exp $");
 
 #include <sys/mount.h>         /* XXX only needed by syscallargs.h */
 #include <sys/proc.h>
@@ -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;
diff -r 4054f25ff469 -r 9826b74a3094 sys/arch/arm/arm/syscall.c
--- a/sys/arch/arm/arm/syscall.c        Tue Oct 07 21:47:57 2003 +0000
+++ b/sys/arch/arm/arm/syscall.c        Wed Oct 08 00:28:40 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: syscall.c,v 1.19 2003/10/05 19:44:58 matt Exp $        */
+/*     $NetBSD: syscall.c,v 1.20 2003/10/08 00:28:41 thorpej Exp $     */
 
 /*-
  * Copyright (c) 2000, 2003 The NetBSD Foundation, Inc.
@@ -82,7 +82,7 @@
 
 #include <sys/param.h>
 
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.19 2003/10/05 19:44:58 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.20 2003/10/08 00:28:41 thorpej Exp $");
 
 #include <sys/device.h>
 #include <sys/errno.h>
@@ -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;
diff -r 4054f25ff469 -r 9826b74a3094 sys/arch/arm/arm/undefined.c
--- a/sys/arch/arm/arm/undefined.c      Tue Oct 07 21:47:57 2003 +0000
+++ b/sys/arch/arm/arm/undefined.c      Wed Oct 08 00:28:40 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: undefined.c,v 1.18 2003/10/05 19:44:58 matt Exp $      */
+/*     $NetBSD: undefined.c,v 1.19 2003/10/08 00:28:41 thorpej Exp $   */
 
 /*
  * Copyright (c) 2001 Ben Harris.
@@ -54,7 +54,7 @@
 #include <sys/kgdb.h>
 #endif
 
-__KERNEL_RCSID(0, "$NetBSD: undefined.c,v 1.18 2003/10/05 19:44:58 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: undefined.c,v 1.19 2003/10/08 00:28:41 thorpej Exp $");
 
 #include <sys/malloc.h>
 #include <sys/queue.h>
@@ -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;
diff -r 4054f25ff469 -r 9826b74a3094 sys/arch/arm/arm32/fault.c
--- a/sys/arch/arm/arm32/fault.c        Tue Oct 07 21:47:57 2003 +0000
+++ b/sys/arch/arm/arm32/fault.c        Wed Oct 08 00:28:40 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fault.c,v 1.34 2003/10/05 19:44:58 matt Exp $  */
+/*     $NetBSD: fault.c,v 1.35 2003/10/08 00:28:41 thorpej Exp $       */
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
 #include "opt_pmap_debug.h"
 
 #include <sys/types.h>
-__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.34 2003/10/05 19:44:58 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.35 2003/10/08 00:28:41 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -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));



Home | Main Index | Thread Index | Old Index