Taken from a larger diff from claudio@, this reduces the lock dances in MD code and put it where we should focus our effort in kern/kern_sig.c.
ok? Index: kern/kern_sig.c =================================================================== RCS file: /cvs/src/sys/kern/kern_sig.c,v retrieving revision 1.258 diff -u -p -r1.258 kern_sig.c --- kern/kern_sig.c 15 Jun 2020 13:18:33 -0000 1.258 +++ kern/kern_sig.c 18 Aug 2020 09:34:11 -0000 @@ -802,6 +802,7 @@ trapsignal(struct proc *p, int signum, u 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 sigexit(p, signum); ptsignal(p, signum, STHREAD); } + KERNEL_UNLOCK(); } /* Index: arch/alpha/alpha/trap.c =================================================================== RCS file: /cvs/src/sys/arch/alpha/alpha/trap.c,v retrieving revision 1.88 diff -u -p -r1.88 trap.c --- arch/alpha/alpha/trap.c 6 Sep 2019 12:22:01 -0000 1.88 +++ arch/alpha/alpha/trap.c 18 Aug 2020 09:18:54 -0000 @@ -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. */ Index: arch/amd64/amd64/trap.c =================================================================== RCS file: /cvs/src/sys/arch/amd64/amd64/trap.c,v retrieving revision 1.79 diff -u -p -r1.79 trap.c --- arch/amd64/amd64/trap.c 21 Jan 2020 03:06:39 -0000 1.79 +++ arch/amd64/amd64/trap.c 18 Aug 2020 09:18:54 -0000 @@ -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); Index: arch/arm/arm/fault.c =================================================================== RCS file: /cvs/src/sys/arch/arm/arm/fault.c,v retrieving revision 1.39 diff -u -p -r1.39 fault.c --- arch/arm/arm/fault.c 6 Sep 2019 12:22:01 -0000 1.39 +++ arch/arm/arm/fault.c 18 Aug 2020 09:18:54 -0000 @@ -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: Index: arch/arm/arm/undefined.c =================================================================== RCS file: /cvs/src/sys/arch/arm/arm/undefined.c,v retrieving revision 1.13 diff -u -p -r1.13 undefined.c --- arch/arm/arm/undefined.c 13 Mar 2019 09:28:21 -0000 1.13 +++ arch/arm/arm/undefined.c 18 Aug 2020 09:18:54 -0000 @@ -113,9 +113,7 @@ gdb_trapper(u_int addr, u_int insn, stru 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) Index: arch/arm64/arm64/trap.c =================================================================== RCS file: /cvs/src/sys/arch/arm64/arm64/trap.c,v retrieving revision 1.28 diff -u -p -r1.28 trap.c --- arch/arm64/arm64/trap.c 17 Aug 2020 08:09:03 -0000 1.28 +++ arch/arm64/arm64/trap.c 18 Aug 2020 09:18:54 -0000 @@ -97,9 +97,7 @@ data_abort(struct trapframe *frame, uint 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, uint } 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, Index: arch/hppa/hppa/trap.c =================================================================== RCS file: /cvs/src/sys/arch/hppa/hppa/trap.c,v retrieving revision 1.146 diff -u -p -r1.146 trap.c --- arch/hppa/hppa/trap.c 6 Sep 2019 12:22:01 -0000 1.146 +++ arch/hppa/hppa/trap.c 18 Aug 2020 09:38:58 -0000 @@ -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 */ Index: arch/i386/i386/trap.c =================================================================== RCS file: /cvs/src/sys/arch/i386/i386/trap.c,v retrieving revision 1.142 diff -u -p -r1.142 trap.c --- arch/i386/i386/trap.c 8 Dec 2019 12:25:30 -0000 1.142 +++ arch/i386/i386/trap.c 18 Aug 2020 09:40:31 -0000 @@ -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 Index: arch/i386/isa/npx.c =================================================================== RCS file: /cvs/src/sys/arch/i386/isa/npx.c,v retrieving revision 1.70 diff -u -p -r1.70 npx.c --- arch/i386/isa/npx.c 30 Jul 2018 14:19:12 -0000 1.70 +++ arch/i386/isa/npx.c 18 Aug 2020 09:18:54 -0000 @@ -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 Index: arch/m88k/m88k/m88100_fp.c =================================================================== RCS file: /cvs/src/sys/arch/m88k/m88k/m88100_fp.c,v retrieving revision 1.4 diff -u -p -r1.4 m88100_fp.c --- arch/m88k/m88k/m88100_fp.c 8 Sep 2017 05:36:52 -0000 1.4 +++ arch/m88k/m88k/m88100_fp.c 18 Aug 2020 09:32:18 -0000 @@ -464,8 +464,6 @@ m88100_fpu_checksig(struct trapframe *fr } sv.sival_ptr = (void *)(frame->tf_sxip & XIP_ADDR); - KERNEL_LOCK(); trapsignal(p, sig, 0, fault_type, sv); - KERNEL_UNLOCK(); } } Index: arch/m88k/m88k/m88110_fp.c =================================================================== RCS file: /cvs/src/sys/arch/m88k/m88k/m88110_fp.c,v retrieving revision 1.11 diff -u -p -r1.11 m88110_fp.c --- arch/m88k/m88k/m88110_fp.c 8 Sep 2017 05:36:52 -0000 1.11 +++ arch/m88k/m88k/m88110_fp.c 18 Aug 2020 09:18:54 -0000 @@ -166,9 +166,7 @@ m88110_fpu_exception(struct trapframe *f deliver: sv.sival_ptr = (void *)fault_addr; - KERNEL_LOCK(); trapsignal(p, sig, 0, fault_type, sv); - KERNEL_UNLOCK(); } } Index: arch/m88k/m88k/trap.c =================================================================== RCS file: /cvs/src/sys/arch/m88k/m88k/trap.c,v retrieving revision 1.111 diff -u -p -r1.111 trap.c --- arch/m88k/m88k/trap.c 11 Dec 2019 07:21:40 -0000 1.111 +++ arch/m88k/m88k/trap.c 18 Aug 2020 09:18:54 -0000 @@ -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: Index: arch/mips64/mips64/fp_emulate.c =================================================================== RCS file: /cvs/src/sys/arch/mips64/mips64/fp_emulate.c,v retrieving revision 1.22 diff -u -p -r1.22 fp_emulate.c --- arch/mips64/mips64/fp_emulate.c 14 Jan 2019 15:02:57 -0000 1.22 +++ arch/mips64/mips64/fp_emulate.c 18 Aug 2020 09:18:54 -0000 @@ -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(); } } Index: arch/mips64/mips64/trap.c =================================================================== RCS file: /cvs/src/sys/arch/mips64/mips64/trap.c,v retrieving revision 1.145 diff -u -p -r1.145 trap.c --- arch/mips64/mips64/trap.c 23 May 2020 07:18:50 -0000 1.145 +++ arch/mips64/mips64/trap.c 18 Aug 2020 09:18:54 -0000 @@ -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 Index: arch/powerpc/powerpc/trap.c =================================================================== RCS file: /cvs/src/sys/arch/powerpc/powerpc/trap.c,v retrieving revision 1.114 diff -u -p -r1.114 trap.c --- arch/powerpc/powerpc/trap.c 6 Sep 2019 13:45:04 -0000 1.114 +++ arch/powerpc/powerpc/trap.c 18 Aug 2020 09:41:14 -0000 @@ -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: Index: arch/powerpc64/powerpc64/trap.c =================================================================== RCS file: /cvs/src/sys/arch/powerpc64/powerpc64/trap.c,v retrieving revision 1.34 diff -u -p -r1.34 trap.c --- arch/powerpc64/powerpc64/trap.c 23 Jul 2020 16:01:08 -0000 1.34 +++ arch/powerpc64/powerpc64/trap.c 18 Aug 2020 09:32:44 -0000 @@ -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: Index: arch/sparc64/fpu/fpu.c =================================================================== RCS file: /cvs/src/sys/arch/sparc64/fpu/fpu.c,v retrieving revision 1.20 diff -u -p -r1.20 fpu.c --- arch/sparc64/fpu/fpu.c 21 Jan 2017 05:42:03 -0000 1.20 +++ arch/sparc64/fpu/fpu.c 18 Aug 2020 09:18:54 -0000 @@ -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: Index: arch/sparc64/sparc64/emul.c =================================================================== RCS file: /cvs/src/sys/arch/sparc64/sparc64/emul.c,v retrieving revision 1.24 diff -u -p -r1.24 emul.c --- arch/sparc64/sparc64/emul.c 8 Aug 2018 08:42:49 -0000 1.24 +++ arch/sparc64/sparc64/emul.c 18 Aug 2020 09:18:54 -0000 @@ -306,9 +306,7 @@ emul_qf(int32_t insv, struct proc *p, un 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, un 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, un return (1); segv: - KERNEL_LOCK(); trapsignal(p, SIGSEGV, isload ? PROT_READ : PROT_WRITE, SEGV_MAPERR, sv); - KERNEL_UNLOCK(); return (0); } Index: arch/sparc64/sparc64/trap.c =================================================================== RCS file: /cvs/src/sys/arch/sparc64/sparc64/trap.c,v retrieving revision 1.102 diff -u -p -r1.102 trap.c --- arch/sparc64/sparc64/trap.c 6 Sep 2019 12:22:01 -0000 1.102 +++ arch/sparc64/sparc64/trap.c 18 Aug 2020 09:33:46 -0000 @@ -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 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 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)