summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2010-01-01 13:13:09 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2010-01-01 13:13:09 +0000
commit9d5e05dd2c7d5b5999777f3443f2b4342d16e894 (patch)
tree62a994c6b721b2829cdd4f5fd04aaf5853f50e36
parent95ade707baba1bae9d8c011069ff1fb9201799d5 (diff)
Make sure we grab the kernel lock before invoking trapsignal().
ok kettenis@
-rw-r--r--sys/arch/sparc64/fpu/fpu.c10
-rw-r--r--sys/arch/sparc64/sparc64/emul.c10
2 files changed, 18 insertions, 2 deletions
diff --git a/sys/arch/sparc64/fpu/fpu.c b/sys/arch/sparc64/fpu/fpu.c
index 667f80fcd43..4c4b5ccb544 100644
--- a/sys/arch/sparc64/fpu/fpu.c
+++ b/sys/arch/sparc64/fpu/fpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fpu.c,v 1.13 2007/09/09 12:57:40 kettenis Exp $ */
+/* $OpenBSD: fpu.c,v 1.14 2010/01/01 13:13:07 miod 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_PROC_LOCK(p);
trapsignal(p, SIGFPE, fpu_codes[i - 1], fpu_types[i - 1], sv);
+ KERNEL_PROC_UNLOCK(p);
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_PROC_LOCK(p);
trapsignal(p, SIGFPE, -1, FPE_FLTINV, sv); /* ??? */
+ KERNEL_PROC_UNLOCK(p);
goto out;
default:
@@ -260,13 +264,17 @@ fpu_cleanup(p, fs)
continue;
case FPE:
+ KERNEL_PROC_LOCK(p);
trapsignal(p, SIGFPE,
fpu_codes[(fs->fs_fsr & FSR_CX) - 1],
fpu_types[(fs->fs_fsr & FSR_CX) - 1], sv);
+ KERNEL_PROC_UNLOCK(p);
break;
case NOTFPU:
+ KERNEL_PROC_LOCK(p);
trapsignal(p, SIGILL, 0, ILL_COPROC, sv);
+ KERNEL_PROC_UNLOCK(p);
break;
default:
diff --git a/sys/arch/sparc64/sparc64/emul.c b/sys/arch/sparc64/sparc64/emul.c
index 3d6548c30b3..c14304781f5 100644
--- a/sys/arch/sparc64/sparc64/emul.c
+++ b/sys/arch/sparc64/sparc64/emul.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: emul.c,v 1.15 2008/06/26 05:42:13 ray Exp $ */
+/* $OpenBSD: emul.c,v 1.16 2010/01/01 13:13:08 miod Exp $ */
/* $NetBSD: emul.c,v 1.8 2001/06/29 23:58:40 eeh Exp $ */
/*-
@@ -497,7 +497,9 @@ emul_qf(int32_t insv, struct proc *p, union sigval sv, struct trapframe *tf)
if (asi < ASI_PRIMARY) {
/* privileged asi */
+ KERNEL_PROC_LOCK(p);
trapsignal(p, SIGILL, 0, ILL_PRVOPC, sv);
+ KERNEL_PROC_UNLOCK(p);
return (0);
}
if (asi > ASI_SECONDARY_NOFAULT_LITTLE ||
@@ -508,7 +510,9 @@ 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_PROC_LOCK(p);
trapsignal(p, SIGILL, 0, ILL_ILLOPN, sv);
+ KERNEL_PROC_UNLOCK(p);
return (0);
}
@@ -517,7 +521,9 @@ emul_qf(int32_t insv, struct proc *p, union sigval sv, struct trapframe *tf)
* If process doesn't want us to fix alignment and the
* request isn't aligned, kill it.
*/
+ KERNEL_PROC_LOCK(p);
trapsignal(p, SIGBUS, 0, BUS_ADRALN, sv);
+ KERNEL_PROC_UNLOCK(p);
return (0);
}
@@ -554,7 +560,9 @@ emul_qf(int32_t insv, struct proc *p, union sigval sv, struct trapframe *tf)
return (1);
segv:
+ KERNEL_PROC_LOCK(p);
trapsignal(p, SIGSEGV, isload ? VM_PROT_READ : VM_PROT_WRITE,
+ KERNEL_PROC_UNLOCK(p);
SEGV_MAPERR, sv);
return (0);
}