Commit 548dafe8 authored by Richard Weinberger's avatar Richard Weinberger Committed by Jonas Bonn

openrisc: 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>
Signed-off-by: default avatarJonas Bonn <jonas@southpole.se>
parent 10f67dbf
...@@ -166,20 +166,21 @@ static inline void __user *get_sigframe(struct k_sigaction *ka, ...@@ -166,20 +166,21 @@ static inline void __user *get_sigframe(struct k_sigaction *ka,
* trampoline which performs the syscall sigreturn, or a provided * trampoline which performs the syscall sigreturn, or a provided
* user-mode trampoline. * user-mode trampoline.
*/ */
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 *frame; struct rt_sigframe *frame;
unsigned long return_ip; unsigned long return_ip;
int err = 0; int err = 0;
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;
/* Create siginfo. */ /* Create siginfo. */
if (ka->sa.sa_flags & SA_SIGINFO) if (ksig->ka.sa.sa_flags & SA_SIGINFO)
err |= copy_siginfo_to_user(&frame->info, info); err |= copy_siginfo_to_user(&frame->info, &ksig->info);
/* Create the ucontext. */ /* Create the ucontext. */
err |= __put_user(0, &frame->uc.uc_flags); err |= __put_user(0, &frame->uc.uc_flags);
...@@ -190,7 +191,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -190,7 +191,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
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;
/* trampoline - the desired return ip is the retcode itself */ /* trampoline - the desired return ip is the retcode itself */
return_ip = (unsigned long)&frame->retcode; return_ip = (unsigned long)&frame->retcode;
...@@ -204,14 +205,14 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -204,14 +205,14 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
err |= __put_user(0x15000000, (unsigned long *)(frame->retcode + 8)); err |= __put_user(0x15000000, (unsigned long *)(frame->retcode + 8));
if (err) if (err)
goto give_sigsegv; return -EFAULT;
/* TODO what is the current->exec_domain stuff and invmap ? */ /* TODO what is the current->exec_domain stuff and invmap ? */
/* Set up registers for signal handler */ /* Set up registers for signal handler */
regs->pc = (unsigned long)ka->sa.sa_handler; /* what we enter NOW */ regs->pc = (unsigned long)ksig->ka.sa.sa_handler; /* what we enter NOW */
regs->gpr[9] = (unsigned long)return_ip; /* what we enter LATER */ regs->gpr[9] = (unsigned long)return_ip; /* what we enter LATER */
regs->gpr[3] = (unsigned long)sig; /* arg 1: signo */ regs->gpr[3] = (unsigned long)ksig->sig; /* arg 1: signo */
regs->gpr[4] = (unsigned long)&frame->info; /* arg 2: (siginfo_t*) */ regs->gpr[4] = (unsigned long)&frame->info; /* arg 2: (siginfo_t*) */
regs->gpr[5] = (unsigned long)&frame->uc; /* arg 3: ucontext */ regs->gpr[5] = (unsigned long)&frame->uc; /* arg 3: ucontext */
...@@ -219,25 +220,16 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -219,25 +220,16 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
regs->sp = (unsigned long)frame; regs->sp = (unsigned long)frame;
return 0; return 0;
give_sigsegv:
force_sigsegv(sig, current);
return -EFAULT;
} }
static inline void static inline void
handle_signal(unsigned long sig, handle_signal(struct ksignal *ksig, struct pt_regs *regs)
siginfo_t *info, struct k_sigaction *ka,
struct pt_regs *regs)
{ {
int ret; int ret;
ret = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs); ret = setup_rt_frame(ksig, sigmask_to_save(), regs);
if (ret)
return;
signal_delivered(sig, info, ka, regs, signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLESTEP));
test_thread_flag(TIF_SINGLESTEP));
} }
/* /*
...@@ -254,9 +246,7 @@ handle_signal(unsigned long sig, ...@@ -254,9 +246,7 @@ handle_signal(unsigned long sig,
int do_signal(struct pt_regs *regs, int syscall) int do_signal(struct pt_regs *regs, int syscall)
{ {
siginfo_t info; struct ksignal ksig;
int signr;
struct k_sigaction ka;
unsigned long continue_addr = 0; unsigned long continue_addr = 0;
unsigned long restart_addr = 0; unsigned long restart_addr = 0;
unsigned long retval = 0; unsigned long retval = 0;
...@@ -286,28 +276,23 @@ int do_signal(struct pt_regs *regs, int syscall) ...@@ -286,28 +276,23 @@ int do_signal(struct pt_regs *regs, int syscall)
} }
/* /*
* Get the signal to deliver. When running under ptrace, at this * Get the signal to deliver. During the call to get_signal the
* point the debugger may change all our registers ... * debugger may change all our registers so we may need to revert
* the decision to restart the syscall; specifically, if the PC is
* changed, don't restart the syscall.
*/ */
signr = get_signal_to_deliver(&info, &ka, regs, NULL); if (get_signal(&ksig)) {
/*
* Depending on the signal settings we may need to revert the
* decision to restart the system call. But skip this if a
* debugger has chosen to restart at a different PC.
*/
if (signr > 0) {
if (unlikely(restart) && regs->pc == restart_addr) { if (unlikely(restart) && regs->pc == restart_addr) {
if (retval == -ERESTARTNOHAND || if (retval == -ERESTARTNOHAND ||
retval == -ERESTART_RESTARTBLOCK retval == -ERESTART_RESTARTBLOCK
|| (retval == -ERESTARTSYS || (retval == -ERESTARTSYS
&& !(ka.sa.sa_flags & SA_RESTART))) { && !(ksig.ka.sa.sa_flags & SA_RESTART))) {
/* No automatic restart */ /* No automatic restart */
regs->gpr[11] = -EINTR; regs->gpr[11] = -EINTR;
regs->pc = continue_addr; regs->pc = continue_addr;
} }
} }
handle_signal(&ksig, regs);
handle_signal(signr, &info, &ka, regs);
} else { } else {
/* no handler */ /* no handler */
restore_saved_sigmask(); restore_saved_sigmask();
......
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