m32r: Use get_signal() signal_setup_done()

Use the more generic functions get_signal() signal_setup_done()
for signal delivery.

Signed-off-by: Richard Weinberger <richard@nod.at>
This commit is contained in:
Richard Weinberger 2013-10-07 13:54:22 +02:00 committed by Richard Weinberger
parent 98c20309b9
commit 0f5bef660a

View File

@ -173,17 +173,17 @@ get_sigframe(struct k_sigaction *ka, unsigned long sp, size_t frame_size)
return (void __user *)((sp - frame_size) & -8ul); return (void __user *)((sp - frame_size) & -8ul);
} }
static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, static int setup_rt_frame(struct ksignal *ksig, sigset_t *set,
sigset_t *set, struct pt_regs *regs) struct pt_regs *regs)
{ {
struct rt_sigframe __user *frame; struct rt_sigframe __user *frame;
int err = 0; int err = 0;
int signal; int signal, sig = ksig->sig;
frame = get_sigframe(ka, regs->spu, sizeof(*frame)); frame = get_sigframe(&ksig->ka, regs->spu, sizeof(*frame));
if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
goto give_sigsegv; return -EFAULT;
signal = current_thread_info()->exec_domain signal = current_thread_info()->exec_domain
&& current_thread_info()->exec_domain->signal_invmap && current_thread_info()->exec_domain->signal_invmap
@ -193,13 +193,13 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
err |= __put_user(signal, &frame->sig); err |= __put_user(signal, &frame->sig);
if (err) if (err)
goto give_sigsegv; return -EFAULT;
err |= __put_user(&frame->info, &frame->pinfo); err |= __put_user(&frame->info, &frame->pinfo);
err |= __put_user(&frame->uc, &frame->puc); err |= __put_user(&frame->uc, &frame->puc);
err |= copy_siginfo_to_user(&frame->info, info); err |= copy_siginfo_to_user(&frame->info, &ksig->info);
if (err) if (err)
goto give_sigsegv; return -EFAULT;
/* Create the ucontext. */ /* Create the ucontext. */
err |= __put_user(0, &frame->uc.uc_flags); err |= __put_user(0, &frame->uc.uc_flags);
@ -208,17 +208,17 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, set->sig[0]); err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, set->sig[0]);
err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
if (err) if (err)
goto give_sigsegv; return -EFAULT;
/* Set up to return from userspace. */ /* Set up to return from userspace. */
regs->lr = (unsigned long)ka->sa.sa_restorer; regs->lr = (unsigned long)ksig->ka.sa.sa_restorer;
/* Set up registers for signal handler */ /* Set up registers for signal handler */
regs->spu = (unsigned long)frame; regs->spu = (unsigned long)frame;
regs->r0 = signal; /* Arg for signal handler */ regs->r0 = signal; /* Arg for signal handler */
regs->r1 = (unsigned long)&frame->info; regs->r1 = (unsigned long)&frame->info;
regs->r2 = (unsigned long)&frame->uc; regs->r2 = (unsigned long)&frame->uc;
regs->bpc = (unsigned long)ka->sa.sa_handler; regs->bpc = (unsigned long)ksig->ka.sa.sa_handler;
set_fs(USER_DS); set_fs(USER_DS);
@ -228,10 +228,6 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
#endif #endif
return 0; return 0;
give_sigsegv:
force_sigsegv(sig, current);
return -EFAULT;
} }
static int prev_insn(struct pt_regs *regs) static int prev_insn(struct pt_regs *regs)
@ -252,9 +248,10 @@ static int prev_insn(struct pt_regs *regs)
*/ */
static void static void
handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, handle_signal(struct ksignal *ksig, struct pt_regs *regs)
struct pt_regs *regs)
{ {
int ret;
/* Are we from a system call? */ /* Are we from a system call? */
if (regs->syscall_nr >= 0) { if (regs->syscall_nr >= 0) {
/* If so, check system call restarting.. */ /* If so, check system call restarting.. */
@ -265,7 +262,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
break; break;
case -ERESTARTSYS: case -ERESTARTSYS:
if (!(ka->sa.sa_flags & SA_RESTART)) { if (!(ksig->ka.sa.sa_flags & SA_RESTART)) {
regs->r0 = -EINTR; regs->r0 = -EINTR;
break; break;
} }
@ -278,10 +275,9 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
} }
/* Set up the stack frame */ /* Set up the stack frame */
if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs)) ret = setup_rt_frame(ksig, sigmask_to_save(), regs);
return;
signal_delivered(sig, info, ka, regs, 0); signal_setup_done(ret, ksig, 0);
} }
/* /*
@ -291,9 +287,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
*/ */
static void do_signal(struct pt_regs *regs) static void do_signal(struct pt_regs *regs)
{ {
siginfo_t info; struct ksignal ksig;
int signr;
struct k_sigaction ka;
/* /*
* We want the common case to go fast, which * We want the common case to go fast, which
@ -304,8 +298,7 @@ static void do_signal(struct pt_regs *regs)
if (!user_mode(regs)) if (!user_mode(regs))
return; return;
signr = get_signal_to_deliver(&info, &ka, regs, NULL); if (get_signal(&ksig)) {
if (signr > 0) {
/* Re-enable any watchpoints before delivering the /* Re-enable any watchpoints before delivering the
* signal to user space. The processor register will * signal to user space. The processor register will
* have been cleared if the watchpoint triggered * have been cleared if the watchpoint triggered
@ -313,7 +306,7 @@ static void do_signal(struct pt_regs *regs)
*/ */
/* Whee! Actually deliver the signal. */ /* Whee! Actually deliver the signal. */
handle_signal(signr, &ka, &info, regs); handle_signal(&ksig, regs);
return; return;
} }