diff options
Diffstat (limited to 'arch/sh/kernel/signal_64.c')
-rw-r--r-- | arch/sh/kernel/signal_64.c | 82 |
1 files changed, 32 insertions, 50 deletions
diff --git a/arch/sh/kernel/signal_64.c b/arch/sh/kernel/signal_64.c index 23d4c71..897abe7 100644 --- a/arch/sh/kernel/signal_64.c +++ b/arch/sh/kernel/signal_64.c @@ -41,8 +41,7 @@ #define DEBUG_SIG 0 static void -handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, - struct pt_regs * regs); +handle_signal(struct ksignal *ksig, struct pt_regs *regs); static inline void handle_syscall_restart(struct pt_regs *regs, struct sigaction *sa) @@ -82,9 +81,7 @@ handle_syscall_restart(struct pt_regs *regs, struct sigaction *sa) */ static void do_signal(struct pt_regs *regs) { - siginfo_t info; - int signr; - struct k_sigaction ka; + struct ksignal ksig; /* * We want the common case to go fast, which @@ -95,12 +92,11 @@ static void do_signal(struct pt_regs *regs) if (!user_mode(regs)) return; - signr = get_signal_to_deliver(&info, &ka, regs, 0); - if (signr > 0) { - handle_syscall_restart(regs, &ka.sa); + if (get_signal(&ksig)) { + handle_syscall_restart(regs, &ksig.ka.sa); /* Whee! Actually deliver the signal. */ - handle_signal(signr, &info, &ka, regs); + handle_signal(&ksig, regs); return; } @@ -378,17 +374,16 @@ get_sigframe(struct k_sigaction *ka, unsigned long sp, size_t frame_size) void sa_default_restorer(void); /* See comments below */ void sa_default_rt_restorer(void); /* See comments below */ -static int setup_frame(int sig, struct k_sigaction *ka, - sigset_t *set, struct pt_regs *regs) +static int setup_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs) { struct sigframe __user *frame; - int err = 0; + int err = 0, sig = ksig->sig; int signal; - frame = get_sigframe(ka, regs->regs[REG_SP], sizeof(*frame)); + frame = get_sigframe(&ksig->ka, regs->regs[REG_SP], sizeof(*frame)); if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) - goto give_sigsegv; + return -EFAULT; signal = current_thread_info()->exec_domain && current_thread_info()->exec_domain->signal_invmap @@ -400,7 +395,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, /* Give up earlier as i386, in case */ if (err) - goto give_sigsegv; + return -EFAULT; if (_NSIG_WORDS > 1) { err |= __copy_to_user(frame->extramask, &set->sig[1], @@ -408,16 +403,16 @@ static int setup_frame(int sig, struct k_sigaction *ka, /* Give up earlier as i386, in case */ if (err) - 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 (ksig->ka.sa.sa_flags & SA_RESTORER) { /* * On SH5 all edited pointers are subject to NEFF */ DEREF_REG_PR = neff_sign_extend((unsigned long) - ka->sa.sa_restorer | 0x1); + ksig->ka->sa.sa_restorer | 0x1); } else { /* * Different approach on SH5. @@ -435,7 +430,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, if (__copy_to_user(frame->retcode, (void *)((unsigned long)sa_default_restorer & (~1)), 16) != 0) - goto give_sigsegv; + return -EFAULT; /* Cohere the trampoline with the I-cache. */ flush_cache_sigtramp(DEREF_REG_PR-1); @@ -460,7 +455,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, regs->regs[REG_ARG2] = (unsigned long long)(unsigned long)(signed long)&frame->sc; regs->regs[REG_ARG3] = (unsigned long long)(unsigned long)(signed long)&frame->sc; - regs->pc = neff_sign_extend((unsigned long)ka->sa.sa_handler); + regs->pc = neff_sign_extend((unsigned long)ksig->ka.sa.sa_handler); set_fs(USER_DS); @@ -471,23 +466,19 @@ static int setup_frame(int sig, struct k_sigaction *ka, DEREF_REG_PR >> 32, DEREF_REG_PR & 0xffffffff); return 0; - -give_sigsegv: - force_sigsegv(sig, current); - return -EFAULT; } -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 *kig, sigset_t *set, + struct pt_regs *regs) { struct rt_sigframe __user *frame; - int err = 0; + int err = 0, sig = ksig->sig; int signal; - frame = get_sigframe(ka, regs->regs[REG_SP], sizeof(*frame)); + frame = get_sigframe(&ksig->ka, regs->regs[REG_SP], sizeof(*frame)); if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) - goto give_sigsegv; + return -EFAULT; signal = current_thread_info()->exec_domain && current_thread_info()->exec_domain->signal_invmap @@ -497,11 +488,11 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, err |= __put_user(&frame->info, &frame->pinfo); err |= __put_user(&frame->uc, &frame->puc); - err |= copy_siginfo_to_user(&frame->info, info); + err |= copy_siginfo_to_user(&frame->info, &ksig->info); /* Give up earlier as i386, in case */ if (err) - goto give_sigsegv; + return -EFAULT; /* Create the ucontext. */ err |= __put_user(0, &frame->uc.uc_flags); @@ -513,16 +504,16 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, /* Give up earlier as i386, in case */ if (err) - 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 (ksig->ka.sa.sa_flags & SA_RESTORER) { /* * On SH5 all edited pointers are subject to NEFF */ DEREF_REG_PR = neff_sign_extend((unsigned long) - ka->sa.sa_restorer | 0x1); + ksig->ka.sa.sa_restorer | 0x1); } else { /* * Different approach on SH5. @@ -540,7 +531,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, if (__copy_to_user(frame->retcode, (void *)((unsigned long)sa_default_rt_restorer & (~1)), 16) != 0) - goto give_sigsegv; + return -EFAULT; /* Cohere the trampoline with the I-cache. */ flush_icache_range(DEREF_REG_PR-1, DEREF_REG_PR-1+15); @@ -554,7 +545,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, regs->regs[REG_ARG1] = signal; /* Arg for signal handler */ regs->regs[REG_ARG2] = (unsigned long long)(unsigned long)(signed long)&frame->info; regs->regs[REG_ARG3] = (unsigned long long)(unsigned long)(signed long)&frame->uc.uc_mcontext; - regs->pc = neff_sign_extend((unsigned long)ka->sa.sa_handler); + regs->pc = neff_sign_extend((unsigned long)ksig->ka.sa.sa_handler); set_fs(USER_DS); @@ -564,33 +555,24 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, DEREF_REG_PR >> 32, DEREF_REG_PR & 0xffffffff); return 0; - -give_sigsegv: - force_sigsegv(sig, current); - return -EFAULT; } /* * OK, we're invoking a handler */ static void -handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, - struct pt_regs * regs) +handle_signal(struct ksignal *ksig, struct pt_regs *regs) { sigset_t *oldset = sigmask_to_save(); int ret; /* 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 = 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)); } asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags) |