Commit 5f50245b authored by Eric W. Biederman's avatar Eric W. Biederman

signal/alpha: Use send_sig_fault where appropriate

Filling in struct siginfo before calling send_sig_info a tedious and
error prone process, where once in a great while the wrong fields
are filled out, and siginfo has been inconsistently cleared.

Simplify this process by using the helper send_sig_fault.  Which
takes as a parameters all of the information it needs, ensures
all of the fiddly bits of filling in struct siginfo are done properly
and then calls send_sig_info.

In short about a 5 line reduction in code for every time send_sig_info
is called, which makes the calling function clearer.

Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: linux-alpha@vger.kernel.org
Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
parent e821fa42
...@@ -871,7 +871,6 @@ SYSCALL_DEFINE5(osf_setsysinfo, unsigned long, op, void __user *, buffer, ...@@ -871,7 +871,6 @@ SYSCALL_DEFINE5(osf_setsysinfo, unsigned long, op, void __user *, buffer,
send a signal. Old exceptions are not signaled. */ send a signal. Old exceptions are not signaled. */
fex = (exc >> IEEE_STATUS_TO_EXCSUM_SHIFT) & swcr; fex = (exc >> IEEE_STATUS_TO_EXCSUM_SHIFT) & swcr;
if (fex) { if (fex) {
siginfo_t info;
int si_code = FPE_FLTUNK; int si_code = FPE_FLTUNK;
if (fex & IEEE_TRAP_ENABLE_DNO) si_code = FPE_FLTUND; if (fex & IEEE_TRAP_ENABLE_DNO) si_code = FPE_FLTUND;
...@@ -881,12 +880,9 @@ SYSCALL_DEFINE5(osf_setsysinfo, unsigned long, op, void __user *, buffer, ...@@ -881,12 +880,9 @@ SYSCALL_DEFINE5(osf_setsysinfo, unsigned long, op, void __user *, buffer,
if (fex & IEEE_TRAP_ENABLE_DZE) si_code = FPE_FLTDIV; if (fex & IEEE_TRAP_ENABLE_DZE) si_code = FPE_FLTDIV;
if (fex & IEEE_TRAP_ENABLE_INV) si_code = FPE_FLTINV; if (fex & IEEE_TRAP_ENABLE_INV) si_code = FPE_FLTINV;
clear_siginfo(&info); send_sig_fault(SIGFPE, si_code,
info.si_signo = SIGFPE; (void __user *)NULL, /* FIXME */
info.si_errno = 0; 0, current);
info.si_code = si_code;
info.si_addr = NULL; /* FIXME */
send_sig_info(SIGFPE, &info, current);
} }
return 0; return 0;
} }
......
...@@ -219,15 +219,8 @@ do_sigreturn(struct sigcontext __user *sc) ...@@ -219,15 +219,8 @@ do_sigreturn(struct sigcontext __user *sc)
/* Send SIGTRAP if we're single-stepping: */ /* Send SIGTRAP if we're single-stepping: */
if (ptrace_cancel_bpt (current)) { if (ptrace_cancel_bpt (current)) {
siginfo_t info; send_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *) regs->pc, 0,
current);
clear_siginfo(&info);
info.si_signo = SIGTRAP;
info.si_errno = 0;
info.si_code = TRAP_BRKPT;
info.si_addr = (void __user *) regs->pc;
info.si_trapno = 0;
send_sig_info(SIGTRAP, &info, current);
} }
return; return;
...@@ -254,15 +247,8 @@ do_rt_sigreturn(struct rt_sigframe __user *frame) ...@@ -254,15 +247,8 @@ do_rt_sigreturn(struct rt_sigframe __user *frame)
/* Send SIGTRAP if we're single-stepping: */ /* Send SIGTRAP if we're single-stepping: */
if (ptrace_cancel_bpt (current)) { if (ptrace_cancel_bpt (current)) {
siginfo_t info; send_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *) regs->pc, 0,
current);
clear_siginfo(&info);
info.si_signo = SIGTRAP;
info.si_errno = 0;
info.si_code = TRAP_BRKPT;
info.si_addr = (void __user *) regs->pc;
info.si_trapno = 0;
send_sig_info(SIGTRAP, &info, current);
} }
return; return;
......
...@@ -213,7 +213,6 @@ do_entArith(unsigned long summary, unsigned long write_mask, ...@@ -213,7 +213,6 @@ do_entArith(unsigned long summary, unsigned long write_mask,
struct pt_regs *regs) struct pt_regs *regs)
{ {
long si_code = FPE_FLTINV; long si_code = FPE_FLTINV;
siginfo_t info;
if (summary & 1) { if (summary & 1) {
/* Software-completion summary bit is set, so try to /* Software-completion summary bit is set, so try to
...@@ -228,21 +227,14 @@ do_entArith(unsigned long summary, unsigned long write_mask, ...@@ -228,21 +227,14 @@ do_entArith(unsigned long summary, unsigned long write_mask,
} }
die_if_kernel("Arithmetic fault", regs, 0, NULL); die_if_kernel("Arithmetic fault", regs, 0, NULL);
clear_siginfo(&info); send_sig_fault(SIGFPE, si_code, (void __user *) regs->pc, 0, current);
info.si_signo = SIGFPE;
info.si_errno = 0;
info.si_code = si_code;
info.si_addr = (void __user *) regs->pc;
send_sig_info(SIGFPE, &info, current);
} }
asmlinkage void asmlinkage void
do_entIF(unsigned long type, struct pt_regs *regs) do_entIF(unsigned long type, struct pt_regs *regs)
{ {
siginfo_t info;
int signo, code; int signo, code;
clear_siginfo(&info);
if ((regs->ps & ~IPL_MAX) == 0) { if ((regs->ps & ~IPL_MAX) == 0) {
if (type == 1) { if (type == 1) {
const unsigned int *data const unsigned int *data
...@@ -272,31 +264,20 @@ do_entIF(unsigned long type, struct pt_regs *regs) ...@@ -272,31 +264,20 @@ do_entIF(unsigned long type, struct pt_regs *regs)
switch (type) { switch (type) {
case 0: /* breakpoint */ case 0: /* breakpoint */
info.si_signo = SIGTRAP;
info.si_errno = 0;
info.si_code = TRAP_BRKPT;
info.si_trapno = 0;
info.si_addr = (void __user *) regs->pc;
if (ptrace_cancel_bpt(current)) { if (ptrace_cancel_bpt(current)) {
regs->pc -= 4; /* make pc point to former bpt */ regs->pc -= 4; /* make pc point to former bpt */
} }
send_sig_info(SIGTRAP, &info, current); send_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->pc, 0,
current);
return; return;
case 1: /* bugcheck */ case 1: /* bugcheck */
info.si_signo = SIGTRAP; send_sig_fault(SIGTRAP, TRAP_UNK, (void __user *) regs->pc, 0,
info.si_errno = 0; current);
info.si_code = TRAP_UNK;
info.si_addr = (void __user *) regs->pc;
info.si_trapno = 0;
send_sig_info(SIGTRAP, &info, current);
return; return;
case 2: /* gentrap */ case 2: /* gentrap */
info.si_addr = (void __user *) regs->pc;
info.si_trapno = regs->r16;
switch ((long) regs->r16) { switch ((long) regs->r16) {
case GEN_INTOVF: case GEN_INTOVF:
signo = SIGFPE; signo = SIGFPE;
...@@ -354,11 +335,8 @@ do_entIF(unsigned long type, struct pt_regs *regs) ...@@ -354,11 +335,8 @@ do_entIF(unsigned long type, struct pt_regs *regs)
break; break;
} }
info.si_signo = signo; send_sig_fault(signo, code, (void __user *) regs->pc, regs->r16,
info.si_errno = 0; current);
info.si_code = code;
info.si_addr = (void __user *) regs->pc;
send_sig_info(signo, &info, current);
return; return;
case 4: /* opDEC */ case 4: /* opDEC */
...@@ -382,11 +360,9 @@ do_entIF(unsigned long type, struct pt_regs *regs) ...@@ -382,11 +360,9 @@ do_entIF(unsigned long type, struct pt_regs *regs)
if (si_code == 0) if (si_code == 0)
return; return;
if (si_code > 0) { if (si_code > 0) {
info.si_signo = SIGFPE; send_sig_fault(SIGFPE, si_code,
info.si_errno = 0; (void __user *) regs->pc, 0,
info.si_code = si_code; current);
info.si_addr = (void __user *) regs->pc;
send_sig_info(SIGFPE, &info, current);
return; return;
} }
} }
...@@ -411,11 +387,7 @@ do_entIF(unsigned long type, struct pt_regs *regs) ...@@ -411,11 +387,7 @@ do_entIF(unsigned long type, struct pt_regs *regs)
; ;
} }
info.si_signo = SIGILL; send_sig_fault(SIGILL, ILL_ILLOPC, (void __user *)regs->pc, 0, current);
info.si_errno = 0;
info.si_code = ILL_ILLOPC;
info.si_addr = (void __user *) regs->pc;
send_sig_info(SIGILL, &info, current);
} }
/* There is an ifdef in the PALcode in MILO that enables a /* There is an ifdef in the PALcode in MILO that enables a
...@@ -761,11 +733,9 @@ do_entUnaUser(void __user * va, unsigned long opcode, ...@@ -761,11 +733,9 @@ do_entUnaUser(void __user * va, unsigned long opcode,
unsigned long tmp1, tmp2, tmp3, tmp4; unsigned long tmp1, tmp2, tmp3, tmp4;
unsigned long fake_reg, *reg_addr = &fake_reg; unsigned long fake_reg, *reg_addr = &fake_reg;
siginfo_t info; int si_code;
long error; long error;
clear_siginfo(&info);
/* Check the UAC bits to decide what the user wants us to do /* Check the UAC bits to decide what the user wants us to do
with the unaliged access. */ with the unaliged access. */
...@@ -986,34 +956,27 @@ do_entUnaUser(void __user * va, unsigned long opcode, ...@@ -986,34 +956,27 @@ do_entUnaUser(void __user * va, unsigned long opcode,
give_sigsegv: give_sigsegv:
regs->pc -= 4; /* make pc point to faulting insn */ regs->pc -= 4; /* make pc point to faulting insn */
info.si_signo = SIGSEGV;
info.si_errno = 0;
/* We need to replicate some of the logic in mm/fault.c, /* We need to replicate some of the logic in mm/fault.c,
since we don't have access to the fault code in the since we don't have access to the fault code in the
exception handling return path. */ exception handling return path. */
if ((unsigned long)va >= TASK_SIZE) if ((unsigned long)va >= TASK_SIZE)
info.si_code = SEGV_ACCERR; si_code = SEGV_ACCERR;
else { else {
struct mm_struct *mm = current->mm; struct mm_struct *mm = current->mm;
down_read(&mm->mmap_sem); down_read(&mm->mmap_sem);
if (find_vma(mm, (unsigned long)va)) if (find_vma(mm, (unsigned long)va))
info.si_code = SEGV_ACCERR; si_code = SEGV_ACCERR;
else else
info.si_code = SEGV_MAPERR; si_code = SEGV_MAPERR;
up_read(&mm->mmap_sem); up_read(&mm->mmap_sem);
} }
info.si_addr = va; send_sig_fault(SIGSEGV, si_code, va, 0, current);
send_sig_info(SIGSEGV, &info, current);
return; return;
give_sigbus: give_sigbus:
regs->pc -= 4; regs->pc -= 4;
info.si_signo = SIGBUS; send_sig_fault(SIGBUS, BUS_ADRALN, va, 0, current);
info.si_errno = 0;
info.si_code = BUS_ADRALN;
info.si_addr = va;
send_sig_info(SIGBUS, &info, current);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment