sprinkle KERNEL_LOCK() and KERNEL_PROC_LOCK() where they're missing. add
SYSCALL_DEBUG support to trap.c.
This commit is contained in:
parent
efc93d040b
commit
122b3a0e67
@ -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_establish __P((int level, struct intrhand *));
|
||||
*/
|
||||
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));
|
||||
|
@ -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 @@ _C_LABEL(fdciop):
|
||||
.seg "text"
|
||||
.align 4
|
||||
|
||||
/* XXXSMP: kernel lock perimeter? */
|
||||
_ENTRY(_C_LABEL(fdchwintr))
|
||||
set save_l, %l7
|
||||
std %l0, [%l7]
|
||||
|
@ -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 @@ int soft01intr __P((void *));
|
||||
/*
|
||||
* 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 @@ soft01intr(fp)
|
||||
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 @@ soft01intr(fp)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
KERNEL_UNLOCK();
|
||||
return (1);
|
||||
}
|
||||
|
||||
@ -175,6 +178,7 @@ nmi_hard()
|
||||
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 @@ nmi_hard()
|
||||
* For now, just return.
|
||||
* Should wait on damage analysis done by the master.
|
||||
*/
|
||||
KERNEL_UNLOCK();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -219,6 +224,7 @@ nmi_hard()
|
||||
fatal |= (*moduleerr_handler)();
|
||||
}
|
||||
|
||||
KERNEL_UNLOCK();
|
||||
if (fatal)
|
||||
panic("nmi");
|
||||
}
|
||||
@ -228,6 +234,7 @@ nmi_soft()
|
||||
{
|
||||
|
||||
#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 @@ nmi_soft()
|
||||
break;
|
||||
}
|
||||
simple_unlock(&cpuinfo.msg.lock);
|
||||
KERNEL_UNLOCK();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@ -421,3 +429,22 @@ intr_fasttrap(level, vec)
|
||||
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
|
||||
|
@ -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 @@ hypersparc_memerr(type, sfsr, sfva, tf)
|
||||
|
||||
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 @@ hypersparc_memerr(type, sfsr, sfva, tf)
|
||||
out:
|
||||
if ((tf->tf_psr & PSR_PS) == 0)
|
||||
KERNEL_PROC_UNLOCK(curproc);
|
||||
else
|
||||
KERNEL_UNLOCK();
|
||||
return;
|
||||
|
||||
hard:
|
||||
@ -297,6 +301,8 @@ viking_memerr(type, sfsr, sfva, tf)
|
||||
|
||||
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 @@ viking_memerr(type, sfsr, sfva, tf)
|
||||
out:
|
||||
if ((tf->tf_psr & PSR_PS) == 0)
|
||||
KERNEL_PROC_UNLOCK(curproc);
|
||||
else
|
||||
KERNEL_UNLOCK();
|
||||
return;
|
||||
|
||||
hard:
|
||||
@ -352,6 +360,8 @@ memerr4m(type, sfsr, sfva, tf)
|
||||
|
||||
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 @@ memerr4m(type, sfsr, sfva, tf)
|
||||
hardmemerr4m(type, sfsr, sfva, afsr, afva);
|
||||
if ((tf->tf_psr & PSR_PS) == 0)
|
||||
KERNEL_PROC_UNLOCK(curproc);
|
||||
else
|
||||
KERNEL_UNLOCK();
|
||||
}
|
||||
#endif /* SUN4M */
|
||||
|
@ -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 @@ trap(type, psr, pc, tf)
|
||||
/* 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 @@ mem_access_fault4m(type, sfsr, sfva, tf)
|
||||
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 @@ mem_access_fault4m(type, sfsr, sfva, tf)
|
||||
*/
|
||||
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 @@ mem_access_fault4m(type, sfsr, sfva, tf)
|
||||
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 @@ kfault:
|
||||
}
|
||||
tf->tf_pc = onfault;
|
||||
tf->tf_npc = onfault + 4;
|
||||
KERNEL_UNLOCK();
|
||||
return;
|
||||
}
|
||||
if (rv == KERN_RESOURCE_SHORTAGE) {
|
||||
@ -1161,9 +1163,12 @@ kfault:
|
||||
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 @@ syscall(code, tf, pc)
|
||||
uvmexp.syscalls++; /* XXXSMP */
|
||||
p = curproc;
|
||||
|
||||
KERNEL_PROC_LOCK(p);
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (tf->tf_psr & PSR_PS)
|
||||
@ -1275,6 +1279,10 @@ syscall(code, tf, pc)
|
||||
}
|
||||
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);
|
||||
@ -1282,6 +1290,7 @@ syscall(code, tf, pc)
|
||||
rval[0] = 0;
|
||||
rval[1] = tf->tf_out[1];
|
||||
error = (*callp->sy_call)(p, &args, rval);
|
||||
KERNEL_PROC_UNLOCK(p);
|
||||
|
||||
switch (error) {
|
||||
case 0:
|
||||
@ -1321,7 +1330,9 @@ syscall(code, tf, pc)
|
||||
break;
|
||||
}
|
||||
|
||||
KERNEL_PROC_UNLOCK(p);
|
||||
#ifdef SYSCALL_DEBUG
|
||||
scdebug_ret(p, code, error, rval);
|
||||
#endif /* SYSCALL_DEBUG */
|
||||
userret(p, pc, sticks);
|
||||
#ifdef KTRACE
|
||||
if (KTRPOINT(p, KTR_SYSRET)) {
|
||||
|
Loading…
Reference in New Issue
Block a user