Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc sprinkle KERNEL_LOCK() and KERNEL_PROC_LOCK()...
details: https://anonhg.NetBSD.org/src/rev/b852e49888e7
branches: trunk
changeset: 507147:b852e49888e7
user: mrg <mrg%NetBSD.org@localhost>
date: Thu Mar 15 03:01:39 2001 +0000
description:
sprinkle KERNEL_LOCK() and KERNEL_PROC_LOCK() where they're missing. add
SYSCALL_DEBUG support to trap.c.
diffstat:
sys/arch/sparc/include/cpu.h | 5 ++++-
sys/arch/sparc/sparc/bsd_fdintr.s | 3 ++-
sys/arch/sparc/sparc/intr.c | 29 ++++++++++++++++++++++++++++-
sys/arch/sparc/sparc/memreg.c | 14 +++++++++++++-
sys/arch/sparc/sparc/trap.c | 37 ++++++++++++++++++++++++-------------
5 files changed, 71 insertions(+), 17 deletions(-)
diffs (truncated from 319 to 300 lines):
diff -r 514c96062684 -r b852e49888e7 sys/arch/sparc/include/cpu.h
--- a/sys/arch/sparc/include/cpu.h Thu Mar 15 02:23:47 2001 +0000
+++ b/sys/arch/sparc/include/cpu.h Thu Mar 15 03:01:39 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.42 2001/01/21 07:48:29 christos Exp $ */
+/* $NetBSD: cpu.h,v 1.43 2001/03/15 03:01:39 mrg Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -198,6 +198,9 @@
*/
void intr_fasttrap __P((int level, void (*vec)(void)));
+void intr_lock_kernel __P((void));
+void intr_unlock_kernel __P((void));
+
/* disksubr.c */
struct dkbad;
int isbad __P((struct dkbad *bt, int, int, int));
diff -r 514c96062684 -r b852e49888e7 sys/arch/sparc/sparc/bsd_fdintr.s
--- a/sys/arch/sparc/sparc/bsd_fdintr.s Thu Mar 15 02:23:47 2001 +0000
+++ b/sys/arch/sparc/sparc/bsd_fdintr.s Thu Mar 15 03:01:39 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bsd_fdintr.s,v 1.18 2000/01/21 13:22:01 pk Exp $ */
+/* $NetBSD: bsd_fdintr.s,v 1.19 2001/03/15 03:01:40 mrg Exp $ */
/*
* Copyright (c) 1995 Paul Kranenburg
@@ -161,6 +161,7 @@
.seg "text"
.align 4
+/* XXXSMP: kernel lock perimeter? */
_ENTRY(_C_LABEL(fdchwintr))
set save_l, %l7
std %l0, [%l7]
diff -r 514c96062684 -r b852e49888e7 sys/arch/sparc/sparc/intr.c
--- a/sys/arch/sparc/sparc/intr.c Thu Mar 15 02:23:47 2001 +0000
+++ b/sys/arch/sparc/sparc/intr.c Thu Mar 15 03:01:39 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: intr.c,v 1.48 2001/01/15 20:19:57 thorpej Exp $ */
+/* $NetBSD: intr.c,v 1.49 2001/03/15 03:01:40 mrg Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -77,6 +77,7 @@
/*
* Stray interrupt handler. Clear it if possible.
* If not, and if we get 10 interrupts in 10 seconds, panic.
+ * XXXSMP: We are holding the kernel lock at entry & exit.
*/
void
strayintr(fp)
@@ -112,6 +113,7 @@
void *fp;
{
+ KERNEL_LOCK(LK_CANRECURSE|LK_EXCLUSIVE);
if (sir.sir_any) {
/*
* XXX this is bogus: should just have a list of
@@ -151,6 +153,7 @@
}
#endif
}
+ KERNEL_UNLOCK();
return (1);
}
@@ -175,6 +178,7 @@
char bits[64];
u_int afsr, afva;
+ KERNEL_LOCK(LK_CANRECURSE|LK_EXCLUSIVE);
afsr = afva = 0;
if ((*cpuinfo.get_asyncflt)(&afsr, &afva) == 0) {
printf("Async registers (mid %d): afsr=%s; afva=0x%x%x\n",
@@ -188,6 +192,7 @@
* For now, just return.
* Should wait on damage analysis done by the master.
*/
+ KERNEL_UNLOCK();
return;
}
@@ -219,6 +224,7 @@
fatal |= (*moduleerr_handler)();
}
+ KERNEL_UNLOCK();
if (fatal)
panic("nmi");
}
@@ -228,6 +234,7 @@
{
#ifdef MULTIPROCESSOR
+ KERNEL_LOCK(LK_CANRECURSE|LK_EXCLUSIVE);
switch (cpuinfo.msg.tag) {
case XPMSG_SAVEFPU: {
savefpstate(cpuinfo.fpproc->p_md.md_fpstate);
@@ -288,6 +295,7 @@
break;
}
simple_unlock(&cpuinfo.msg.lock);
+ KERNEL_UNLOCK();
#endif
}
#endif
@@ -421,3 +429,22 @@
fastvec |= 1 << level;
splx(s);
}
+
+#ifdef MULTIPROCESSOR
+/*
+ * Called by interrupt stubs, etc., to lock/unlock the kernel.
+ */
+void
+intr_lock_kernel()
+{
+
+ KERNEL_LOCK(LK_CANRECURSE|LK_EXCLUSIVE);
+}
+
+void
+intr_unlock_kernel()
+{
+
+ KERNEL_UNLOCK();
+}
+#endif
diff -r 514c96062684 -r b852e49888e7 sys/arch/sparc/sparc/memreg.c
--- a/sys/arch/sparc/sparc/memreg.c Thu Mar 15 02:23:47 2001 +0000
+++ b/sys/arch/sparc/sparc/memreg.c Thu Mar 15 03:01:39 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: memreg.c,v 1.29 2001/03/03 19:11:02 pk Exp $ */
+/* $NetBSD: memreg.c,v 1.30 2001/03/15 03:01:40 mrg Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -261,6 +261,8 @@
if ((tf->tf_psr & PSR_PS) == 0)
KERNEL_PROC_LOCK(curproc);
+ else
+ KERNEL_LOCK(LK_CANRECURSE|LK_EXCLUSIVE);
(*cpuinfo.get_asyncflt)(&afsr, &afva);
if ((afsr & AFSR_AFO) != 0) { /* HS async fault! */
@@ -278,6 +280,8 @@
out:
if ((tf->tf_psr & PSR_PS) == 0)
KERNEL_PROC_UNLOCK(curproc);
+ else
+ KERNEL_UNLOCK();
return;
hard:
@@ -297,6 +301,8 @@
if ((tf->tf_psr & PSR_PS) == 0)
KERNEL_PROC_LOCK(curproc);
+ else
+ KERNEL_LOCK(LK_CANRECURSE|LK_EXCLUSIVE);
if (type == T_STOREBUFFAULT) {
@@ -333,6 +339,8 @@
out:
if ((tf->tf_psr & PSR_PS) == 0)
KERNEL_PROC_UNLOCK(curproc);
+ else
+ KERNEL_UNLOCK();
return;
hard:
@@ -352,6 +360,8 @@
if ((tf->tf_psr & PSR_PS) == 0)
KERNEL_PROC_LOCK(curproc);
+ else
+ KERNEL_LOCK(LK_CANRECURSE|LK_EXCLUSIVE);
/*
* No known special cases.
@@ -363,5 +373,7 @@
hardmemerr4m(type, sfsr, sfva, afsr, afva);
if ((tf->tf_psr & PSR_PS) == 0)
KERNEL_PROC_UNLOCK(curproc);
+ else
+ KERNEL_UNLOCK();
}
#endif /* SUN4M */
diff -r 514c96062684 -r b852e49888e7 sys/arch/sparc/sparc/trap.c
--- a/sys/arch/sparc/sparc/trap.c Thu Mar 15 02:23:47 2001 +0000
+++ b/sys/arch/sparc/sparc/trap.c Thu Mar 15 03:01:39 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.99 2001/03/05 07:16:19 pk Exp $ */
+/* $NetBSD: trap.c,v 1.100 2001/03/15 03:01:40 mrg Exp $ */
/*
* Copyright (c) 1996
@@ -273,7 +273,7 @@
/* This steps the PC over the trap. */
#define ADVANCE (n = tf->tf_npc, tf->tf_pc = n, tf->tf_npc = n + 4)
- uvmexp.traps++; /* XXXSMP */
+ uvmexp.traps++; /* XXXSMP */
/*
* Generally, kernel traps cause a panic. Any exceptions are
* handled early here.
@@ -952,9 +952,6 @@
pc = tf->tf_pc; /* These are needed below */
psr = tf->tf_psr;
- if ((psr & PSR_PS) == 0)
- KERNEL_PROC_LOCK(p);
-
/*
* Our first priority is handling serious faults, such as
* parity errors or async faults that might have come through here.
@@ -972,18 +969,19 @@
*/
if (type == T_STOREBUFFAULT ||
(type == T_DATAFAULT && (sfsr & SFSR_FAV) == 0)) {
- if ((psr & PSR_PS) == 0)
- KERNEL_PROC_UNLOCK(p);
(*cpuinfo.memerr)(type, sfsr, sfva, tf);
/*
* If we get here, exit the trap handler and wait for the
* trap to re-occur.
*/
- if ((psr & PSR_PS) == 0)
- KERNEL_PROC_LOCK(p);
- goto out;
+ goto out_nounlock;
}
+ if ((psr & PSR_PS) == 0)
+ KERNEL_PROC_LOCK(p);
+ else
+ KERNEL_LOCK(LK_CANRECURSE|LK_EXCLUSIVE);
+
/*
* Figure out what to pass the VM code. We cannot ignore the sfva
* register on text faults, since this might be a trap on an
@@ -1099,8 +1097,11 @@
if (cold)
goto kfault;
if (va >= KERNBASE) {
- if (uvm_fault(kernel_map, va, 0, atype) == KERN_SUCCESS)
+ if (uvm_fault(kernel_map, va, 0, atype) ==
+ KERN_SUCCESS) {
+ KERNEL_UNLOCK();
return;
+ }
goto kfault;
}
} else
@@ -1147,6 +1148,7 @@
}
tf->tf_pc = onfault;
tf->tf_npc = onfault + 4;
+ KERNEL_UNLOCK();
return;
}
if (rv == KERN_RESOURCE_SHORTAGE) {
@@ -1161,9 +1163,12 @@
out:
if ((psr & PSR_PS) == 0) {
KERNEL_PROC_UNLOCK(p);
+out_nounlock:
userret(p, pc, sticks);
share_fpu(p, tf);
}
+ else
+ KERNEL_UNLOCK();
}
#endif
@@ -1194,7 +1199,6 @@
uvmexp.syscalls++; /* XXXSMP */
p = curproc;
- KERNEL_PROC_LOCK(p);
#ifdef DIAGNOSTIC
if (tf->tf_psr & PSR_PS)
@@ -1275,6 +1279,10 @@
}
copywords(ap, args.i, i * sizeof(register_t));
}
+#ifdef SYSCALL_DEBUG
+ scdebug_call(p, code, args.i);
+#endif /* SYSCALL_DEBUG */
+ KERNEL_PROC_LOCK(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p, code, callp->sy_argsize, args.i);
Home |
Main Index |
Thread Index |
Old Index