diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2011-07-07 18:11:25 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2011-07-07 18:11:25 +0000 |
commit | f0dbc508cb2d1060a83c43da71f60ac4bab02188 (patch) | |
tree | 260e73ca64d22b10f4541858e6ee7fea0b7c1bff /sys/arch/i386 | |
parent | 291e013ccd4b9989e6d79d1ae219784a4a37894e (diff) |
There is a bunch of places in the kernel entry points where we don't
hold the kernel lock, but still need call one function that needs it.
Instead of grabbing the lock all over the place, move the locks into
the affected functions: trapsignal, scdebug*, ktrsyscall, ktrsysret,
systrace_redirect and ADDUPROF. In the cases we already hold the biglock
we'll just recurse.
kettenis@, beck@ ok
Diffstat (limited to 'sys/arch/i386')
-rw-r--r-- | sys/arch/i386/i386/trap.c | 42 | ||||
-rw-r--r-- | sys/arch/i386/isa/npx.c | 4 |
2 files changed, 3 insertions, 43 deletions
diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c index a141cc608e1..8c48ed8283c 100644 --- a/sys/arch/i386/i386/trap.c +++ b/sys/arch/i386/i386/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.98 2011/07/06 21:41:37 art Exp $ */ +/* $OpenBSD: trap.c,v 1.99 2011/07/07 18:11:23 art Exp $ */ /* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */ /*- @@ -322,46 +322,34 @@ trap(struct trapframe *frame) case T_TSSFLT|T_USER: sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGBUS, vftype, BUS_OBJERR, sv); - KERNEL_UNLOCK(); goto out; case T_SEGNPFLT|T_USER: case T_STKFLT|T_USER: sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGSEGV, vftype, SEGV_MAPERR, sv); - KERNEL_UNLOCK(); goto out; case T_ALIGNFLT|T_USER: sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGBUS, vftype, BUS_ADRALN, sv); - KERNEL_UNLOCK(); goto out; case T_PRIVINFLT|T_USER: /* privileged instruction fault */ sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGILL, type &~ T_USER, ILL_PRVOPC, sv); - KERNEL_UNLOCK(); goto out; case T_FPOPFLT|T_USER: /* coprocessor operand fault */ sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGILL, type &~ T_USER, ILL_COPROC, sv); - KERNEL_UNLOCK(); goto out; case T_ASTFLT|T_USER: /* Allow process switch */ uvmexp.softs++; if (p->p_flag & P_OWEUPC) { - KERNEL_LOCK(); ADDUPROF(p); - KERNEL_UNLOCK(); } if (want_resched) preempt(NULL); @@ -371,36 +359,26 @@ trap(struct trapframe *frame) printf("pid %d killed due to lack of floating point\n", p->p_pid); sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGKILL, type &~ T_USER, FPE_FLTINV, sv); - KERNEL_UNLOCK(); goto out; } case T_BOUND|T_USER: sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGFPE, type &~ T_USER, FPE_FLTSUB, sv); - KERNEL_UNLOCK(); goto out; case T_OFLOW|T_USER: sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGFPE, type &~ T_USER, FPE_INTOVF, sv); - KERNEL_UNLOCK(); goto out; case T_DIVIDE|T_USER: sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGFPE, type &~ T_USER, FPE_INTDIV, sv); - KERNEL_UNLOCK(); goto out; case T_ARITHTRAP|T_USER: sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGFPE, frame->tf_err, FPE_INTOVF, sv); - KERNEL_UNLOCK(); goto out; case T_XFTRAP|T_USER: @@ -506,15 +484,11 @@ trap(struct trapframe *frame) case T_BPTFLT|T_USER: /* bpt instruction fault */ sv.sival_int = rcr2(); - KERNEL_LOCK(); trapsignal(p, SIGTRAP, type &~ T_USER, TRAP_BRKPT, sv); - KERNEL_UNLOCK(); break; case T_TRCTRAP|T_USER: /* trace trap */ sv.sival_int = rcr2(); - KERNEL_LOCK(); trapsignal(p, SIGTRAP, type &~ T_USER, TRAP_TRACE, sv); - KERNEL_UNLOCK(); break; #if NISA > 0 @@ -667,16 +641,12 @@ syscall(struct trapframe *frame) lock = !(callp->sy_flags & SY_NOLOCK); #ifdef SYSCALL_DEBUG - KERNEL_LOCK(); scdebug_call(p, code, args); - KERNEL_UNLOCK(); #endif #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) { - KERNEL_LOCK(); ktrsyscall(p, code, argsize, args); - KERNEL_UNLOCK(); } #endif @@ -688,15 +658,13 @@ syscall(struct trapframe *frame) #if NSYSTRACE > 0 if (ISSET(p->p_flag, P_SYSTRACE)) { - KERNEL_LOCK(); orig_error = error = systrace_redirect(code, p, args, rval); - KERNEL_UNLOCK(); } else #endif { if (lock) KERNEL_LOCK(); - orig_error = error = (*callp->sy_call)(p, args, rval); + orig_error = error = (*callp->sy_call)(p, args, rval); if (lock) KERNEL_UNLOCK(); } @@ -728,16 +696,12 @@ syscall(struct trapframe *frame) } #ifdef SYSCALL_DEBUG - KERNEL_LOCK(); scdebug_ret(p, code, orig_error, rval); - KERNEL_UNLOCK(); #endif userret(p); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - KERNEL_LOCK(); ktrsysret(p, code, orig_error, rval[0]); - KERNEL_UNLOCK(); } #endif #ifdef DIAGNOSTIC @@ -764,12 +728,10 @@ child_return(void *arg) userret(p); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - KERNEL_LOCK(); ktrsysret(p, (p->p_flag & P_THREAD) ? SYS_rfork : (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); - KERNEL_UNLOCK(); } #endif } diff --git a/sys/arch/i386/isa/npx.c b/sys/arch/i386/isa/npx.c index e13e64f646b..a35f451c5f1 100644 --- a/sys/arch/i386/isa/npx.c +++ b/sys/arch/i386/isa/npx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: npx.c,v 1.55 2011/07/06 21:41:37 art Exp $ */ +/* $OpenBSD: npx.c,v 1.56 2011/07/07 18:11:24 art Exp $ */ /* $NetBSD: npx.c,v 1.57 1996/05/12 23:12:24 mycroft Exp $ */ #if 0 @@ -578,9 +578,7 @@ npxtrap(struct trapframe *frame) addr->sv_xmm.sv_ex_tw = addr->sv_xmm.sv_env.en_tw; code = x86fpflags_to_siginfo (statbits); sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGFPE, frame->tf_err, code, sv); - KERNEL_UNLOCK(); } static int |