Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 18976
b: refs/heads/master
c: a411aee
h: refs/heads/master
v: v3
  • Loading branch information
David Howells authored and Linus Torvalds committed Jan 19, 2006
1 parent 569a8e4 commit 6314f9a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 77 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 150256d8aadb3a337c31efa9e175cbd25bf06b06
refs/heads/master: a411aee96ea7fe6fe065df65bf29ea755bcdb554
120 changes: 44 additions & 76 deletions trunk/arch/frv/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,74 +35,22 @@ struct fdpic_func_descriptor {
unsigned long GOT;
};

static int do_signal(sigset_t *oldset);

/*
* Atomically swap in the new signal mask, and wait for a signal.
*/
asmlinkage int sys_sigsuspend(int history0, int history1, old_sigset_t mask)
{
sigset_t saveset;

mask &= _BLOCKABLE;
spin_lock_irq(&current->sighand->siglock);
saveset = current->blocked;
current->saved_sigmask = current->blocked;
siginitset(&current->blocked, mask);
recalc_sigpending();
spin_unlock_irq(&current->sighand->siglock);

__frame->gr8 = -EINTR;
while (1) {
current->state = TASK_INTERRUPTIBLE;
schedule();
if (do_signal(&saveset))
/* return the signal number as the return value of this function
* - this is an utterly evil hack. syscalls should not invoke do_signal()
* as entry.S sets regs->gr8 to the return value of the system call
* - we can't just use sigpending() as we'd have to discard SIG_IGN signals
* and call waitpid() if SIGCHLD needed discarding
* - this only works on the i386 because it passes arguments to the signal
* handler on the stack, and the return value in EAX is effectively
* discarded
*/
return __frame->gr8;
}
}

asmlinkage int sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize)
{
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);

spin_lock_irq(&current->sighand->siglock);
saveset = current->blocked;
current->blocked = newset;
recalc_sigpending();
spin_unlock_irq(&current->sighand->siglock);

__frame->gr8 = -EINTR;
while (1) {
current->state = TASK_INTERRUPTIBLE;
schedule();
if (do_signal(&saveset))
/* return the signal number as the return value of this function
* - this is an utterly evil hack. syscalls should not invoke do_signal()
* as entry.S sets regs->gr8 to the return value of the system call
* - we can't just use sigpending() as we'd have to discard SIG_IGN signals
* and call waitpid() if SIGCHLD needed discarding
* - this only works on the i386 because it passes arguments to the signal
* handler on the stack, and the return value in EAX is effectively
* discarded
*/
return __frame->gr8;
}
current->state = TASK_INTERRUPTIBLE;
schedule();
set_thread_flag(TIF_RESTORE_SIGMASK);
return -ERESTARTNOHAND;
}

asmlinkage int sys_sigaction(int sig,
Expand Down Expand Up @@ -372,11 +320,11 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set)
frame->pretcode);
#endif

return 1;
return 0;

give_sigsegv:
force_sig(SIGSEGV, current);
return 0;
return -EFAULT;

} /* end setup_frame() */

Expand Down Expand Up @@ -471,11 +419,11 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
frame->pretcode);
#endif

return 1;
return 0;

give_sigsegv:
force_sig(SIGSEGV, current);
return 0;
return -EFAULT;

} /* end setup_rt_frame() */

Expand Down Expand Up @@ -516,7 +464,7 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
else
ret = setup_frame(sig, ka, oldset);

if (ret) {
if (ret == 0) {
spin_lock_irq(&current->sighand->siglock);
sigorsets(&current->blocked, &current->blocked,
&ka->sa.sa_mask);
Expand All @@ -536,10 +484,11 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
* want to handle. Thus you cannot kill init even with a SIGKILL even by
* mistake.
*/
static int do_signal(sigset_t *oldset)
static void do_signal(void)
{
struct k_sigaction ka;
siginfo_t info;
sigset_t *oldset;
int signr;

/*
Expand All @@ -549,43 +498,62 @@ static int do_signal(sigset_t *oldset)
* if so.
*/
if (!user_mode(__frame))
return 1;
return;

if (try_to_freeze())
goto no_signal;

if (!oldset)
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
oldset = &current->blocked;

signr = get_signal_to_deliver(&info, &ka, __frame, NULL);
if (signr > 0)
return handle_signal(signr, &info, &ka, oldset);
if (signr > 0) {
if (handle_signal(signr, &info, &ka, oldset) == 0) {
/* a signal was successfully delivered; the saved
* sigmask will have been stored in the signal frame,
* and will be restored by sigreturn, so we can simply
* clear the TIF_RESTORE_SIGMASK flag */
if (test_thread_flag(TIF_RESTORE_SIGMASK))
clear_thread_flag(TIF_RESTORE_SIGMASK);
}

return;
}

no_signal:
/* Did we come from a system call? */
if (__frame->syscallno >= 0) {
/* Restart the system call - no handlers present */
if (__frame->gr8 == -ERESTARTNOHAND ||
__frame->gr8 == -ERESTARTSYS ||
__frame->gr8 == -ERESTARTNOINTR) {
switch (__frame->gr8) {
case -ERESTARTNOHAND:
case -ERESTARTSYS:
case -ERESTARTNOINTR:
__frame->gr8 = __frame->orig_gr8;
__frame->pc -= 4;
}
break;

if (__frame->gr8 == -ERESTART_RESTARTBLOCK){
case -ERESTART_RESTARTBLOCK:
__frame->gr8 = __NR_restart_syscall;
__frame->pc -= 4;
break;
}
}

return 0;
/* if there's no signal to deliver, we just put the saved sigmask
* back */
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
clear_thread_flag(TIF_RESTORE_SIGMASK);
sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
}

} /* end do_signal() */

/*****************************************************************************/
/*
* notification of userspace execution resumption
* - triggered by current->work.notify_resume
* - triggered by the TIF_WORK_MASK flags
*/
asmlinkage void do_notify_resume(__u32 thread_info_flags)
{
Expand All @@ -594,7 +562,7 @@ asmlinkage void do_notify_resume(__u32 thread_info_flags)
clear_thread_flag(TIF_SINGLESTEP);

/* deal with pending signal delivery */
if (thread_info_flags & _TIF_SIGPENDING)
do_signal(NULL);
if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK))
do_signal();

} /* end do_notify_resume() */
2 changes: 2 additions & 0 deletions trunk/include/asm-frv/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ register struct thread_info *__current_thread_info asm("gr15");
#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
#define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */
#define TIF_IRET 5 /* return with iret */
#define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */
#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
#define TIF_MEMDIE 17 /* OOM killer killed process */

Expand All @@ -138,6 +139,7 @@ register struct thread_info *__current_thread_info asm("gr15");
#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
#define _TIF_IRET (1 << TIF_IRET)
#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)

#define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
Expand Down
1 change: 1 addition & 0 deletions trunk/include/asm-frv/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ static inline pid_t wait(int * wait_stat)
/* #define __ARCH_WANT_SYS_SIGPENDING */
#define __ARCH_WANT_SYS_SIGPROCMASK
#define __ARCH_WANT_SYS_RT_SIGACTION
#define __ARCH_WANT_SYS_RT_SIGSUSPEND
#endif

/*
Expand Down

0 comments on commit 6314f9a

Please sign in to comment.