diff options
author | Richard Weinberger | 2013-10-07 14:22:50 +0200 |
---|---|---|
committer | Richard Weinberger | 2014-08-06 13:03:08 +0200 |
commit | 8b166553a9aaf39774bc22f5e93c965584303929 (patch) | |
tree | 2922e190eab7a7cfb729fa92b43278506f56c71f /arch/mn10300 | |
parent | 81d103bf80678669c56658185e758fc3f9845d71 (diff) |
mn10300: 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>
Diffstat (limited to 'arch/mn10300')
-rw-r--r-- | arch/mn10300/kernel/signal.c | 89 |
1 files changed, 36 insertions, 53 deletions
diff --git a/arch/mn10300/kernel/signal.c b/arch/mn10300/kernel/signal.c index 9dfac5cd16e6..0c97202764ce 100644 --- a/arch/mn10300/kernel/signal.c +++ b/arch/mn10300/kernel/signal.c @@ -207,16 +207,16 @@ static inline void __user *get_sigframe(struct k_sigaction *ka, /* * set up a normal signal frame */ -static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, +static int setup_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs) { struct sigframe __user *frame; - int rsig; + int rsig, sig = ksig->sig; - frame = get_sigframe(ka, regs, sizeof(*frame)); + frame = get_sigframe(&ksig->ka, regs, sizeof(*frame)); if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) - goto give_sigsegv; + return -EFAULT; rsig = sig; if (sig < 32 && @@ -226,40 +226,40 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, if (__put_user(rsig, &frame->sig) < 0 || __put_user(&frame->sc, &frame->psc) < 0) - goto give_sigsegv; + return -EFAULT; if (setup_sigcontext(&frame->sc, &frame->fpuctx, regs, set->sig[0])) - goto give_sigsegv; + return -EFAULT; if (_NSIG_WORDS > 1) { if (__copy_to_user(frame->extramask, &set->sig[1], sizeof(frame->extramask))) - goto give_sigsegv; + return -EFAULT; } /* set up to return from userspace. If provided, use a stub already in * userspace */ - if (ka->sa.sa_flags & SA_RESTORER) { - if (__put_user(ka->sa.sa_restorer, &frame->pretcode)) - goto give_sigsegv; + if (ksig->ka.sa.sa_flags & SA_RESTORER) { + if (__put_user(ksig->ka.sa.sa_restorer, &frame->pretcode)) + return -EFAULT; } else { if (__put_user((void (*)(void))frame->retcode, &frame->pretcode)) - goto give_sigsegv; + return -EFAULT; /* this is mov $,d0; syscall 0 */ if (__put_user(0x2c, (char *)(frame->retcode + 0)) || __put_user(__NR_sigreturn, (char *)(frame->retcode + 1)) || __put_user(0x00, (char *)(frame->retcode + 2)) || __put_user(0xf0, (char *)(frame->retcode + 3)) || __put_user(0xe0, (char *)(frame->retcode + 4))) - goto give_sigsegv; + return -EFAULT; flush_icache_range((unsigned long) frame->retcode, (unsigned long) frame->retcode + 5); } /* set up registers for signal handler */ regs->sp = (unsigned long) frame; - regs->pc = (unsigned long) ka->sa.sa_handler; + regs->pc = (unsigned long) ksig->ka.sa.sa_handler; regs->d0 = sig; regs->d1 = (unsigned long) &frame->sc; @@ -270,25 +270,21 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, #endif return 0; - -give_sigsegv: - force_sigsegv(sig, current); - return -EFAULT; } /* * set up a realtime signal frame */ -static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, - sigset_t *set, struct pt_regs *regs) +static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, + struct pt_regs *regs) { struct rt_sigframe __user *frame; - int rsig; + int rsig, sig = ksig->sig; - frame = get_sigframe(ka, regs, sizeof(*frame)); + frame = get_sigframe(&ksig->ka, regs, sizeof(*frame)); if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) - goto give_sigsegv; + return -EFAULT; rsig = sig; if (sig < 32 && @@ -299,8 +295,8 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, if (__put_user(rsig, &frame->sig) || __put_user(&frame->info, &frame->pinfo) || __put_user(&frame->uc, &frame->puc) || - copy_siginfo_to_user(&frame->info, info)) - goto give_sigsegv; + copy_siginfo_to_user(&frame->info, &ksig->info)) + return -EFAULT; /* create the ucontext. */ if (__put_user(0, &frame->uc.uc_flags) || @@ -309,13 +305,14 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, setup_sigcontext(&frame->uc.uc_mcontext, &frame->fpuctx, regs, set->sig[0]) || __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set))) - goto give_sigsegv; + return -EFAULT; /* set up to return from userspace. If provided, use a stub already in * userspace */ - if (ka->sa.sa_flags & SA_RESTORER) { - if (__put_user(ka->sa.sa_restorer, &frame->pretcode)) - goto give_sigsegv; + if (ksig->ka.sa.sa_flags & SA_RESTORER) { + if (__put_user(ksig->ka.sa.sa_restorer, &frame->pretcode)) + return -EFAULT; + } else { if (__put_user((void(*)(void))frame->retcode, &frame->pretcode) || @@ -326,7 +323,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, __put_user(0x00, (char *)(frame->retcode + 2)) || __put_user(0xf0, (char *)(frame->retcode + 3)) || __put_user(0xe0, (char *)(frame->retcode + 4))) - goto give_sigsegv; + return -EFAULT; flush_icache_range((u_long) frame->retcode, (u_long) frame->retcode + 5); @@ -334,7 +331,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, /* Set up registers for signal handler */ regs->sp = (unsigned long) frame; - regs->pc = (unsigned long) ka->sa.sa_handler; + regs->pc = (unsigned long) ksig->ka.sa.sa_handler; regs->d0 = sig; regs->d1 = (long) &frame->info; @@ -345,10 +342,6 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, #endif return 0; - -give_sigsegv: - force_sigsegv(sig, current); - return -EFAULT; } static inline void stepback(struct pt_regs *regs) @@ -360,9 +353,7 @@ static inline void stepback(struct pt_regs *regs) /* * handle the actual delivery of a signal to userspace */ -static int handle_signal(int sig, - siginfo_t *info, struct k_sigaction *ka, - struct pt_regs *regs) +static int handle_signal(struct ksignal *ksig, struct pt_regs *regs) { sigset_t *oldset = sigmask_to_save(); int ret; @@ -377,7 +368,7 @@ static int handle_signal(int sig, break; case -ERESTARTSYS: - if (!(ka->sa.sa_flags & SA_RESTART)) { + if (!(ksig->ka.sa.sa_flags & SA_RESTART)) { regs->d0 = -EINTR; break; } @@ -390,15 +381,12 @@ static int handle_signal(int sig, } /* Set up the stack frame */ - if (ka->sa.sa_flags & SA_SIGINFO) - ret = setup_rt_frame(sig, ka, info, oldset, regs); + if (ksig->ka.sa.sa_flags & SA_SIGINFO) + ret = setup_rt_frame(ksig, oldset, regs); else - ret = setup_frame(sig, ka, oldset, regs); - if (ret) - return ret; + ret = setup_frame(ksig, oldset, regs); - signal_delivered(sig, info, ka, regs, - test_thread_flag(TIF_SINGLESTEP)); + signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLESTEP)); return 0; } @@ -407,15 +395,10 @@ static int handle_signal(int sig, */ static void do_signal(struct pt_regs *regs) { - struct k_sigaction ka; - siginfo_t info; - int signr; - - signr = get_signal_to_deliver(&info, &ka, regs, NULL); - if (signr > 0) { - if (handle_signal(signr, &info, &ka, regs) == 0) { - } + struct ksignal ksig; + if (get_signal(&ksig)) { + handle_signal(&ksig, regs); return; } |