sh: switch to saved_sigmask-based sigsuspend()/rt_sigsuspend()
Complete the move of sh64 to it, trim the crap from prototypes, tidy up a bit. Infrastructure in do_signal() had already been there, in signal_64 as well as in signal_32 (where it was already used). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Родитель
9ccc9c75c9
Коммит
9ef461adf9
|
@ -23,9 +23,7 @@ asmlinkage int sys_execve(const char __user *ufilename,
|
||||||
const char __user *const __user *uargv,
|
const char __user *const __user *uargv,
|
||||||
const char __user *const __user *uenvp,
|
const char __user *const __user *uenvp,
|
||||||
unsigned long r7, struct pt_regs __regs);
|
unsigned long r7, struct pt_regs __regs);
|
||||||
asmlinkage int sys_sigsuspend(old_sigset_t mask, unsigned long r5,
|
asmlinkage int sys_sigsuspend(old_sigset_t mask);
|
||||||
unsigned long r6, unsigned long r7,
|
|
||||||
struct pt_regs __regs);
|
|
||||||
asmlinkage int sys_sigaction(int sig, const struct old_sigaction __user *act,
|
asmlinkage int sys_sigaction(int sig, const struct old_sigaction __user *act,
|
||||||
struct old_sigaction __user *oact);
|
struct old_sigaction __user *oact);
|
||||||
asmlinkage int sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
|
asmlinkage int sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
||||||
# ifdef CONFIG_SUPERH32
|
# ifdef CONFIG_SUPERH32
|
||||||
|
|
||||||
# include "unistd_32.h"
|
# include "unistd_32.h"
|
||||||
# define __ARCH_WANT_SYS_RT_SIGSUSPEND
|
|
||||||
|
|
||||||
# else
|
# else
|
||||||
# include "unistd_64.h"
|
# include "unistd_64.h"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# define __ARCH_WANT_SYS_RT_SIGSUSPEND
|
||||||
# define __ARCH_WANT_IPC_PARSE_VERSION
|
# define __ARCH_WANT_IPC_PARSE_VERSION
|
||||||
# define __ARCH_WANT_OLD_READDIR
|
# define __ARCH_WANT_OLD_READDIR
|
||||||
# define __ARCH_WANT_OLD_STAT
|
# define __ARCH_WANT_OLD_STAT
|
||||||
|
|
|
@ -53,9 +53,7 @@ struct fdpic_func_descriptor {
|
||||||
* Atomically swap in the new signal mask, and wait for a signal.
|
* Atomically swap in the new signal mask, and wait for a signal.
|
||||||
*/
|
*/
|
||||||
asmlinkage int
|
asmlinkage int
|
||||||
sys_sigsuspend(old_sigset_t mask,
|
sys_sigsuspend(old_sigset_t mask)
|
||||||
unsigned long r5, unsigned long r6, unsigned long r7,
|
|
||||||
struct pt_regs __regs)
|
|
||||||
{
|
{
|
||||||
sigset_t blocked;
|
sigset_t blocked;
|
||||||
siginitset(&blocked, mask);
|
siginitset(&blocked, mask);
|
||||||
|
|
|
@ -83,11 +83,12 @@ handle_syscall_restart(struct pt_regs *regs, struct sigaction *sa)
|
||||||
* the kernel can handle, and then we build all the user-level signal handling
|
* the kernel can handle, and then we build all the user-level signal handling
|
||||||
* stack-frames in one go after that.
|
* stack-frames in one go after that.
|
||||||
*/
|
*/
|
||||||
static int do_signal(struct pt_regs *regs, sigset_t *oldset)
|
static void do_signal(struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
siginfo_t info;
|
siginfo_t info;
|
||||||
int signr;
|
int signr;
|
||||||
struct k_sigaction ka;
|
struct k_sigaction ka;
|
||||||
|
sigset_t *oldset;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We want the common case to go fast, which
|
* We want the common case to go fast, which
|
||||||
|
@ -96,11 +97,11 @@ static int do_signal(struct pt_regs *regs, sigset_t *oldset)
|
||||||
* if so.
|
* if so.
|
||||||
*/
|
*/
|
||||||
if (!user_mode(regs))
|
if (!user_mode(regs))
|
||||||
return 1;
|
return;
|
||||||
|
|
||||||
if (current_thread_info()->status & TS_RESTORE_SIGMASK)
|
if (current_thread_info()->status & TS_RESTORE_SIGMASK)
|
||||||
oldset = ¤t->saved_sigmask;
|
oldset = ¤t->saved_sigmask;
|
||||||
else if (!oldset)
|
else
|
||||||
oldset = ¤t->blocked;
|
oldset = ¤t->blocked;
|
||||||
|
|
||||||
signr = get_signal_to_deliver(&info, &ka, regs, 0);
|
signr = get_signal_to_deliver(&info, &ka, regs, 0);
|
||||||
|
@ -118,7 +119,7 @@ static int do_signal(struct pt_regs *regs, sigset_t *oldset)
|
||||||
|
|
||||||
tracehook_signal_handler(signr, &info, &ka, regs,
|
tracehook_signal_handler(signr, &info, &ka, regs,
|
||||||
test_thread_flag(TIF_SINGLESTEP));
|
test_thread_flag(TIF_SINGLESTEP));
|
||||||
return 1;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,71 +148,18 @@ static int do_signal(struct pt_regs *regs, sigset_t *oldset)
|
||||||
sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL);
|
sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Atomically swap in the new signal mask, and wait for a signal.
|
* Atomically swap in the new signal mask, and wait for a signal.
|
||||||
*/
|
*/
|
||||||
asmlinkage int
|
asmlinkage int
|
||||||
sys_sigsuspend(old_sigset_t mask,
|
sys_sigsuspend(old_sigset_t mask)
|
||||||
unsigned long r3, unsigned long r4, unsigned long r5,
|
|
||||||
unsigned long r6, unsigned long r7,
|
|
||||||
struct pt_regs * regs)
|
|
||||||
{
|
{
|
||||||
sigset_t saveset, blocked;
|
sigset_t blocked;
|
||||||
|
|
||||||
saveset = current->blocked;
|
|
||||||
|
|
||||||
mask &= _BLOCKABLE;
|
|
||||||
siginitset(&blocked, mask);
|
siginitset(&blocked, mask);
|
||||||
set_current_blocked(&blocked);
|
return sigsuspend(&blocked);
|
||||||
|
|
||||||
REF_REG_RET = -EINTR;
|
|
||||||
while (1) {
|
|
||||||
current->state = TASK_INTERRUPTIBLE;
|
|
||||||
schedule();
|
|
||||||
set_restore_sigmask();
|
|
||||||
regs->pc += 4; /* because sys_sigreturn decrements the pc */
|
|
||||||
if (do_signal(regs, &saveset)) {
|
|
||||||
/* pc now points at signal handler. Need to decrement
|
|
||||||
it because entry.S will increment it. */
|
|
||||||
regs->pc -= 4;
|
|
||||||
return -EINTR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
asmlinkage int
|
|
||||||
sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize,
|
|
||||||
unsigned long r4, unsigned long r5, unsigned long r6,
|
|
||||||
unsigned long r7,
|
|
||||||
struct pt_regs * regs)
|
|
||||||
{
|
|
||||||
sigset_t saveset, newset;
|
|
||||||
|
|
||||||
/* XXX: Don't preclude handling different sized sigset_t's. */
|
|
||||||
if (sigsetsize != sizeof(sigset_t))
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (copy_from_user(&newset, unewset, sizeof(newset)))
|
|
||||||
return -EFAULT;
|
|
||||||
sigdelsetmask(&newset, ~_BLOCKABLE);
|
|
||||||
saveset = current->blocked;
|
|
||||||
set_current_blocked(&newset);
|
|
||||||
|
|
||||||
REF_REG_RET = -EINTR;
|
|
||||||
while (1) {
|
|
||||||
current->state = TASK_INTERRUPTIBLE;
|
|
||||||
schedule();
|
|
||||||
regs->pc += 4; /* because sys_sigreturn decrements the pc */
|
|
||||||
if (do_signal(regs, &saveset)) {
|
|
||||||
/* pc now points at signal handler. Need to decrement
|
|
||||||
it because entry.S will increment it. */
|
|
||||||
regs->pc -= 4;
|
|
||||||
return -EINTR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
asmlinkage int
|
asmlinkage int
|
||||||
|
@ -732,7 +680,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
|
||||||
asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags)
|
asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags)
|
||||||
{
|
{
|
||||||
if (thread_info_flags & _TIF_SIGPENDING)
|
if (thread_info_flags & _TIF_SIGPENDING)
|
||||||
do_signal(regs, 0);
|
do_signal(regs);
|
||||||
|
|
||||||
if (thread_info_flags & _TIF_NOTIFY_RESUME) {
|
if (thread_info_flags & _TIF_NOTIFY_RESUME) {
|
||||||
clear_thread_flag(TIF_NOTIFY_RESUME);
|
clear_thread_flag(TIF_NOTIFY_RESUME);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче