summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2020-08-19 10:10:59 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2020-08-19 10:10:59 +0000
commit8ba0cde5f5b1f4893fed53f798aea25db42477cc (patch)
treed53f6fb5e1e82791c1277d4e1a98ccfaa8109a2f /sys
parentb1c76213ea9218d3823866f7dd850875db91b45d (diff)
Push KERNEL_LOCK/UNLOCK() dance inside trapsignal().
ok kettenis@, visa@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/alpha/alpha/trap.c4
-rw-r--r--sys/arch/amd64/amd64/trap.c4
-rw-r--r--sys/arch/arm/arm/fault.c8
-rw-r--r--sys/arch/arm/arm/undefined.c8
-rw-r--r--sys/arch/arm64/arm64/trap.c16
-rw-r--r--sys/arch/hppa/hppa/trap.c28
-rw-r--r--sys/arch/i386/i386/trap.c26
-rw-r--r--sys/arch/i386/isa/npx.c6
-rw-r--r--sys/arch/m88k/m88k/m88100_fp.c4
-rw-r--r--sys/arch/m88k/m88k/m88110_fp.c4
-rw-r--r--sys/arch/m88k/m88k/trap.c6
-rw-r--r--sys/arch/mips64/mips64/fp_emulate.c4
-rw-r--r--sys/arch/mips64/mips64/trap.c4
-rw-r--r--sys/arch/powerpc/powerpc/trap.c16
-rw-r--r--sys/arch/powerpc64/powerpc64/trap.c10
-rw-r--r--sys/arch/sparc64/fpu/fpu.c10
-rw-r--r--sys/arch/sparc64/sparc64/emul.c10
-rw-r--r--sys/arch/sparc64/sparc64/trap.c34
-rw-r--r--sys/kern/kern_sig.c4
19 files changed, 21 insertions, 185 deletions
diff --git a/sys/arch/alpha/alpha/trap.c b/sys/arch/alpha/alpha/trap.c
index 252e2fdd69d..c145c8b1627 100644
--- a/sys/arch/alpha/alpha/trap.c
+++ b/sys/arch/alpha/alpha/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.88 2019/09/06 12:22:01 deraadt Exp $ */
+/* $OpenBSD: trap.c,v 1.89 2020/08/19 10:10:57 mpi Exp $ */
/* $NetBSD: trap.c,v 1.52 2000/05/24 16:48:33 thorpej Exp $ */
/*-
@@ -488,9 +488,7 @@ do_fault:
printtrap(a0, a1, a2, entry, framep, 1, user);
#endif
sv.sival_ptr = v;
- KERNEL_LOCK();
trapsignal(p, i, ucode, typ, sv);
- KERNEL_UNLOCK();
out:
if (user) {
/* Do any deferred user pmap operations. */
diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c
index 2e4ea21bc79..4a4c6275aa7 100644
--- a/sys/arch/amd64/amd64/trap.c
+++ b/sys/arch/amd64/amd64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.79 2020/01/21 03:06:39 mlarkin Exp $ */
+/* $OpenBSD: trap.c,v 1.80 2020/08/19 10:10:57 mpi Exp $ */
/* $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $ */
/*-
@@ -391,9 +391,7 @@ usertrap(struct trapframe *frame)
}
sv.sival_ptr = (void *)frame->tf_rip;
- KERNEL_LOCK();
trapsignal(p, sig, type, code, sv);
- KERNEL_UNLOCK();
out:
userret(p);
diff --git a/sys/arch/arm/arm/fault.c b/sys/arch/arm/arm/fault.c
index 303ede0f24d..40f362254bb 100644
--- a/sys/arch/arm/arm/fault.c
+++ b/sys/arch/arm/arm/fault.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fault.c,v 1.39 2019/09/06 12:22:01 deraadt Exp $ */
+/* $OpenBSD: fault.c,v 1.40 2020/08/19 10:10:58 mpi Exp $ */
/* $NetBSD: fault.c,v 1.46 2004/01/21 15:39:21 skrll Exp $ */
/*
@@ -373,9 +373,7 @@ data_abort_handler(trapframe_t *tf)
sd.trap = fsr;
do_trapsignal:
sv.sival_int = sd.addr;
- KERNEL_LOCK();
trapsignal(p, sd.signo, sd.trap, sd.code, sv);
- KERNEL_UNLOCK();
out:
/* If returning to user mode, make sure to invoke userret() */
if (user)
@@ -596,13 +594,9 @@ prefetch_abort_handler(trapframe_t *tf)
printf("UVM: pid %d (%s), uid %d killed: "
"out of swap\n", p->p_p->ps_pid, p->p_p->ps_comm,
p->p_ucred ? (int)p->p_ucred->cr_uid : -1);
- KERNEL_LOCK();
trapsignal(p, SIGKILL, 0, SEGV_MAPERR, sv);
- KERNEL_UNLOCK();
} else {
- KERNEL_LOCK();
trapsignal(p, SIGSEGV, 0, SEGV_MAPERR, sv);
- KERNEL_UNLOCK();
}
out:
diff --git a/sys/arch/arm/arm/undefined.c b/sys/arch/arm/arm/undefined.c
index d0acd459d41..6850d945596 100644
--- a/sys/arch/arm/arm/undefined.c
+++ b/sys/arch/arm/arm/undefined.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: undefined.c,v 1.13 2019/03/13 09:28:21 patrick Exp $ */
+/* $OpenBSD: undefined.c,v 1.14 2020/08/19 10:10:58 mpi Exp $ */
/* $NetBSD: undefined.c,v 1.22 2003/11/29 22:21:29 bjh21 Exp $ */
/*
@@ -113,9 +113,7 @@ gdb_trapper(u_int addr, u_int insn, struct trapframe *frame, int code, uint32_t
if (insn == GDB_BREAKPOINT || insn == GDB5_BREAKPOINT) {
if (code == FAULT_USER) {
sv.sival_int = addr;
- KERNEL_LOCK();
trapsignal(p, SIGTRAP, 0, TRAP_BRKPT, sv);
- KERNEL_UNLOCK();
return 0;
}
}
@@ -174,9 +172,7 @@ undefinedinstruction(trapframe_t *frame)
if (__predict_false((fault_pc & 3) != 0)) {
/* Give the user an illegal instruction signal. */
sv.sival_int = (u_int32_t) fault_pc;
- KERNEL_LOCK();
trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv);
- KERNEL_UNLOCK();
userret(p);
return;
}
@@ -260,9 +256,7 @@ undefinedinstruction(trapframe_t *frame)
}
sv.sival_int = frame->tf_pc;
- KERNEL_LOCK();
trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv);
- KERNEL_UNLOCK();
}
if ((fault_code & FAULT_USER) == 0)
diff --git a/sys/arch/arm64/arm64/trap.c b/sys/arch/arm64/arm64/trap.c
index 4f0e4aa2fd5..7282c7f372b 100644
--- a/sys/arch/arm64/arm64/trap.c
+++ b/sys/arch/arm64/arm64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.28 2020/08/17 08:09:03 kettenis Exp $ */
+/* $OpenBSD: trap.c,v 1.29 2020/08/19 10:10:58 mpi Exp $ */
/*-
* Copyright (c) 2014 Andrew Turner
* All rights reserved.
@@ -97,9 +97,7 @@ data_abort(struct trapframe *frame, uint64_t esr, uint64_t far,
switch (esr & ISS_DATA_DFSC_MASK) {
case ISS_DATA_DFSC_ALIGN:
sv.sival_ptr = (void *)far;
- KERNEL_LOCK();
trapsignal(p, SIGBUS, 0, BUS_ADRALN, sv);
- KERNEL_UNLOCK();
return;
default:
break;
@@ -170,9 +168,7 @@ data_abort(struct trapframe *frame, uint64_t esr, uint64_t far,
}
sv.sival_ptr = (void *)far;
- KERNEL_LOCK();
trapsignal(p, sig, 0, code, sv);
- KERNEL_UNLOCK();
} else {
if (curcpu()->ci_idepth == 0 &&
pcb->pcb_onfault != 0) {
@@ -272,9 +268,7 @@ do_el0_sync(struct trapframe *frame)
vfp_save();
curcpu()->ci_flush_bp();
sv.sival_ptr = (void *)frame->tf_elr;
- KERNEL_LOCK();
trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv);
- KERNEL_UNLOCK();
break;
case EXCP_FP_SIMD:
case EXCP_TRAP_FP:
@@ -292,17 +286,13 @@ do_el0_sync(struct trapframe *frame)
vfp_save();
curcpu()->ci_flush_bp();
sv.sival_ptr = (void *)frame->tf_elr;
- KERNEL_LOCK();
trapsignal(p, SIGBUS, 0, BUS_ADRALN, sv);
- KERNEL_UNLOCK();
break;
case EXCP_SP_ALIGN:
vfp_save();
curcpu()->ci_flush_bp();
sv.sival_ptr = (void *)frame->tf_sp;
- KERNEL_LOCK();
trapsignal(p, SIGBUS, 0, BUS_ADRALN, sv);
- KERNEL_UNLOCK();
break;
case EXCP_DATA_ABORT_L:
vfp_save();
@@ -311,16 +301,12 @@ do_el0_sync(struct trapframe *frame)
case EXCP_BRK:
vfp_save();
sv.sival_ptr = (void *)frame->tf_elr;
- KERNEL_LOCK();
trapsignal(p, SIGTRAP, 0, TRAP_BRKPT, sv);
- KERNEL_UNLOCK();
break;
case EXCP_SOFTSTP_EL0:
vfp_save();
sv.sival_ptr = (void *)frame->tf_elr;
- KERNEL_LOCK();
trapsignal(p, SIGTRAP, 0, TRAP_TRACE, sv);
- KERNEL_UNLOCK();
break;
default:
// panic("Unknown userland exception %x esr_el1 %lx\n", exception,
diff --git a/sys/arch/hppa/hppa/trap.c b/sys/arch/hppa/hppa/trap.c
index e3a56d7a1ca..6ad34750b51 100644
--- a/sys/arch/hppa/hppa/trap.c
+++ b/sys/arch/hppa/hppa/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.146 2019/09/06 12:22:01 deraadt Exp $ */
+/* $OpenBSD: trap.c,v 1.147 2020/08/19 10:10:58 mpi Exp $ */
/*
* Copyright (c) 1998-2004 Michael Shalayeff
@@ -328,9 +328,7 @@ 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;
@@ -340,30 +338,22 @@ 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:
@@ -386,9 +376,7 @@ trap(int type, struct trapframe *frame)
frame->tf_ipsw |= PSL_N;
} else {
sv.sival_int = va;
- KERNEL_LOCK();
trapsignal(p, SIGILL, type & ~T_USER, ILL_PRVREG, sv);
- KERNEL_UNLOCK();
}
break;
@@ -397,9 +385,7 @@ trap(int type, struct trapframe *frame)
case T_LOWERPL | T_USER:
case T_DATAPID | T_USER:
sv.sival_int = va;
- KERNEL_LOCK();
trapsignal(p, SIGSEGV, vftype, SEGV_ACCERR, sv);
- KERNEL_UNLOCK();
break;
/*
@@ -416,9 +402,7 @@ trap(int type, struct trapframe *frame)
}
sv.sival_int = va;
- KERNEL_LOCK();
trapsignal(p, SIGSEGV, vftype, SEGV_ACCERR, sv);
- KERNEL_UNLOCK();
break;
case T_ITLBMISSNA:
@@ -460,9 +444,7 @@ 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%lx:0x%lx for 0x%x:0x%lx irr 0x%08x",
tts, frame->tf_iisq_head, frame->tf_iioq_head,
@@ -501,9 +483,7 @@ 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;
}
@@ -537,9 +517,7 @@ datacc:
sicode = BUS_OBJERR;
}
sv.sival_int = va;
- KERNEL_LOCK();
trapsignal(p, signal, vftype, sicode, sv);
- KERNEL_UNLOCK();
} else {
if (p && p->p_addr->u_pcb.pcb_onfault) {
frame->tf_iioq_tail = 4 +
@@ -573,9 +551,7 @@ 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:
@@ -597,9 +573,7 @@ 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 */
diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c
index 30fcba0cc72..747dac01582 100644
--- a/sys/arch/i386/i386/trap.c
+++ b/sys/arch/i386/i386/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.142 2019/12/08 12:25:30 mpi Exp $ */
+/* $OpenBSD: trap.c,v 1.143 2020/08/19 10:10:58 mpi Exp $ */
/* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */
/*-
@@ -274,74 +274,54 @@ trap(struct trapframe *frame)
case T_TSSFLT|T_USER:
sv.sival_int = frame->tf_eip;
- KERNEL_LOCK();
trapsignal(p, SIGBUS, type &~ T_USER, 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, type &~ T_USER, SEGV_MAPERR, sv);
- KERNEL_UNLOCK();
goto out;
case T_ALIGNFLT|T_USER:
sv.sival_int = frame->tf_eip;
- 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_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_DNA|T_USER: {
printf("pid %d killed due to lack of floating point\n",
p->p_p->ps_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:
@@ -455,15 +435,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
diff --git a/sys/arch/i386/isa/npx.c b/sys/arch/i386/isa/npx.c
index 4e113b86b7d..c65895c89b2 100644
--- a/sys/arch/i386/isa/npx.c
+++ b/sys/arch/i386/isa/npx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: npx.c,v 1.70 2018/07/30 14:19:12 kettenis Exp $ */
+/* $OpenBSD: npx.c,v 1.71 2020/08/19 10:10:58 mpi Exp $ */
/* $NetBSD: npx.c,v 1.57 1996/05/12 23:12:24 mycroft Exp $ */
#if 0
@@ -529,9 +529,7 @@ npxintr(void *arg)
else
code = x86fpflags_to_siginfo(addr->sv_87.sv_ex_sw);
sv.sival_int = frame->if_eip;
- KERNEL_LOCK();
trapsignal(p, SIGFPE, T_ARITHTRAP, code, sv);
- KERNEL_UNLOCK();
} else {
/*
* Nested interrupt. These losers occur when:
@@ -582,9 +580,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
diff --git a/sys/arch/m88k/m88k/m88100_fp.c b/sys/arch/m88k/m88k/m88100_fp.c
index 5c7adf2bcbb..199e0191904 100644
--- a/sys/arch/m88k/m88k/m88100_fp.c
+++ b/sys/arch/m88k/m88k/m88100_fp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: m88100_fp.c,v 1.4 2017/09/08 05:36:52 deraadt Exp $ */
+/* $OpenBSD: m88100_fp.c,v 1.5 2020/08/19 10:10:58 mpi Exp $ */
/*
* Copyright (c) 2007, 2014, Miodrag Vallat.
@@ -464,8 +464,6 @@ m88100_fpu_checksig(struct trapframe *frame, int sig, int fault_type)
}
sv.sival_ptr = (void *)(frame->tf_sxip & XIP_ADDR);
- KERNEL_LOCK();
trapsignal(p, sig, 0, fault_type, sv);
- KERNEL_UNLOCK();
}
}
diff --git a/sys/arch/m88k/m88k/m88110_fp.c b/sys/arch/m88k/m88k/m88110_fp.c
index 0ddd911656b..ec59b304f70 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.11 2017/09/08 05:36:52 deraadt Exp $ */
+/* $OpenBSD: m88110_fp.c,v 1.12 2020/08/19 10:10:58 mpi Exp $ */
/*
* Copyright (c) 2007, Miodrag Vallat.
@@ -166,9 +166,7 @@ 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 52a56580fff..cd61860a6d8 100644
--- a/sys/arch/m88k/m88k/trap.c
+++ b/sys/arch/m88k/m88k/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.111 2019/12/11 07:21:40 guenther Exp $ */
+/* $OpenBSD: trap.c,v 1.112 2020/08/19 10:10:58 mpi Exp $ */
/*
* Copyright (c) 2004, Miodrag Vallat.
* Copyright (c) 1998 Steve Murphree, Jr.
@@ -587,9 +587,7 @@ 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.
@@ -1121,9 +1119,7 @@ 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:
diff --git a/sys/arch/mips64/mips64/fp_emulate.c b/sys/arch/mips64/mips64/fp_emulate.c
index ba6a7351fb4..379569b73a6 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.22 2019/01/14 15:02:57 visa Exp $ */
+/* $OpenBSD: fp_emulate.c,v 1.23 2020/08/19 10:10:58 mpi Exp $ */
/*
* Copyright (c) 2010 Miodrag Vallat.
@@ -431,9 +431,7 @@ deliver:
if (sig != 0) {
if (sig != SIGBUS && sig != SIGSEGV)
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 87d390978cf..2a657cd6cb2 100644
--- a/sys/arch/mips64/mips64/trap.c
+++ b/sys/arch/mips64/mips64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.145 2020/05/23 07:18:50 visa Exp $ */
+/* $OpenBSD: trap.c,v 1.146 2020/08/19 10:10:58 mpi Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -926,9 +926,7 @@ fault_common_no_miss:
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, signal, ucode, sicode, sv);
- KERNEL_UNLOCK();
}
void
diff --git a/sys/arch/powerpc/powerpc/trap.c b/sys/arch/powerpc/powerpc/trap.c
index 64a1ba04329..b6c67e732fc 100644
--- a/sys/arch/powerpc/powerpc/trap.c
+++ b/sys/arch/powerpc/powerpc/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.114 2019/09/06 13:45:04 deraadt Exp $ */
+/* $OpenBSD: trap.c,v 1.115 2020/08/19 10:10:58 mpi Exp $ */
/* $NetBSD: trap.c,v 1.3 1996/10/13 03:31:37 christos Exp $ */
/*
@@ -254,9 +254,7 @@ trap(struct trapframe *frame)
switch (type) {
case EXC_TRC|EXC_USER:
sv.sival_int = frame->srr0;
- KERNEL_LOCK();
trapsignal(p, SIGTRAP, type, TRAP_TRACE, sv);
- KERNEL_UNLOCK();
break;
case EXC_MCHK:
if ((fb = p->p_addr->u_pcb.pcb_onfault)) {
@@ -354,9 +352,7 @@ trap(struct trapframe *frame)
/* 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, PROT_EXEC, SEGV_MAPERR, sv);
- KERNEL_UNLOCK();
break;
case EXC_SC|EXC_USER:
@@ -455,9 +451,7 @@ trap(struct trapframe *frame)
frame->srr0 += 4;
else {
sv.sival_int = frame->srr0;
- KERNEL_LOCK();
trapsignal(p, SIGBUS, PROT_EXEC, BUS_ADRALN, sv);
- KERNEL_UNLOCK();
}
break;
@@ -481,15 +475,11 @@ brain_damage:
case EXC_PGM|EXC_USER:
if (frame->srr1 & (1<<(31-14))) {
sv.sival_int = frame->srr0;
- KERNEL_LOCK();
trapsignal(p, SIGTRAP, type, TRAP_BRKPT, sv);
- KERNEL_UNLOCK();
break;
}
sv.sival_int = frame->srr0;
- KERNEL_LOCK();
trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv);
- KERNEL_UNLOCK();
break;
case EXC_PGM:
@@ -519,17 +509,13 @@ brain_damage:
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:
sv.sival_int = frame->srr0;
- KERNEL_LOCK();
trapsignal(p, SIGFPE, 0, FPE_FLTRES, sv);
- KERNEL_UNLOCK();
break;
case EXC_AST|EXC_USER:
diff --git a/sys/arch/powerpc64/powerpc64/trap.c b/sys/arch/powerpc64/powerpc64/trap.c
index 08134fc21c1..4237acc56d8 100644
--- a/sys/arch/powerpc64/powerpc64/trap.c
+++ b/sys/arch/powerpc64/powerpc64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.34 2020/07/23 16:01:08 kettenis Exp $ */
+/* $OpenBSD: trap.c,v 1.35 2020/08/19 10:10:58 mpi Exp $ */
/*
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
@@ -205,9 +205,7 @@ trap(struct trapframe *frame)
code = SEGV_MAPERR;
}
sv.sival_ptr = (void *)va;
- KERNEL_LOCK();
trapsignal(p, sig, 0, code, sv);
- KERNEL_UNLOCK();
}
break;
@@ -246,9 +244,7 @@ trap(struct trapframe *frame)
code = SEGV_MAPERR;
}
sv.sival_ptr = (void *)va;
- KERNEL_LOCK();
trapsignal(p, sig, 0, code, sv);
- KERNEL_UNLOCK();
}
break;
@@ -264,9 +260,7 @@ trap(struct trapframe *frame)
case EXC_ALI|EXC_USER:
sv.sival_ptr = (void *)frame->dar;
- KERNEL_LOCK();
trapsignal(p, SIGBUS, 0, BUS_ADRALN, sv);
- KERNEL_UNLOCK();
break;
case EXC_PGM|EXC_USER:
@@ -274,9 +268,7 @@ trap(struct trapframe *frame)
dumpframe(frame);
sv.sival_ptr = (void *)frame->srr0;
- KERNEL_LOCK();
trapsignal(p, SIGTRAP, 0, TRAP_BRKPT, sv);
- KERNEL_UNLOCK();
break;
case EXC_FPU|EXC_USER:
diff --git a/sys/arch/sparc64/fpu/fpu.c b/sys/arch/sparc64/fpu/fpu.c
index db0b0bd51eb..f4bba76db9b 100644
--- a/sys/arch/sparc64/fpu/fpu.c
+++ b/sys/arch/sparc64/fpu/fpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fpu.c,v 1.20 2017/01/21 05:42:03 guenther Exp $ */
+/* $OpenBSD: fpu.c,v 1.21 2020/08/19 10:10:58 mpi Exp $ */
/* $NetBSD: fpu.c,v 1.11 2000/12/06 01:47:50 mrg Exp $ */
/*
@@ -214,9 +214,7 @@ 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:
@@ -240,9 +238,7 @@ fpu_cleanup(p, fs)
p->p_p->ps_comm, p->p_p->ps_pid);
uprintf("%s[%d]: fpu hardware error\n",
p->p_p->ps_comm, p->p_p->ps_pid);
- KERNEL_LOCK();
trapsignal(p, SIGFPE, -1, FPE_FLTINV, sv); /* ??? */
- KERNEL_UNLOCK();
goto out;
default:
@@ -265,17 +261,13 @@ 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 92e029f2ae1..d33047d1111 100644
--- a/sys/arch/sparc64/sparc64/emul.c
+++ b/sys/arch/sparc64/sparc64/emul.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: emul.c,v 1.24 2018/08/08 08:42:49 kn Exp $ */
+/* $OpenBSD: emul.c,v 1.25 2020/08/19 10:10:58 mpi Exp $ */
/* $NetBSD: emul.c,v 1.8 2001/06/29 23:58:40 eeh Exp $ */
/*-
@@ -306,9 +306,7 @@ 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 ||
@@ -319,17 +317,13 @@ 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);
}
@@ -366,10 +360,8 @@ emul_qf(int32_t insv, struct proc *p, union sigval sv, struct trapframe *tf)
return (1);
segv:
- KERNEL_LOCK();
trapsignal(p, SIGSEGV, isload ? PROT_READ : 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 753ba6d5847..e8c36d61e94 100644
--- a/sys/arch/sparc64/sparc64/trap.c
+++ b/sys/arch/sparc64/sparc64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.102 2019/09/06 12:22:01 deraadt Exp $ */
+/* $OpenBSD: trap.c,v 1.103 2020/08/19 10:10:58 mpi Exp $ */
/* $NetBSD: trap.c,v 1.73 2001/08/09 01:03:01 eeh Exp $ */
/*
@@ -441,9 +441,7 @@ 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:
@@ -463,9 +461,7 @@ dopanic:
*/
write_user_windows();
if (rwindow_save(p) == -1) {
- KERNEL_LOCK();
trapsignal(p, SIGILL, 0, ILL_BADSTK, sv);
- KERNEL_UNLOCK();
}
break;
@@ -475,9 +471,7 @@ 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 &&
@@ -496,9 +490,7 @@ dopanic:
ADVANCE;
break;
}
- KERNEL_LOCK();
trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv); /* XXX code? */
- KERNEL_UNLOCK();
break;
}
@@ -506,9 +498,7 @@ 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: {
@@ -559,9 +549,7 @@ 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 &&
@@ -572,9 +560,7 @@ dopanic:
if (emul_qf(ins.i_int, p, sv, tf))
ADVANCE;
} else {
- KERNEL_LOCK();
trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv);
- KERNEL_UNLOCK();
}
break;
}
@@ -617,9 +603,7 @@ 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:
@@ -654,22 +638,16 @@ 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:
@@ -685,25 +663,19 @@ 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;
}
out:
@@ -961,9 +933,7 @@ data_access_error(struct trapframe64 *tf, unsigned type, vaddr_t afva,
return;
}
- KERNEL_LOCK();
trapsignal(p, SIGSEGV, PROT_READ | PROT_WRITE, SEGV_MAPERR, sv);
- KERNEL_UNLOCK();
out:
if ((tstate & TSTATE_PRIV) == 0) {
@@ -1092,9 +1062,7 @@ text_access_error(struct trapframe64 *tf, unsigned type, vaddr_t pc,
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)
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 757507fedd3..6c1c0b5caa0 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sig.c,v 1.258 2020/06/15 13:18:33 visa Exp $ */
+/* $OpenBSD: kern_sig.c,v 1.259 2020/08/19 10:10:57 mpi Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
@@ -802,6 +802,7 @@ trapsignal(struct proc *p, int signum, u_long trapno, int code,
struct sigacts *ps = pr->ps_sigacts;
int mask;
+ KERNEL_LOCK();
switch (signum) {
case SIGILL:
case SIGBUS:
@@ -842,6 +843,7 @@ trapsignal(struct proc *p, int signum, u_long trapno, int code,
sigexit(p, signum);
ptsignal(p, signum, STHREAD);
}
+ KERNEL_UNLOCK();
}
/*