Commit 720f36b9 authored by Richard Weinberger's avatar Richard Weinberger Committed by Richard Weinberger

frv: Use get_signal() signal_setup_done()

Use the more generic functions get_signal() signal_setup_done()
for signal delivery.
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent fa019772
...@@ -180,17 +180,17 @@ static inline void __user *get_sigframe(struct k_sigaction *ka, ...@@ -180,17 +180,17 @@ static inline void __user *get_sigframe(struct k_sigaction *ka,
/* /*
* *
*/ */
static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set) static int setup_frame(struct ksignal *ksig, sigset_t *set)
{ {
struct sigframe __user *frame; struct sigframe __user *frame;
int rsig; int rsig, sig = ksig->sig;
set_fs(USER_DS); set_fs(USER_DS);
frame = get_sigframe(ka, sizeof(*frame)); frame = get_sigframe(&ksig->ka, sizeof(*frame));
if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
goto give_sigsegv; return -EFAULT;
rsig = sig; rsig = sig;
if (sig < 32 && if (sig < 32 &&
...@@ -199,22 +199,22 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set) ...@@ -199,22 +199,22 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set)
rsig = __current_thread_info->exec_domain->signal_invmap[sig]; rsig = __current_thread_info->exec_domain->signal_invmap[sig];
if (__put_user(rsig, &frame->sig) < 0) if (__put_user(rsig, &frame->sig) < 0)
goto give_sigsegv; return -EFAULT;
if (setup_sigcontext(&frame->sc, set->sig[0])) if (setup_sigcontext(&frame->sc, set->sig[0]))
goto give_sigsegv; return -EFAULT;
if (_NSIG_WORDS > 1) { if (_NSIG_WORDS > 1) {
if (__copy_to_user(frame->extramask, &set->sig[1], if (__copy_to_user(frame->extramask, &set->sig[1],
sizeof(frame->extramask))) sizeof(frame->extramask)))
goto give_sigsegv; return -EFAULT;
} }
/* Set up to return from userspace. If provided, use a stub /* Set up to return from userspace. If provided, use a stub
* already in userspace. */ * already in userspace. */
if (ka->sa.sa_flags & SA_RESTORER) { if (ksig->ka.sa.sa_flags & SA_RESTORER) {
if (__put_user(ka->sa.sa_restorer, &frame->pretcode) < 0) if (__put_user(ksig->ka.sa.sa_restorer, &frame->pretcode) < 0)
goto give_sigsegv; return -EFAULT;
} }
else { else {
/* Set up the following code on the stack: /* Set up the following code on the stack:
...@@ -224,7 +224,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set) ...@@ -224,7 +224,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set)
if (__put_user((__sigrestore_t)frame->retcode, &frame->pretcode) || if (__put_user((__sigrestore_t)frame->retcode, &frame->pretcode) ||
__put_user(0x8efc0000|__NR_sigreturn, &frame->retcode[0]) || __put_user(0x8efc0000|__NR_sigreturn, &frame->retcode[0]) ||
__put_user(0xc0700000, &frame->retcode[1])) __put_user(0xc0700000, &frame->retcode[1]))
goto give_sigsegv; return -EFAULT;
flush_icache_range((unsigned long) frame->retcode, flush_icache_range((unsigned long) frame->retcode,
(unsigned long) (frame->retcode + 2)); (unsigned long) (frame->retcode + 2));
...@@ -233,14 +233,14 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set) ...@@ -233,14 +233,14 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set)
/* Set up registers for the signal handler */ /* Set up registers for the signal handler */
if (current->personality & FDPIC_FUNCPTRS) { if (current->personality & FDPIC_FUNCPTRS) {
struct fdpic_func_descriptor __user *funcptr = struct fdpic_func_descriptor __user *funcptr =
(struct fdpic_func_descriptor __user *) ka->sa.sa_handler; (struct fdpic_func_descriptor __user *) ksig->ka.sa.sa_handler;
struct fdpic_func_descriptor desc; struct fdpic_func_descriptor desc;
if (copy_from_user(&desc, funcptr, sizeof(desc))) if (copy_from_user(&desc, funcptr, sizeof(desc)))
goto give_sigsegv; return -EFAULT;
__frame->pc = desc.text; __frame->pc = desc.text;
__frame->gr15 = desc.GOT; __frame->gr15 = desc.GOT;
} else { } else {
__frame->pc = (unsigned long) ka->sa.sa_handler; __frame->pc = (unsigned long) ksig->ka.sa.sa_handler;
__frame->gr15 = 0; __frame->gr15 = 0;
} }
...@@ -255,29 +255,23 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set) ...@@ -255,29 +255,23 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set)
#endif #endif
return 0; return 0;
give_sigsegv:
force_sigsegv(sig, current);
return -EFAULT;
} /* end setup_frame() */ } /* end setup_frame() */
/*****************************************************************************/ /*****************************************************************************/
/* /*
* *
*/ */
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 rt_sigframe __user *frame; struct rt_sigframe __user *frame;
int rsig; int rsig, sig = ksig->sig;
set_fs(USER_DS); set_fs(USER_DS);
frame = get_sigframe(ka, sizeof(*frame)); frame = get_sigframe(&ksig->ka, sizeof(*frame));
if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
goto give_sigsegv; return -EFAULT;
rsig = sig; rsig = sig;
if (sig < 32 && if (sig < 32 &&
...@@ -288,28 +282,28 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -288,28 +282,28 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
if (__put_user(rsig, &frame->sig) || if (__put_user(rsig, &frame->sig) ||
__put_user(&frame->info, &frame->pinfo) || __put_user(&frame->info, &frame->pinfo) ||
__put_user(&frame->uc, &frame->puc)) __put_user(&frame->uc, &frame->puc))
goto give_sigsegv; return -EFAULT;
if (copy_siginfo_to_user(&frame->info, info)) if (copy_siginfo_to_user(&frame->info, &ksig->info))
goto give_sigsegv; return -EFAULT;
/* Create the ucontext. */ /* Create the ucontext. */
if (__put_user(0, &frame->uc.uc_flags) || if (__put_user(0, &frame->uc.uc_flags) ||
__put_user(NULL, &frame->uc.uc_link) || __put_user(NULL, &frame->uc.uc_link) ||
__save_altstack(&frame->uc.uc_stack, __frame->sp)) __save_altstack(&frame->uc.uc_stack, __frame->sp))
goto give_sigsegv; return -EFAULT;
if (setup_sigcontext(&frame->uc.uc_mcontext, set->sig[0])) if (setup_sigcontext(&frame->uc.uc_mcontext, set->sig[0]))
goto give_sigsegv; return -EFAULT;
if (__copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set))) if (__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 /* Set up to return from userspace. If provided, use a stub
* already in userspace. */ * already in userspace. */
if (ka->sa.sa_flags & SA_RESTORER) { if (ksig->ka.sa.sa_flags & SA_RESTORER) {
if (__put_user(ka->sa.sa_restorer, &frame->pretcode)) if (__put_user(ksig->ka.sa.sa_restorer, &frame->pretcode))
goto give_sigsegv; return -EFAULT;
} }
else { else {
/* Set up the following code on the stack: /* Set up the following code on the stack:
...@@ -319,7 +313,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -319,7 +313,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
if (__put_user((__sigrestore_t)frame->retcode, &frame->pretcode) || if (__put_user((__sigrestore_t)frame->retcode, &frame->pretcode) ||
__put_user(0x8efc0000|__NR_rt_sigreturn, &frame->retcode[0]) || __put_user(0x8efc0000|__NR_rt_sigreturn, &frame->retcode[0]) ||
__put_user(0xc0700000, &frame->retcode[1])) __put_user(0xc0700000, &frame->retcode[1]))
goto give_sigsegv; return -EFAULT;
flush_icache_range((unsigned long) frame->retcode, flush_icache_range((unsigned long) frame->retcode,
(unsigned long) (frame->retcode + 2)); (unsigned long) (frame->retcode + 2));
...@@ -328,14 +322,14 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -328,14 +322,14 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
/* Set up registers for signal handler */ /* Set up registers for signal handler */
if (current->personality & FDPIC_FUNCPTRS) { if (current->personality & FDPIC_FUNCPTRS) {
struct fdpic_func_descriptor __user *funcptr = struct fdpic_func_descriptor __user *funcptr =
(struct fdpic_func_descriptor __user *) ka->sa.sa_handler; (struct fdpic_func_descriptor __user *) ksig->ka.sa.sa_handler;
struct fdpic_func_descriptor desc; struct fdpic_func_descriptor desc;
if (copy_from_user(&desc, funcptr, sizeof(desc))) if (copy_from_user(&desc, funcptr, sizeof(desc)))
goto give_sigsegv; return -EFAULT;
__frame->pc = desc.text; __frame->pc = desc.text;
__frame->gr15 = desc.GOT; __frame->gr15 = desc.GOT;
} else { } else {
__frame->pc = (unsigned long) ka->sa.sa_handler; __frame->pc = (unsigned long) ksig->ka.sa.sa_handler;
__frame->gr15 = 0; __frame->gr15 = 0;
} }
...@@ -349,21 +343,15 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -349,21 +343,15 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
sig, current->comm, current->pid, frame, __frame->pc, sig, current->comm, current->pid, frame, __frame->pc,
frame->pretcode); frame->pretcode);
#endif #endif
return 0; return 0;
give_sigsegv:
force_sigsegv(sig, current);
return -EFAULT;
} /* end setup_rt_frame() */ } /* end setup_rt_frame() */
/*****************************************************************************/ /*****************************************************************************/
/* /*
* OK, we're invoking a handler * OK, we're invoking a handler
*/ */
static void handle_signal(unsigned long sig, siginfo_t *info, static void handle_signal(struct ksignal *ksig)
struct k_sigaction *ka)
{ {
sigset_t *oldset = sigmask_to_save(); sigset_t *oldset = sigmask_to_save();
int ret; int ret;
...@@ -378,7 +366,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info, ...@@ -378,7 +366,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info,
break; break;
case -ERESTARTSYS: case -ERESTARTSYS:
if (!(ka->sa.sa_flags & SA_RESTART)) { if (!(ksig->ka.sa.sa_flags & SA_RESTART)) {
__frame->gr8 = -EINTR; __frame->gr8 = -EINTR;
break; break;
} }
...@@ -392,16 +380,12 @@ static void handle_signal(unsigned long sig, siginfo_t *info, ...@@ -392,16 +380,12 @@ static void handle_signal(unsigned long sig, siginfo_t *info,
} }
/* Set up the stack frame */ /* Set up the stack frame */
if (ka->sa.sa_flags & SA_SIGINFO) if (ksig->ka.sa.sa_flags & SA_SIGINFO)
ret = setup_rt_frame(sig, ka, info, oldset); ret = setup_rt_frame(ksig, oldset);
else else
ret = setup_frame(sig, ka, oldset); ret = setup_frame(ksig, oldset);
if (ret)
return;
signal_delivered(sig, info, ka, __frame, signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLESTEP));
test_thread_flag(TIF_SINGLESTEP));
} /* end handle_signal() */ } /* end handle_signal() */
/*****************************************************************************/ /*****************************************************************************/
...@@ -412,13 +396,10 @@ static void handle_signal(unsigned long sig, siginfo_t *info, ...@@ -412,13 +396,10 @@ static void handle_signal(unsigned long sig, siginfo_t *info,
*/ */
static void do_signal(void) static void do_signal(void)
{ {
struct k_sigaction ka; struct ksignal ksig;
siginfo_t info;
int signr;
signr = get_signal_to_deliver(&info, &ka, __frame, NULL); if (get_signal(&ksig)) {
if (signr > 0) { handle_signal(&ksig);
handle_signal(signr, &info, &ka);
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