diff options
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/amd64/fpu.c | 4 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/syscall.c | 14 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/trap.c | 20 | ||||
-rw-r--r-- | sys/arch/hppa/hppa/trap.c | 46 | ||||
-rw-r--r-- | sys/arch/i386/i386/trap.c | 42 | ||||
-rw-r--r-- | sys/arch/i386/isa/npx.c | 4 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/m88110_fp.c | 4 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/trap.c | 30 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/fp_emulate.c | 4 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/trap.c | 18 | ||||
-rw-r--r-- | sys/arch/powerpc/powerpc/trap.c | 30 | ||||
-rw-r--r-- | sys/arch/sparc64/fpu/fpu.c | 10 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/emul.c | 10 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/trap.c | 48 |
14 files changed, 269 insertions, 15 deletions
diff --git a/sys/arch/amd64/amd64/fpu.c b/sys/arch/amd64/amd64/fpu.c index cb182aa1a22..779a713a398 100644 --- a/sys/arch/amd64/amd64/fpu.c +++ b/sys/arch/amd64/amd64/fpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpu.c,v 1.25 2011/07/10 18:09:27 deraadt Exp $ */ +/* $OpenBSD: fpu.c,v 1.26 2011/07/11 15:40:47 guenther Exp $ */ /* $NetBSD: fpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */ /*- @@ -160,7 +160,9 @@ 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 e8fa341ef92..c30b6dc1b4d 100644 --- a/sys/arch/amd64/amd64/syscall.c +++ b/sys/arch/amd64/amd64/syscall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syscall.c,v 1.18 2011/07/07 18:11:23 art Exp $ */ +/* $OpenBSD: syscall.c,v 1.19 2011/07/11 15:40:47 guenther Exp $ */ /* $NetBSD: syscall.c,v 1.1 2003/04/26 18:39:32 fvdl Exp $ */ /*- @@ -127,18 +127,24 @@ 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 { @@ -173,12 +179,16 @@ 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 } @@ -198,10 +208,12 @@ 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 ff2c2330724..e40c937b17c 100644 --- a/sys/arch/amd64/amd64/trap.c +++ b/sys/arch/amd64/amd64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.24 2011/07/07 18:11:23 art Exp $ */ +/* $OpenBSD: trap.c,v 1.25 2011/07/11 15:40:47 guenther Exp $ */ /* $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $ */ /*- @@ -250,16 +250,22 @@ 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 @@ -268,13 +274,17 @@ 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) @@ -283,15 +293,21 @@ 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: @@ -405,7 +421,9 @@ faultcommon: #ifdef MATH_EMULATE trace: #endif + KERNEL_LOCK(); trapsignal(p, SIGTRAP, type &~ T_USER, TRAP_BRKPT, sv); + KERNEL_UNLOCK(); break; #if NISA > 0 diff --git a/sys/arch/hppa/hppa/trap.c b/sys/arch/hppa/hppa/trap.c index 8a807ab25b8..f9c2271f206 100644 --- a/sys/arch/hppa/hppa/trap.c +++ b/sys/arch/hppa/hppa/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.117 2011/07/07 18:11:23 art Exp $ */ +/* $OpenBSD: trap.c,v 1.118 2011/07/11 15:40:47 guenther Exp $ */ /* * Copyright (c) 1998-2004 Michael Shalayeff @@ -146,7 +146,9 @@ userret(struct proc *p) p->p_md.md_astpending = 0; uvmexp.softs++; if (p->p_flag & P_OWEUPC) { + KERNEL_LOCK(); ADDUPROF(p); + KERNEL_UNLOCK(); } if (curcpu()->ci_want_resched) preempt(NULL); @@ -280,7 +282,9 @@ trap(int type, struct trapframe *frame) code = TRAP_TRACE; #endif /* pass to user debugger */ + KERNEL_LOCK(); trapsignal(p, SIGTRAP, type &~ T_USER, code, sv); + KERNEL_UNLOCK(); } break; @@ -289,7 +293,9 @@ trap(int type, struct trapframe *frame) ss_clear_breakpoints(p); /* pass to user debugger */ + KERNEL_LOCK(); trapsignal(p, SIGTRAP, type &~ T_USER, TRAP_TRACE, sv); + KERNEL_UNLOCK(); break; #endif @@ -329,7 +335,9 @@ trap(int type, struct trapframe *frame) fpp[0] &= ~(((u_int64_t)HPPA_FPU_T) << 32); sv.sival_int = va; + KERNEL_LOCK(); trapsignal(p, SIGFPE, type &~ T_USER, flt, sv); + KERNEL_UNLOCK(); } break; @@ -339,34 +347,46 @@ trap(int type, struct trapframe *frame) case T_EMULATION | T_USER: sv.sival_int = va; + KERNEL_LOCK(); trapsignal(p, SIGILL, type &~ T_USER, ILL_COPROC, sv); + KERNEL_UNLOCK(); break; case T_OVERFLOW | T_USER: sv.sival_int = va; + KERNEL_LOCK(); trapsignal(p, SIGFPE, type &~ T_USER, FPE_INTOVF, sv); + KERNEL_UNLOCK(); break; case T_CONDITION | T_USER: sv.sival_int = va; + KERNEL_LOCK(); trapsignal(p, SIGFPE, type &~ T_USER, FPE_INTDIV, sv); + KERNEL_UNLOCK(); break; case T_PRIV_OP | T_USER: sv.sival_int = va; + KERNEL_LOCK(); trapsignal(p, SIGILL, type &~ T_USER, ILL_PRVOPC, sv); + KERNEL_UNLOCK(); break; case T_PRIV_REG | T_USER: sv.sival_int = va; + KERNEL_LOCK(); trapsignal(p, SIGILL, type &~ T_USER, ILL_PRVREG, sv); + KERNEL_UNLOCK(); break; /* these should never got here */ case T_HIGHERPL | T_USER: case T_LOWERPL | T_USER: sv.sival_int = va; + KERNEL_LOCK(); trapsignal(p, SIGSEGV, vftype, SEGV_ACCERR, sv); + KERNEL_UNLOCK(); break; /* @@ -385,7 +405,9 @@ trap(int type, struct trapframe *frame) case T_IPROT | T_USER: sv.sival_int = va; + KERNEL_LOCK(); trapsignal(p, SIGSEGV, vftype, SEGV_ACCERR, sv); + KERNEL_UNLOCK(); break; case T_ITLBMISSNA: @@ -427,7 +449,9 @@ trap(int type, struct trapframe *frame) KERNEL_UNLOCK(); } else if (type & T_USER) { sv.sival_int = va; + KERNEL_LOCK(); trapsignal(p, SIGILL, type & ~T_USER, ILL_ILLTRP, sv); + KERNEL_UNLOCK(); } else panic("trap: %s @ 0x%x:0x%x for 0x%x:0x%x irr 0x%08x", tts, frame->tf_iisq_head, frame->tf_iioq_head, @@ -465,7 +489,9 @@ datacc: if ((type & T_USER && va >= VM_MAXUSER_ADDRESS) || (type & T_USER && map->pmap->pm_space != space)) { sv.sival_int = va; + KERNEL_LOCK(); trapsignal(p, SIGSEGV, vftype, SEGV_MAPERR, sv); + KERNEL_UNLOCK(); break; } @@ -493,9 +519,11 @@ datacc: if (ret != 0) { if (type & T_USER) { sv.sival_int = va; + KERNEL_LOCK(); trapsignal(p, SIGSEGV, vftype, ret == EACCES? SEGV_ACCERR : SEGV_MAPERR, sv); + KERNEL_UNLOCK(); } else { if (p && p->p_addr->u_pcb.pcb_onfault) { frame->tf_iioq_tail = 4 + @@ -516,7 +544,9 @@ datacc: case T_DATALIGN | T_USER: datalign_user: sv.sival_int = va; + KERNEL_LOCK(); trapsignal(p, SIGBUS, vftype, BUS_ADRALN, sv); + KERNEL_UNLOCK(); break; case T_INTERRUPT: @@ -538,7 +568,9 @@ datalign_user: } if (type & T_USER) { sv.sival_int = va; + KERNEL_LOCK(); trapsignal(p, SIGILL, type &~ T_USER, ILL_ILLOPC, sv); + KERNEL_UNLOCK(); break; } /* FALLTHROUGH */ @@ -614,10 +646,12 @@ 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 } @@ -835,11 +869,15 @@ syscall(struct trapframe *frame) } #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, callp->sy_argsize, args); + KERNEL_UNLOCK(); } #endif if (error) @@ -849,7 +887,9 @@ syscall(struct trapframe *frame) rval[1] = frame->tf_ret1; #if NSYSTRACE > 0 if (ISSET(p->p_flag, P_SYSTRACE)) { + KERNEL_LOCK(); oerror = error = systrace_redirect(code, p, args, rval); + KERNEL_UNLOCK(); } else #endif { @@ -882,12 +922,16 @@ syscall(struct trapframe *frame) break; } #ifdef SYSCALL_DEBUG + KERNEL_LOCK(); scdebug_ret(p, code, oerror, rval); + KERNEL_UNLOCK(); #endif userret(p); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { + KERNEL_LOCK(); ktrsysret(p, code, oerror, rval[0]); + KERNEL_UNLOCK(); } #endif #ifdef DIAGNOSTIC diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c index 8c48ed8283c..3dab71dcfb0 100644 --- a/sys/arch/i386/i386/trap.c +++ b/sys/arch/i386/i386/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.99 2011/07/07 18:11:23 art Exp $ */ +/* $OpenBSD: trap.c,v 1.100 2011/07/11 15:40:47 guenther Exp $ */ /* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */ /*- @@ -322,34 +322,46 @@ 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); @@ -359,26 +371,36 @@ 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: @@ -484,11 +506,15 @@ 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 @@ -641,12 +667,16 @@ 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 @@ -658,13 +688,15 @@ 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(); } @@ -696,12 +728,16 @@ 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 @@ -728,10 +764,12 @@ 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 a35f451c5f1..f787be75315 100644 --- a/sys/arch/i386/isa/npx.c +++ b/sys/arch/i386/isa/npx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: npx.c,v 1.56 2011/07/07 18:11:24 art Exp $ */ +/* $OpenBSD: npx.c,v 1.57 2011/07/11 15:40:47 guenther Exp $ */ /* $NetBSD: npx.c,v 1.57 1996/05/12 23:12:24 mycroft Exp $ */ #if 0 @@ -578,7 +578,9 @@ 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 diff --git a/sys/arch/m88k/m88k/m88110_fp.c b/sys/arch/m88k/m88k/m88110_fp.c index b3f06309ec0..7ffb044d913 100644 --- a/sys/arch/m88k/m88k/m88110_fp.c +++ b/sys/arch/m88k/m88k/m88110_fp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m88110_fp.c,v 1.5 2011/07/07 18:11:24 art Exp $ */ +/* $OpenBSD: m88110_fp.c,v 1.6 2011/07/11 15:40:47 guenther Exp $ */ /* * Copyright (c) 2007, Miodrag Vallat. @@ -215,7 +215,9 @@ m88110_fpu_exception(struct trapframe *frame) deliver: sv.sival_ptr = (void *)fault_addr; + KERNEL_LOCK(); trapsignal(p, sig, 0, fault_type, sv); + KERNEL_UNLOCK(); } } diff --git a/sys/arch/m88k/m88k/trap.c b/sys/arch/m88k/m88k/trap.c index 032579fc8b4..542065c3533 100644 --- a/sys/arch/m88k/m88k/trap.c +++ b/sys/arch/m88k/m88k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.77 2011/07/07 18:11:24 art Exp $ */ +/* $OpenBSD: trap.c,v 1.78 2011/07/11 15:40:47 guenther Exp $ */ /* * Copyright (c) 2004, Miodrag Vallat. * Copyright (c) 1998 Steve Murphree, Jr. @@ -223,7 +223,9 @@ ast(struct trapframe *frame) uvmexp.softs++; p->p_md.md_astpending = 0; if (p->p_flag & P_OWEUPC) { + KERNEL_LOCK(); ADDUPROF(p); + KERNEL_UNLOCK(); } if (ci->ci_want_resched) preempt(NULL); @@ -600,7 +602,9 @@ user_fault: if (sig) { sv.sival_ptr = (void *)fault_addr; + KERNEL_LOCK(); trapsignal(p, sig, fault_code, fault_type, sv); + KERNEL_UNLOCK(); /* * don't want multiple faults - we are going to * deliver signal. @@ -1113,7 +1117,9 @@ m88110_user_fault: if (sig) { deliver: sv.sival_ptr = (void *)fault_addr; + KERNEL_LOCK(); trapsignal(p, sig, fault_code, fault_type, sv); + KERNEL_UNLOCK(); } userexit: @@ -1198,18 +1204,24 @@ m88100_syscall(register_t code, struct trapframe *tf) goto bad; #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, callp->sy_argsize, args); + KERNEL_UNLOCK(); } #endif rval[0] = 0; rval[1] = tf->tf_r[3]; #if NSYSTRACE > 0 if (ISSET(p->p_flag, P_SYSTRACE)) { + KERNEL_LOCK(); error = systrace_redirect(code, p, args, rval); + KERNEL_UNLOCK(); } else #endif { @@ -1277,12 +1289,16 @@ bad: break; } #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 } @@ -1352,18 +1368,24 @@ m88110_syscall(register_t code, struct trapframe *tf) goto bad; #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, callp->sy_argsize, args); + KERNEL_UNLOCK(); } #endif rval[0] = 0; rval[1] = tf->tf_r[3]; #if NSYSTRACE > 0 if (ISSET(p->p_flag, P_SYSTRACE)) { + KERNEL_LOCK(); error = systrace_redirect(code, p, args, rval); + KERNEL_UNLOCK(); } else #endif { @@ -1434,12 +1456,16 @@ bad: } #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 } @@ -1480,10 +1506,12 @@ child_return(arg) #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/mips64/mips64/fp_emulate.c b/sys/arch/mips64/mips64/fp_emulate.c index 8daad01d48c..87c40ab1346 100644 --- a/sys/arch/mips64/mips64/fp_emulate.c +++ b/sys/arch/mips64/mips64/fp_emulate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fp_emulate.c,v 1.5 2011/07/07 18:11:24 art Exp $ */ +/* $OpenBSD: fp_emulate.c,v 1.6 2011/07/11 15:40:47 guenther Exp $ */ /* * Copyright (c) 2010 Miodrag Vallat. @@ -385,7 +385,9 @@ deliver: if (sig != SIGBUS && sig != SIGSEGV) #endif sv.sival_ptr = (void *)pc; + KERNEL_LOCK(); trapsignal(p, sig, 0, fault_type, sv); + KERNEL_UNLOCK(); } } diff --git a/sys/arch/mips64/mips64/trap.c b/sys/arch/mips64/mips64/trap.c index 88e2e89dad4..391f1467447 100644 --- a/sys/arch/mips64/mips64/trap.c +++ b/sys/arch/mips64/mips64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.75 2011/07/07 18:11:24 art Exp $ */ +/* $OpenBSD: trap.c,v 1.76 2011/07/11 15:40:47 guenther Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -166,7 +166,9 @@ ast() p->p_md.md_astpending = 0; if (p->p_flag & P_OWEUPC) { + KERNEL_LOCK(); ADDUPROF(p); + KERNEL_UNLOCK(); } if (ci->ci_want_resched) preempt(NULL); @@ -496,11 +498,15 @@ printf("SIG-BUSB @%p pc %p, ra %p\n", trapframe->badvaddr, trapframe->pc, trapfr } } #ifdef SYSCALL_DEBUG + KERNEL_LOCK(); scdebug_call(p, code, args.i); + KERNEL_UNLOCK(); #endif #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) { + KERNEL_LOCK(); ktrsyscall(p, code, callp->sy_argsize, args.i); + KERNEL_UNLOCK(); } #endif rval[0] = 0; @@ -512,7 +518,9 @@ printf("SIG-BUSB @%p pc %p, ra %p\n", trapframe->badvaddr, trapframe->pc, trapfr #if NSYSTRACE > 0 if (ISSET(p->p_flag, P_SYSTRACE)) { + KERNEL_LOCK(); i = systrace_redirect(code, p, args.i, rval); + KERNEL_UNLOCK(); } else #endif { @@ -542,11 +550,15 @@ printf("SIG-BUSB @%p pc %p, ra %p\n", trapframe->badvaddr, trapframe->pc, trapfr locr0->a3 = 1; } #ifdef SYSCALL_DEBUG + KERNEL_LOCK(); scdebug_ret(p, code, i, rval); + KERNEL_UNLOCK(); #endif #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { + KERNEL_LOCK(); ktrsysret(p, code, i, rval[0]); + KERNEL_UNLOCK(); } #endif goto out; @@ -792,7 +804,9 @@ printf("SIG-BUSB @%p pc %p, ra %p\n", trapframe->badvaddr, trapframe->pc, trapfr p->p_md.md_regs->cause = trapframe->cause; p->p_md.md_regs->badvaddr = trapframe->badvaddr; sv.sival_ptr = (void *)trapframe->badvaddr; + KERNEL_LOCK(); trapsignal(p, i, ucode, typ, sv); + KERNEL_UNLOCK(); out: /* * Note: we should only get here if returning to user mode. @@ -818,10 +832,12 @@ child_return(arg) #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/powerpc/powerpc/trap.c b/sys/arch/powerpc/powerpc/trap.c index a37d7452668..8abdcddab2c 100644 --- a/sys/arch/powerpc/powerpc/trap.c +++ b/sys/arch/powerpc/powerpc/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.86 2011/07/07 18:11:24 art Exp $ */ +/* $OpenBSD: trap.c,v 1.87 2011/07/11 15:40:47 guenther Exp $ */ /* $NetBSD: trap.c,v 1.3 1996/10/13 03:31:37 christos Exp $ */ /* @@ -275,7 +275,9 @@ trap(struct trapframe *frame) case EXC_TRC|EXC_USER: { sv.sival_int = frame->srr0; + KERNEL_LOCK(); trapsignal(p, SIGTRAP, type, TRAP_TRACE, sv); + KERNEL_UNLOCK(); } break; @@ -400,7 +402,9 @@ printf("isi iar %x lr %x\n", frame->srr0, frame->lr); /* XXX Likely that returning from this trap is bogus... */ /* XXX Have to make sure that sigreturn does the right thing. */ sv.sival_int = frame->srr0; + KERNEL_LOCK(); trapsignal(p, SIGSEGV, VM_PROT_EXECUTE, SEGV_MAPERR, sv); + KERNEL_UNLOCK(); break; case EXC_SC|EXC_USER: { @@ -466,21 +470,27 @@ printf("isi iar %x lr %x\n", frame->srr0, frame->lr); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) { + KERNEL_LOCK(); ktrsyscall(p, code, argsize, params); + KERNEL_UNLOCK(); } #endif rval[0] = 0; rval[1] = frame->fixreg[FIRSTARG + 1]; #ifdef SYSCALL_DEBUG + KERNEL_LOCK(); scdebug_call(p, code, params); + KERNEL_UNLOCK(); #endif #if NSYSTRACE > 0 if (ISSET(p->p_flag, P_SYSTRACE)) { + KERNEL_LOCK(); error = systrace_redirect(code, p, params, rval); + KERNEL_UNLOCK(); } else #endif { @@ -518,11 +528,15 @@ syscall_bad: break; } #ifdef SYSCALL_DEBUG + KERNEL_LOCK(); scdebug_ret(p, code, error, rval); + KERNEL_UNLOCK(); #endif #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { + KERNEL_LOCK(); ktrsysret(p, code, error, rval[0]); + KERNEL_UNLOCK(); } #endif } @@ -545,8 +559,10 @@ syscall_bad: frame->srr0 += 4; else { sv.sival_int = frame->srr0; + KERNEL_LOCK(); trapsignal(p, SIGSEGV, VM_PROT_EXECUTE, SEGV_MAPERR, sv); + KERNEL_UNLOCK(); } break; @@ -600,7 +616,9 @@ mpc_print_pci_stat(); errnum++; #endif sv.sival_int = frame->srr0; + KERNEL_LOCK(); trapsignal(p, SIGTRAP, type, TRAP_BRKPT, sv); + KERNEL_UNLOCK(); break; } #if 0 @@ -619,7 +637,9 @@ for (i = 0; i < errnum; i++) { } #endif sv.sival_int = frame->srr0; + KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv); + KERNEL_UNLOCK(); break; } case EXC_PGM: @@ -647,19 +667,25 @@ for (i = 0; i < errnum; i++) { break; #else /* ALTIVEC */ sv.sival_int = frame->srr0; + KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv); + KERNEL_UNLOCK(); break; #endif case EXC_VECAST|EXC_USER: + KERNEL_LOCK(); trapsignal(p, SIGFPE, 0, FPE_FLTRES, sv); + KERNEL_UNLOCK(); break; case EXC_AST|EXC_USER: uvmexp.softs++; p->p_md.md_astpending = 0; /* we are about to do it */ if (p->p_flag & P_OWEUPC) { + KERNEL_LOCK(); ADDUPROF(p); + KERNEL_UNLOCK(); } if (ci->ci_want_resched) preempt(NULL); @@ -706,10 +732,12 @@ child_return(void *arg) #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/sparc64/fpu/fpu.c b/sys/arch/sparc64/fpu/fpu.c index 82ecd01693f..c82af1be713 100644 --- a/sys/arch/sparc64/fpu/fpu.c +++ b/sys/arch/sparc64/fpu/fpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpu.c,v 1.16 2011/07/07 18:11:24 art Exp $ */ +/* $OpenBSD: fpu.c,v 1.17 2011/07/11 15:40:47 guenther Exp $ */ /* $NetBSD: fpu.c,v 1.11 2000/12/06 01:47:50 mrg Exp $ */ /* @@ -214,7 +214,9 @@ fpu_cleanup(p, fs) case FSR_TT_IEEE: if ((i = fsr & FSR_CX) == 0) panic("fpu ieee trap, but no exception"); + KERNEL_LOCK(); trapsignal(p, SIGFPE, fpu_codes[i - 1], fpu_types[i - 1], sv); + KERNEL_UNLOCK(); break; /* XXX should return, but queue remains */ case FSR_TT_UNFIN: @@ -237,7 +239,9 @@ fpu_cleanup(p, fs) log(LOG_ERR, "fpu hardware error (%s[%d])\n", p->p_comm, p->p_pid); uprintf("%s[%d]: fpu hardware error\n", p->p_comm, p->p_pid); + KERNEL_LOCK(); trapsignal(p, SIGFPE, -1, FPE_FLTINV, sv); /* ??? */ + KERNEL_UNLOCK(); goto out; default: @@ -260,13 +264,17 @@ fpu_cleanup(p, fs) continue; case FPE: + KERNEL_LOCK(); trapsignal(p, SIGFPE, fpu_codes[(fs->fs_fsr & FSR_CX) - 1], fpu_types[(fs->fs_fsr & FSR_CX) - 1], sv); + KERNEL_UNLOCK(); break; case NOTFPU: + KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_COPROC, sv); + KERNEL_UNLOCK(); break; default: diff --git a/sys/arch/sparc64/sparc64/emul.c b/sys/arch/sparc64/sparc64/emul.c index d83f2737586..3cd9f33faa2 100644 --- a/sys/arch/sparc64/sparc64/emul.c +++ b/sys/arch/sparc64/sparc64/emul.c @@ -1,4 +1,4 @@ -/* $OpenBSD: emul.c,v 1.21 2011/07/07 18:11:24 art Exp $ */ +/* $OpenBSD: emul.c,v 1.22 2011/07/11 15:40:47 guenther Exp $ */ /* $NetBSD: emul.c,v 1.8 2001/06/29 23:58:40 eeh Exp $ */ /*- @@ -333,7 +333,9 @@ emul_qf(int32_t insv, struct proc *p, union sigval sv, struct trapframe *tf) if (asi < ASI_PRIMARY) { /* privileged asi */ + KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_PRVOPC, sv); + KERNEL_UNLOCK(); return (0); } if (asi > ASI_SECONDARY_NOFAULT_LITTLE || @@ -344,13 +346,17 @@ emul_qf(int32_t insv, struct proc *p, union sigval sv, struct trapframe *tf) if ((freg & 3) != 0) { /* only valid for %fN where N % 4 = 0 */ + KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPN, sv); + KERNEL_UNLOCK(); return (0); } if ((addr & 3) != 0) { /* request is not aligned */ + KERNEL_LOCK(); trapsignal(p, SIGBUS, 0, BUS_ADRALN, sv); + KERNEL_UNLOCK(); return (0); } @@ -387,8 +393,10 @@ emul_qf(int32_t insv, struct proc *p, union sigval sv, struct trapframe *tf) return (1); segv: + KERNEL_LOCK(); trapsignal(p, SIGSEGV, isload ? VM_PROT_READ : VM_PROT_WRITE, SEGV_MAPERR, sv); + KERNEL_UNLOCK(); return (0); } diff --git a/sys/arch/sparc64/sparc64/trap.c b/sys/arch/sparc64/sparc64/trap.c index 2c1dbce8386..29fd687123b 100644 --- a/sys/arch/sparc64/sparc64/trap.c +++ b/sys/arch/sparc64/sparc64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.72 2011/07/07 18:11:24 art Exp $ */ +/* $OpenBSD: trap.c,v 1.73 2011/07/11 15:40:47 guenther Exp $ */ /* $NetBSD: trap.c,v 1.73 2001/08/09 01:03:01 eeh Exp $ */ /* @@ -466,13 +466,17 @@ dopanic: pc, (long)tf->tf_npc, pstate, PSTATE_BITS); /* NOTREACHED */ } + KERNEL_LOCK(); trapsignal(p, SIGILL, type, ILL_ILLOPC, sv); + KERNEL_UNLOCK(); break; case T_AST: p->p_md.md_astpending = 0; if (p->p_flag & P_OWEUPC) { + KERNEL_LOCK(); ADDUPROF(p); + KERNEL_UNLOCK(); } if (curcpu()->ci_want_resched) preempt(NULL); @@ -489,7 +493,9 @@ dopanic: */ write_user_windows(); if (rwindow_save(p) == -1) { + KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_BADSTK, sv); + KERNEL_UNLOCK(); } break; @@ -499,7 +505,9 @@ dopanic: if (copyin((caddr_t)pc, &ins, sizeof(ins)) != 0) { /* XXX Can this happen? */ + KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv); + KERNEL_UNLOCK(); break; } if (ins.i_any.i_op == IOP_mem && @@ -518,7 +526,9 @@ dopanic: ADVANCE; break; } + KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv); /* XXX code? */ + KERNEL_UNLOCK(); break; } @@ -526,7 +536,9 @@ dopanic: case T_TEXTFAULT: case T_PRIVINST: case T_PRIVACT: + KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv); /* XXX code? */ + KERNEL_UNLOCK(); break; case T_FPDISABLED: { @@ -577,7 +589,9 @@ dopanic: if (copyin((caddr_t)pc, &ins, sizeof(ins)) != 0) { /* XXX Can this happen? */ + KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv); + KERNEL_UNLOCK(); break; } if (ins.i_any.i_op == IOP_mem && @@ -588,7 +602,9 @@ dopanic: if (emul_qf(ins.i_int, p, sv, tf)) ADVANCE; } else { + KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv); + KERNEL_UNLOCK(); } break; } @@ -631,7 +647,9 @@ dopanic: } /* XXX sv.sival_ptr should be the fault address! */ + KERNEL_LOCK(); trapsignal(p, SIGBUS, 0, BUS_ADRALN, sv); /* XXX code? */ + KERNEL_UNLOCK(); break; case T_FP_IEEE_754: @@ -666,16 +684,22 @@ dopanic: break; case T_TAGOF: + KERNEL_LOCK(); trapsignal(p, SIGEMT, 0, EMT_TAGOVF, sv); /* XXX code? */ + KERNEL_UNLOCK(); break; case T_BREAKPOINT: + KERNEL_LOCK(); trapsignal(p, SIGTRAP, 0, TRAP_BRKPT, sv); + KERNEL_UNLOCK(); break; case T_DIV0: ADVANCE; + KERNEL_LOCK(); trapsignal(p, SIGFPE, 0, FPE_INTDIV, sv); + KERNEL_UNLOCK(); break; case T_CLEANWIN: @@ -691,19 +715,25 @@ dopanic: case T_RANGECHECK: ADVANCE; + KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPN, sv); /* XXX code? */ + KERNEL_UNLOCK(); break; case T_FIXALIGN: uprintf("T_FIXALIGN\n"); ADVANCE; + KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPN, sv); /* XXX code? */ + KERNEL_UNLOCK(); break; case T_INTOF: uprintf("T_INTOF\n"); /* XXX */ ADVANCE; + KERNEL_LOCK(); trapsignal(p, SIGFPE, FPE_INTOVF_TRAP, FPE_INTOVF, sv); + KERNEL_UNLOCK(); break; } userret(p); @@ -971,7 +1001,9 @@ data_access_error(tf, type, afva, afsr, sfva, sfsr) return; } + KERNEL_LOCK(); trapsignal(p, SIGSEGV, VM_PROT_READ|VM_PROT_WRITE, SEGV_MAPERR, sv); + KERNEL_UNLOCK(); out: if ((tstate & TSTATE_PRIV) == 0) { @@ -1108,7 +1140,9 @@ text_access_error(tf, type, pc, sfsr, afva, afsr) panic("text_access_error: kernel memory error"); /* User fault -- Berr */ + KERNEL_LOCK(); trapsignal(p, SIGBUS, 0, BUS_ADRALN, sv); + KERNEL_UNLOCK(); } if ((sfsr & SFSR_FV) == 0 || (sfsr & SFSR_FT) == 0) @@ -1292,7 +1326,9 @@ syscall(tf, code, pc) #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) { + KERNEL_LOCK(); ktrsyscall(p, code, callp->sy_argsize, args); + KERNEL_UNLOCK(); } #endif if (error) @@ -1303,13 +1339,17 @@ syscall(tf, code, pc) } #ifdef SYSCALL_DEBUG + KERNEL_LOCK(); scdebug_call(p, code, args); + KERNEL_UNLOCK(); #endif rval[0] = 0; rval[1] = tf->tf_out[1]; #if NSYSTRACE > 0 if (ISSET(p->p_flag, P_SYSTRACE)) { + KERNEL_LOCK(); error = systrace_redirect(code, p, args, rval); + KERNEL_UNLOCK(); } else #endif { @@ -1359,12 +1399,16 @@ syscall(tf, code, pc) } #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 share_fpu(p, tf); @@ -1392,10 +1436,12 @@ child_return(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 } |