Commit 00554fa4 authored by Richard Weinberger's avatar Richard Weinberger Committed by Richard Weinberger

arm64: 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 f6dd2a3f
...@@ -24,22 +24,21 @@ ...@@ -24,22 +24,21 @@
extern const compat_ulong_t aarch32_sigret_code[6]; extern const compat_ulong_t aarch32_sigret_code[6];
int compat_setup_frame(int usig, struct k_sigaction *ka, sigset_t *set, int compat_setup_frame(int usig, struct ksignal *ksig, sigset_t *set,
struct pt_regs *regs); struct pt_regs *regs);
int compat_setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, int compat_setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set,
sigset_t *set, struct pt_regs *regs); struct pt_regs *regs);
void compat_setup_restart_syscall(struct pt_regs *regs); void compat_setup_restart_syscall(struct pt_regs *regs);
#else #else
static inline int compat_setup_frame(int usid, struct k_sigaction *ka, static inline int compat_setup_frame(int usid, struct ksignal *ksig,
sigset_t *set, struct pt_regs *regs) sigset_t *set, struct pt_regs *regs)
{ {
return -ENOSYS; return -ENOSYS;
} }
static inline int compat_setup_rt_frame(int usig, struct k_sigaction *ka, static inline int compat_setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set,
siginfo_t *info, sigset_t *set,
struct pt_regs *regs) struct pt_regs *regs)
{ {
return -ENOSYS; return -ENOSYS;
......
...@@ -253,13 +253,13 @@ static void setup_return(struct pt_regs *regs, struct k_sigaction *ka, ...@@ -253,13 +253,13 @@ static void setup_return(struct pt_regs *regs, struct k_sigaction *ka,
regs->regs[30] = (unsigned long)sigtramp; regs->regs[30] = (unsigned long)sigtramp;
} }
static int setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, static int setup_rt_frame(int usig, 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 err = 0; int err = 0;
frame = get_sigframe(ka, regs); frame = get_sigframe(&ksig->ka, regs);
if (!frame) if (!frame)
return 1; return 1;
...@@ -269,9 +269,9 @@ static int setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, ...@@ -269,9 +269,9 @@ static int setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
err |= __save_altstack(&frame->uc.uc_stack, regs->sp); err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
err |= setup_sigframe(frame, regs, set); err |= setup_sigframe(frame, regs, set);
if (err == 0) { if (err == 0) {
setup_return(regs, ka, frame, usig); setup_return(regs, &ksig->ka, frame, usig);
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);
regs->regs[1] = (unsigned long)&frame->info; regs->regs[1] = (unsigned long)&frame->info;
regs->regs[2] = (unsigned long)&frame->uc; regs->regs[2] = (unsigned long)&frame->uc;
} }
...@@ -291,13 +291,12 @@ static void setup_restart_syscall(struct pt_regs *regs) ...@@ -291,13 +291,12 @@ static void setup_restart_syscall(struct pt_regs *regs)
/* /*
* OK, we're invoking a handler * OK, we're invoking a handler
*/ */
static void handle_signal(unsigned long sig, struct k_sigaction *ka, static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
siginfo_t *info, struct pt_regs *regs)
{ {
struct thread_info *thread = current_thread_info(); struct thread_info *thread = current_thread_info();
struct task_struct *tsk = current; struct task_struct *tsk = current;
sigset_t *oldset = sigmask_to_save(); sigset_t *oldset = sigmask_to_save();
int usig = sig; int usig = ksig->sig;
int ret; int ret;
/* /*
...@@ -310,13 +309,12 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka, ...@@ -310,13 +309,12 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka,
* Set up the stack frame * Set up the stack frame
*/ */
if (is_compat_task()) { if (is_compat_task()) {
if (ka->sa.sa_flags & SA_SIGINFO) if (ksig->ka.sa.sa_flags & SA_SIGINFO)
ret = compat_setup_rt_frame(usig, ka, info, oldset, ret = compat_setup_rt_frame(usig, ksig, oldset, regs);
regs);
else else
ret = compat_setup_frame(usig, ka, oldset, regs); ret = compat_setup_frame(usig, ksig, oldset, regs);
} else { } else {
ret = setup_rt_frame(usig, ka, info, oldset, regs); ret = setup_rt_frame(usig, ksig, oldset, regs);
} }
/* /*
...@@ -324,18 +322,14 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka, ...@@ -324,18 +322,14 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka,
*/ */
ret |= !valid_user_regs(&regs->user_regs); ret |= !valid_user_regs(&regs->user_regs);
if (ret != 0) {
force_sigsegv(sig, tsk);
return;
}
/* /*
* Fast forward the stepping logic so we step into the signal * Fast forward the stepping logic so we step into the signal
* handler. * handler.
*/ */
user_fastforward_single_step(tsk); if (!ret)
user_fastforward_single_step(tsk);
signal_delivered(sig, info, ka, regs, 0); signal_setup_done(ret, ksig, 0);
} }
/* /*
...@@ -350,10 +344,9 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka, ...@@ -350,10 +344,9 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka,
static void do_signal(struct pt_regs *regs) static void do_signal(struct pt_regs *regs)
{ {
unsigned long continue_addr = 0, restart_addr = 0; unsigned long continue_addr = 0, restart_addr = 0;
struct k_sigaction ka; int retval = 0;
siginfo_t info;
int signr, retval = 0;
int syscall = (int)regs->syscallno; int syscall = (int)regs->syscallno;
struct ksignal ksig;
/* /*
* If we were from a system call, check for system call restarting... * If we were from a system call, check for system call restarting...
...@@ -387,8 +380,7 @@ static void do_signal(struct pt_regs *regs) ...@@ -387,8 +380,7 @@ static void do_signal(struct pt_regs *regs)
* Get the signal to deliver. When running under ptrace, at this point * Get the signal to deliver. When running under ptrace, at this point
* the debugger may change all of our registers. * the debugger may change all of our registers.
*/ */
signr = get_signal_to_deliver(&info, &ka, regs, NULL); if (get_signal(&ksig)) {
if (signr > 0) {
/* /*
* Depending on the signal settings, we may need to revert the * Depending on the signal settings, we may need to revert the
* decision to restart the system call, but skip this if a * decision to restart the system call, but skip this if a
...@@ -398,12 +390,12 @@ static void do_signal(struct pt_regs *regs) ...@@ -398,12 +390,12 @@ static void do_signal(struct pt_regs *regs)
(retval == -ERESTARTNOHAND || (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)))) {
regs->regs[0] = -EINTR; regs->regs[0] = -EINTR;
regs->pc = continue_addr; regs->pc = continue_addr;
} }
handle_signal(signr, &ka, &info, regs); handle_signal(&ksig, regs);
return; return;
} }
......
...@@ -520,18 +520,18 @@ static int compat_setup_sigframe(struct compat_sigframe __user *sf, ...@@ -520,18 +520,18 @@ static int compat_setup_sigframe(struct compat_sigframe __user *sf,
/* /*
* 32-bit signal handling routines called from signal.c * 32-bit signal handling routines called from signal.c
*/ */
int compat_setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, int compat_setup_rt_frame(int usig, struct ksignal *ksig,
sigset_t *set, struct pt_regs *regs) sigset_t *set, struct pt_regs *regs)
{ {
struct compat_rt_sigframe __user *frame; struct compat_rt_sigframe __user *frame;
int err = 0; int err = 0;
frame = compat_get_sigframe(ka, regs, sizeof(*frame)); frame = compat_get_sigframe(&ksig->ka, regs, sizeof(*frame));
if (!frame) if (!frame)
return 1; return 1;
err |= copy_siginfo_to_user32(&frame->info, info); err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
__put_user_error(0, &frame->sig.uc.uc_flags, err); __put_user_error(0, &frame->sig.uc.uc_flags, err);
__put_user_error(0, &frame->sig.uc.uc_link, err); __put_user_error(0, &frame->sig.uc.uc_link, err);
...@@ -541,7 +541,7 @@ int compat_setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, ...@@ -541,7 +541,7 @@ int compat_setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
err |= compat_setup_sigframe(&frame->sig, regs, set); err |= compat_setup_sigframe(&frame->sig, regs, set);
if (err == 0) { if (err == 0) {
compat_setup_return(regs, ka, frame->sig.retcode, frame, usig); compat_setup_return(regs, &ksig->ka, frame->sig.retcode, frame, usig);
regs->regs[1] = (compat_ulong_t)(unsigned long)&frame->info; regs->regs[1] = (compat_ulong_t)(unsigned long)&frame->info;
regs->regs[2] = (compat_ulong_t)(unsigned long)&frame->sig.uc; regs->regs[2] = (compat_ulong_t)(unsigned long)&frame->sig.uc;
} }
...@@ -549,13 +549,13 @@ int compat_setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, ...@@ -549,13 +549,13 @@ int compat_setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
return err; return err;
} }
int compat_setup_frame(int usig, struct k_sigaction *ka, sigset_t *set, int compat_setup_frame(int usig, struct ksignal *ksig, sigset_t *set,
struct pt_regs *regs) struct pt_regs *regs)
{ {
struct compat_sigframe __user *frame; struct compat_sigframe __user *frame;
int err = 0; int err = 0;
frame = compat_get_sigframe(ka, regs, sizeof(*frame)); frame = compat_get_sigframe(&ksig->ka, regs, sizeof(*frame));
if (!frame) if (!frame)
return 1; return 1;
...@@ -564,7 +564,7 @@ int compat_setup_frame(int usig, struct k_sigaction *ka, sigset_t *set, ...@@ -564,7 +564,7 @@ int compat_setup_frame(int usig, struct k_sigaction *ka, sigset_t *set,
err |= compat_setup_sigframe(frame, regs, set); err |= compat_setup_sigframe(frame, regs, set);
if (err == 0) if (err == 0)
compat_setup_return(regs, ka, frame->retcode, frame, usig); compat_setup_return(regs, &ksig->ka, frame->retcode, frame, usig);
return err; return err;
} }
......
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