Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc/sparc Sprinkle KERNEL_PROC_LOCK()s at the ker...



details:   https://anonhg.NetBSD.org/src/rev/beb6ced86f93
branches:  trunk
changeset: 504468:beb6ced86f93
user:      pk <pk%NetBSD.org@localhost>
date:      Sat Mar 03 19:11:02 2001 +0000

description:
Sprinkle KERNEL_PROC_LOCK()s at the kernel entry points.

diffstat:

 sys/arch/sparc/sparc/memreg.c |   33 +++++++++-
 sys/arch/sparc/sparc/trap.c   |  127 +++++++++++++++++++++++++++++++----------
 2 files changed, 122 insertions(+), 38 deletions(-)

diffs (truncated from 509 to 300 lines):

diff -r 3f132ddcfe5d -r beb6ced86f93 sys/arch/sparc/sparc/memreg.c
--- a/sys/arch/sparc/sparc/memreg.c     Sat Mar 03 18:08:31 2001 +0000
+++ b/sys/arch/sparc/sparc/memreg.c     Sat Mar 03 19:11:02 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: memreg.c,v 1.28 1998/09/21 10:32:00 pk Exp $ */
+/*     $NetBSD: memreg.c,v 1.29 2001/03/03 19:11:02 pk Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -48,6 +48,7 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/proc.h>
 #include <sys/device.h>
 
 #include <machine/autoconf.h>
@@ -242,9 +243,11 @@
  * once, and then fail if we get called again.
  */
 
+/* XXXSMP */
 static int addrold = (int) 0xdeadbeef; /* We pick an unlikely address */
 static int addroldtop = (int) 0xdeadbeef;
 static int oldtype = -1;
+/* XXXSMP */
 
 void
 hypersparc_memerr(type, sfsr, sfva, tf)
@@ -256,6 +259,9 @@
        u_int afsr;
        u_int afva;
 
+       if ((tf->tf_psr & PSR_PS) == 0)
+               KERNEL_PROC_LOCK(curproc);
+
        (*cpuinfo.get_asyncflt)(&afsr, &afva);
        if ((afsr & AFSR_AFO) != 0) {   /* HS async fault! */
 
@@ -268,10 +274,15 @@
                oldtype = -1;
                addrold = afva;
                addroldtop = afsr & AFSR_AFA;
-               return;
        }
+out:
+       if ((tf->tf_psr & PSR_PS) == 0)
+               KERNEL_PROC_UNLOCK(curproc);
+       return;
+
 hard:
        hardmemerr4m(type, sfsr, sfva, afsr, afva);
+       goto out;
 }
 
 void
@@ -284,6 +295,9 @@
        u_int afsr=0;   /* No Async fault registers on the viking */
        u_int afva=0;
 
+       if ((tf->tf_psr & PSR_PS) == 0)
+               KERNEL_PROC_LOCK(curproc);
+
        if (type == T_STOREBUFFAULT) {
 
                /*
@@ -303,8 +317,6 @@
                sta(SRMMU_PCR, ASI_SRMMU,
                    lda(SRMMU_PCR, ASI_SRMMU) | VIKING_PCR_SB);
 
-               return;
-
        } else if (type == T_DATAFAULT && (sfsr & SFSR_FAV) == 0) {
                /*
                 * bizarre.
@@ -316,10 +328,16 @@
                if (oldtype == T_DATAFAULT)
                        goto hard;
                oldtype = T_DATAFAULT;
-               return;
        }
+
+out:
+       if ((tf->tf_psr & PSR_PS) == 0)
+               KERNEL_PROC_UNLOCK(curproc);
+       return;
+
 hard:
        hardmemerr4m(type, sfsr, sfva, afsr, afva);
+       goto out;
 }
 
 void
@@ -332,6 +350,9 @@
        u_int afsr;
        u_int afva;
 
+       if ((tf->tf_psr & PSR_PS) == 0)
+               KERNEL_PROC_LOCK(curproc);
+
        /*
         * No known special cases.
         * Just get async registers, if any, and report the unhandled case.
@@ -340,5 +361,7 @@
                afsr = afva = 0;
 
        hardmemerr4m(type, sfsr, sfva, afsr, afva);
+       if ((tf->tf_psr & PSR_PS) == 0)
+               KERNEL_PROC_UNLOCK(curproc);
 }
 #endif /* SUN4M */
diff -r 3f132ddcfe5d -r beb6ced86f93 sys/arch/sparc/sparc/trap.c
--- a/sys/arch/sparc/sparc/trap.c       Sat Mar 03 18:08:31 2001 +0000
+++ b/sys/arch/sparc/sparc/trap.c       Sat Mar 03 19:11:02 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.97 2000/12/01 19:50:17 jdolecek Exp $ */
+/*     $NetBSD: trap.c,v 1.98 2001/03/03 19:11:02 pk Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -267,11 +267,13 @@
        int n;
        char bits[64];
        u_quad_t sticks;
+       int sig;
+       u_long ucode;
 
        /* This steps the PC over the trap. */
 #define        ADVANCE (n = tf->tf_npc, tf->tf_pc = n, tf->tf_npc = n + 4)
 
-       uvmexp.traps++;
+       uvmexp.traps++;         /* XXXSMP */
        /*
         * Generally, kernel traps cause a panic.  Any exceptions are
         * handled early here.
@@ -333,6 +335,9 @@
        }
 #endif
 
+       sig = 0;
+       ucode = 0;
+
        switch (type) {
 
        default:
@@ -342,7 +347,8 @@
                        printf("trap type 0x%x: pc=0x%x npc=0x%x psr=%s\n",
                               type, pc, tf->tf_npc, bitmask_snprintf(psr,
                               PSR_BITS, bits, sizeof(bits)));
-                       trapsignal(p, SIGILL, type);
+                       sig = SIGILL;
+                       ucode = type;
                        break;
                }
 #if defined(COMPAT_SVR4)
@@ -354,7 +360,8 @@
                uprintf("%s[%d]: unimplemented software trap 0x%x\n",
                        p->p_comm, p->p_pid, type);
 #endif
-               trapsignal(p, SIGILL, type);
+               sig = SIGILL;
+               ucode = type;
                break;
 
 #ifdef COMPAT_SVR4
@@ -375,15 +382,16 @@
 
        case T_ILLINST:
        case T_UNIMPLFLUSH:
-               if ((n = emulinstr(pc, tf)) == 0) {
+               if ((sig = emulinstr(pc, tf)) == 0) {
                        ADVANCE;
                        break;
                }
-               trapsignal(p, n, 0);    /* XXX code?? */
+               /* XXX - ucode? */
                break;
 
        case T_PRIVINST:
-               trapsignal(p, SIGILL, 0);       /* XXX code?? */
+               sig = SIGILL;
+               /* XXX - ucode? */
                break;
 
        case T_FPDISABLED: {
@@ -398,6 +406,7 @@
                }
 #endif
 
+               KERNEL_PROC_LOCK(p);
                if (fs == NULL) {
                        fs = malloc(sizeof *fs, M_SUBPROC, M_WAITOK);
                        *fs = initfpstate;
@@ -410,11 +419,12 @@
                if (!cpuinfo.fpupresent) {
 #ifdef notyet
                        fpu_emulate(p, tf, fs);
+#else
+                       sig = SIGFPE;
+                       /* XXX - ucode? */
+#endif
+                       KERNEL_PROC_UNLOCK(p);
                        break;
-#else
-                       trapsignal(p, SIGFPE, 0);       /* XXX code?? */
-                       break;
-#endif
                }
                /*
                 * We may have more FPEs stored up and/or ops queued.
@@ -423,9 +433,10 @@
                 */
                if (fs->fs_qsize) {
                        fpu_cleanup(p, fs);
+                       KERNEL_PROC_UNLOCK(p);
                        break;
                }
-#if NEW
+#if notyet
                simple_lock(&cpuinfo.fplock);
                if (cpuinfo.fpproc != p) {              /* we do not have it */
                        if (cpuinfo.fpproc != NULL) {   /* someone else had it*/
@@ -477,6 +488,7 @@
                        p->p_md.md_fpumid = cpuinfo.mid;
                }
 #endif
+               KERNEL_PROC_UNLOCK(p);
                tf->tf_psr |= PSR_EF;
                break;
        }
@@ -498,6 +510,7 @@
                 * nsaved to -1.  If we decide to deliver a signal on
                 * our way out, we will clear nsaved.
                 */
+               KERNEL_PROC_LOCK(p);
                if (pcb->pcb_uw || pcb->pcb_nsaved)
                        panic("trap T_RWRET 1");
 #ifdef DEBUG
@@ -510,6 +523,7 @@
                if (pcb->pcb_nsaved)
                        panic("trap T_RWRET 2");
                pcb->pcb_nsaved = -1;           /* mark success */
+               KERNEL_PROC_UNLOCK(p);
                break;
 
        case T_WINUF:
@@ -522,6 +536,7 @@
                 * in the pcb.  The restore's window may still be in
                 * the cpu; we need to force it out to the stack.
                 */
+               KERNEL_PROC_LOCK(p);
 #ifdef DEBUG
                if (rwindow_debug)
                        printf("%s[%d]: rwindow: T_WINUF 0: pcb<-stack: 0x%x\n",
@@ -540,15 +555,21 @@
                if (pcb->pcb_nsaved)
                        panic("trap T_WINUF");
                pcb->pcb_nsaved = -1;           /* mark success */
+               KERNEL_PROC_UNLOCK(p);
                break;
 
        case T_ALIGN:
-               if ((p->p_md.md_flags & MDP_FIXALIGN) != 0 && 
-                   fixalign(p, tf) == 0) {
-                       ADVANCE;
-                       break;
+               if ((p->p_md.md_flags & MDP_FIXALIGN) != 0) {
+                       KERNEL_PROC_LOCK(p);
+                       n = fixalign(p, tf);
+                       KERNEL_PROC_UNLOCK(p);
+                       if (n == 0) {
+                               ADVANCE;
+                               break;
+                       }
                }
-               trapsignal(p, SIGBUS, 0);       /* XXX code?? */
+               sig = SIGBUS;
+               /* XXX - ucode? */
                break;
 
        case T_FPE:
@@ -560,12 +581,14 @@
                 * will not match once fpu_cleanup does its job, so
                 * we must not save again later.)
                 */
+               KERNEL_PROC_LOCK(p);
                if (p != cpuinfo.fpproc)
                        panic("fpe without being the FP user");
                savefpstate(p->p_md.md_fpstate);
                cpuinfo.fpproc = NULL;
                /* tf->tf_psr &= ~PSR_EF; */    /* share_fpu will do this */
                fpu_cleanup(p, p->p_md.md_fpstate);
+               KERNEL_PROC_UNLOCK(p);
                /* fpu_cleanup posts signals if needed */
 #if 0          /* ??? really never??? */
                ADVANCE;
@@ -573,29 +596,34 @@
                break;
 
        case T_TAGOF:



Home | Main Index | Thread Index | Old Index