summaryrefslogtreecommitdiff
path: root/sys/arch/amd64
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2011-07-07 18:11:25 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2011-07-07 18:11:25 +0000
commitf0dbc508cb2d1060a83c43da71f60ac4bab02188 (patch)
tree260e73ca64d22b10f4541858e6ee7fea0b7c1bff /sys/arch/amd64
parent291e013ccd4b9989e6d79d1ae219784a4a37894e (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/amd64')
-rw-r--r--sys/arch/amd64/amd64/fpu.c4
-rw-r--r--sys/arch/amd64/amd64/syscall.c14
-rw-r--r--sys/arch/amd64/amd64/trap.c20
3 files changed, 3 insertions, 35 deletions
diff --git a/sys/arch/amd64/amd64/fpu.c b/sys/arch/amd64/amd64/fpu.c
index 1c36e6e7443..ae53cbf65fb 100644
--- a/sys/arch/amd64/amd64/fpu.c
+++ b/sys/arch/amd64/amd64/fpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fpu.c,v 1.23 2011/07/06 21:41:37 art Exp $ */
+/* $OpenBSD: fpu.c,v 1.24 2011/07/07 18:11:23 art Exp $ */
/* $NetBSD: fpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */
/*-
@@ -166,9 +166,7 @@ fputrap(struct trapframe *frame)
sfp->fp_ex_sw = sfp->fp_fxsave.fx_fsw;
code = x86fpflags_to_siginfo (statbits);
sv.sival_ptr = (void *)frame->tf_rip; /* XXX - ? */
- KERNEL_LOCK();
trapsignal(p, SIGFPE, frame->tf_err, code, sv);
- KERNEL_UNLOCK();
}
static int
diff --git a/sys/arch/amd64/amd64/syscall.c b/sys/arch/amd64/amd64/syscall.c
index e43c2f61227..e8fa341ef92 100644
--- a/sys/arch/amd64/amd64/syscall.c
+++ b/sys/arch/amd64/amd64/syscall.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscall.c,v 1.17 2011/07/06 21:41:37 art Exp $ */
+/* $OpenBSD: syscall.c,v 1.18 2011/07/07 18:11:23 art Exp $ */
/* $NetBSD: syscall.c,v 1.1 2003/04/26 18:39:32 fvdl Exp $ */
/*-
@@ -127,24 +127,18 @@ syscall(struct trapframe *frame)
lock = !(callp->sy_flags & SY_NOLOCK);
#ifdef SYSCALL_DEBUG
- KERNEL_LOCK();
scdebug_call(p, code, argp);
- KERNEL_UNLOCK();
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL)) {
- KERNEL_LOCK();
ktrsyscall(p, code, callp->sy_argsize, argp);
- KERNEL_UNLOCK();
}
#endif
rval[0] = 0;
rval[1] = frame->tf_rdx;
#if NSYSTRACE > 0
if (ISSET(p->p_flag, P_SYSTRACE)) {
- KERNEL_LOCK();
error = systrace_redirect(code, p, argp, rval);
- KERNEL_UNLOCK();
} else
#endif
{
@@ -179,16 +173,12 @@ syscall(struct trapframe *frame)
}
#ifdef SYSCALL_DEBUG
- KERNEL_LOCK();
scdebug_ret(p, code, error, rval);
- KERNEL_UNLOCK();
#endif
userret(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET)) {
- KERNEL_LOCK();
ktrsysret(p, code, error, rval[0]);
- KERNEL_UNLOCK();
}
#endif
}
@@ -208,12 +198,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/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c
index 10d1cc5ce2b..ff2c2330724 100644
--- a/sys/arch/amd64/amd64/trap.c
+++ b/sys/arch/amd64/amd64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.23 2011/07/06 21:41:37 art Exp $ */
+/* $OpenBSD: trap.c,v 1.24 2011/07/07 18:11:23 art Exp $ */
/* $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $ */
/*-
@@ -250,22 +250,16 @@ copyfault:
frame_dump(frame);
#endif
sv.sival_ptr = (void *)frame->tf_rip;
- KERNEL_LOCK();
trapsignal(p, SIGBUS, type & ~T_USER, BUS_OBJERR, sv);
- KERNEL_UNLOCK();
goto out;
case T_ALIGNFLT|T_USER:
sv.sival_ptr = (void *)frame->tf_rip;
- KERNEL_LOCK();
trapsignal(p, SIGBUS, type & ~T_USER, BUS_ADRALN, sv);
- KERNEL_UNLOCK();
goto out;
case T_PRIVINFLT|T_USER: /* privileged instruction fault */
sv.sival_ptr = (void *)frame->tf_rip;
- KERNEL_LOCK();
trapsignal(p, SIGILL, type & ~T_USER, ILL_PRVOPC, sv);
- KERNEL_UNLOCK();
goto out;
case T_FPOPFLT|T_USER: /* coprocessor operand fault */
#ifdef TRAP_SIGDEBUG
@@ -274,17 +268,13 @@ copyfault:
frame_dump(frame);
#endif
sv.sival_ptr = (void *)frame->tf_rip;
- 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();
}
/* Allow a forced task switch. */
if (curcpu()->ci_want_resched)
@@ -293,21 +283,15 @@ copyfault:
case T_BOUND|T_USER:
sv.sival_ptr = (void *)frame->tf_rip;
- KERNEL_LOCK();
trapsignal(p, SIGFPE, type &~ T_USER, FPE_FLTSUB, sv);
- KERNEL_UNLOCK();
goto out;
case T_OFLOW|T_USER:
sv.sival_ptr = (void *)frame->tf_rip;
- KERNEL_LOCK();
trapsignal(p, SIGFPE, type &~ T_USER, FPE_INTOVF, sv);
- KERNEL_UNLOCK();
goto out;
case T_DIVIDE|T_USER:
sv.sival_ptr = (void *)frame->tf_rip;
- KERNEL_LOCK();
trapsignal(p, SIGFPE, type &~ T_USER, FPE_INTDIV, sv);
- KERNEL_UNLOCK();
goto out;
case T_ARITHTRAP|T_USER:
@@ -421,9 +405,7 @@ faultcommon:
#ifdef MATH_EMULATE
trace:
#endif
- KERNEL_LOCK();
trapsignal(p, SIGTRAP, type &~ T_USER, TRAP_BRKPT, sv);
- KERNEL_UNLOCK();
break;
#if NISA > 0