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>
This commit is contained in:
parent
81d103bf80
commit
8b166553a9
|
@ -207,16 +207,16 @@ static inline void __user *get_sigframe(struct k_sigaction *ka,
|
||||||
/*
|
/*
|
||||||
* set up a normal signal frame
|
* 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 pt_regs *regs)
|
||||||
{
|
{
|
||||||
struct sigframe __user *frame;
|
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)))
|
if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
|
||||||
goto give_sigsegv;
|
return -EFAULT;
|
||||||
|
|
||||||
rsig = sig;
|
rsig = sig;
|
||||||
if (sig < 32 &&
|
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 ||
|
if (__put_user(rsig, &frame->sig) < 0 ||
|
||||||
__put_user(&frame->sc, &frame->psc) < 0)
|
__put_user(&frame->sc, &frame->psc) < 0)
|
||||||
goto give_sigsegv;
|
return -EFAULT;
|
||||||
|
|
||||||
if (setup_sigcontext(&frame->sc, &frame->fpuctx, regs, set->sig[0]))
|
if (setup_sigcontext(&frame->sc, &frame->fpuctx, regs, 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 already in
|
/* set up to return from userspace. If provided, use a stub already in
|
||||||
* userspace */
|
* 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 {
|
||||||
if (__put_user((void (*)(void))frame->retcode,
|
if (__put_user((void (*)(void))frame->retcode,
|
||||||
&frame->pretcode))
|
&frame->pretcode))
|
||||||
goto give_sigsegv;
|
return -EFAULT;
|
||||||
/* this is mov $,d0; syscall 0 */
|
/* this is mov $,d0; syscall 0 */
|
||||||
if (__put_user(0x2c, (char *)(frame->retcode + 0)) ||
|
if (__put_user(0x2c, (char *)(frame->retcode + 0)) ||
|
||||||
__put_user(__NR_sigreturn, (char *)(frame->retcode + 1)) ||
|
__put_user(__NR_sigreturn, (char *)(frame->retcode + 1)) ||
|
||||||
__put_user(0x00, (char *)(frame->retcode + 2)) ||
|
__put_user(0x00, (char *)(frame->retcode + 2)) ||
|
||||||
__put_user(0xf0, (char *)(frame->retcode + 3)) ||
|
__put_user(0xf0, (char *)(frame->retcode + 3)) ||
|
||||||
__put_user(0xe0, (char *)(frame->retcode + 4)))
|
__put_user(0xe0, (char *)(frame->retcode + 4)))
|
||||||
goto give_sigsegv;
|
return -EFAULT;
|
||||||
flush_icache_range((unsigned long) frame->retcode,
|
flush_icache_range((unsigned long) frame->retcode,
|
||||||
(unsigned long) frame->retcode + 5);
|
(unsigned long) frame->retcode + 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set up registers for signal handler */
|
/* set up registers for signal handler */
|
||||||
regs->sp = (unsigned long) frame;
|
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->d0 = sig;
|
||||||
regs->d1 = (unsigned long) &frame->sc;
|
regs->d1 = (unsigned long) &frame->sc;
|
||||||
|
|
||||||
|
@ -270,25 +270,21 @@ 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* set up a realtime signal frame
|
* set up a realtime signal 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 pt_regs *regs)
|
struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
struct rt_sigframe __user *frame;
|
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)))
|
if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
|
||||||
goto give_sigsegv;
|
return -EFAULT;
|
||||||
|
|
||||||
rsig = sig;
|
rsig = sig;
|
||||||
if (sig < 32 &&
|
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) ||
|
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) ||
|
||||||
copy_siginfo_to_user(&frame->info, info))
|
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) ||
|
||||||
|
@ -309,13 +305,14 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
|
||||||
setup_sigcontext(&frame->uc.uc_mcontext,
|
setup_sigcontext(&frame->uc.uc_mcontext,
|
||||||
&frame->fpuctx, regs, set->sig[0]) ||
|
&frame->fpuctx, regs, set->sig[0]) ||
|
||||||
__copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)))
|
__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
|
/* set up to return from userspace. If provided, use a stub already in
|
||||||
* userspace */
|
* 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 {
|
||||||
if (__put_user((void(*)(void))frame->retcode,
|
if (__put_user((void(*)(void))frame->retcode,
|
||||||
&frame->pretcode) ||
|
&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(0x00, (char *)(frame->retcode + 2)) ||
|
||||||
__put_user(0xf0, (char *)(frame->retcode + 3)) ||
|
__put_user(0xf0, (char *)(frame->retcode + 3)) ||
|
||||||
__put_user(0xe0, (char *)(frame->retcode + 4)))
|
__put_user(0xe0, (char *)(frame->retcode + 4)))
|
||||||
goto give_sigsegv;
|
return -EFAULT;
|
||||||
|
|
||||||
flush_icache_range((u_long) frame->retcode,
|
flush_icache_range((u_long) frame->retcode,
|
||||||
(u_long) frame->retcode + 5);
|
(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 */
|
/* Set up registers for signal handler */
|
||||||
regs->sp = (unsigned long) frame;
|
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->d0 = sig;
|
||||||
regs->d1 = (long) &frame->info;
|
regs->d1 = (long) &frame->info;
|
||||||
|
|
||||||
|
@ -345,10 +342,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 inline void stepback(struct pt_regs *regs)
|
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
|
* handle the actual delivery of a signal to userspace
|
||||||
*/
|
*/
|
||||||
static int handle_signal(int sig,
|
static int handle_signal(struct ksignal *ksig, struct pt_regs *regs)
|
||||||
siginfo_t *info, struct k_sigaction *ka,
|
|
||||||
struct pt_regs *regs)
|
|
||||||
{
|
{
|
||||||
sigset_t *oldset = sigmask_to_save();
|
sigset_t *oldset = sigmask_to_save();
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -377,7 +368,7 @@ static int handle_signal(int sig,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case -ERESTARTSYS:
|
case -ERESTARTSYS:
|
||||||
if (!(ka->sa.sa_flags & SA_RESTART)) {
|
if (!(ksig->ka.sa.sa_flags & SA_RESTART)) {
|
||||||
regs->d0 = -EINTR;
|
regs->d0 = -EINTR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -390,15 +381,12 @@ static int handle_signal(int sig,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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, regs);
|
ret = setup_rt_frame(ksig, oldset, regs);
|
||||||
else
|
else
|
||||||
ret = setup_frame(sig, ka, oldset, regs);
|
ret = setup_frame(ksig, oldset, regs);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
signal_delivered(sig, info, ka, regs,
|
signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLESTEP));
|
||||||
test_thread_flag(TIF_SINGLESTEP));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,15 +395,10 @@ static int handle_signal(int sig,
|
||||||
*/
|
*/
|
||||||
static void do_signal(struct pt_regs *regs)
|
static void do_signal(struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
struct k_sigaction ka;
|
struct ksignal ksig;
|
||||||
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) {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (get_signal(&ksig)) {
|
||||||
|
handle_signal(&ksig, regs);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue