Skip to content

Commit

Permalink
[SPARC]: Add support for *at(), ppoll, and pselect syscalls.
Browse files Browse the repository at this point in the history
This also includes by necessity _TIF_RESTORE_SIGMASK support,
which actually resulted in a lot of cleanups.

The sparc signal handling code is quite a mess and I should
clean it up some day.

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jan 19, 2006
1 parent f7111ce commit 2d7d5f0
Show file tree
Hide file tree
Showing 16 changed files with 184 additions and 422 deletions.
56 changes: 0 additions & 56 deletions arch/sparc/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -1276,62 +1276,6 @@ sys_sigstack:
call do_sys_sigstack
mov %l5, %o7

.align 4
.globl sys_sigpause
sys_sigpause:
/* Note: %o0 already has correct value... */
call do_sigpause
add %sp, STACKFRAME_SZ, %o1

ld [%curptr + TI_FLAGS], %l5
andcc %l5, _TIF_SYSCALL_TRACE, %g0
be 1f
nop

call syscall_trace
nop

1:
/* We are returning to a signal handler. */
RESTORE_ALL

.align 4
.globl sys_sigsuspend
sys_sigsuspend:
call do_sigsuspend
add %sp, STACKFRAME_SZ, %o0

ld [%curptr + TI_FLAGS], %l5
andcc %l5, _TIF_SYSCALL_TRACE, %g0
be 1f
nop

call syscall_trace
nop

1:
/* We are returning to a signal handler. */
RESTORE_ALL

.align 4
.globl sys_rt_sigsuspend
sys_rt_sigsuspend:
/* Note: %o0, %o1 already have correct value... */
call do_rt_sigsuspend
add %sp, STACKFRAME_SZ, %o2

ld [%curptr + TI_FLAGS], %l5
andcc %l5, _TIF_SYSCALL_TRACE, %g0
be 1f
nop

call syscall_trace
nop

1:
/* We are returning to a signal handler. */
RESTORE_ALL

.align 4
.globl sys_sigreturn
sys_sigreturn:
Expand Down
9 changes: 4 additions & 5 deletions arch/sparc/kernel/rtrap.S
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,14 @@ ret_trap_lockless_ipi:

ld [%curptr + TI_FLAGS], %g2
signal_p:
andcc %g2, (_TIF_NOTIFY_RESUME|_TIF_SIGPENDING), %g0
andcc %g2, (_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK), %g0
bz,a ret_trap_continue
ld [%sp + STACKFRAME_SZ + PT_PSR], %t_psr

clr %o0
mov %l5, %o2
mov %l6, %o3
mov %l5, %o1
mov %l6, %o2
call do_signal
add %sp, STACKFRAME_SZ, %o1 ! pt_regs ptr
add %sp, STACKFRAME_SZ, %o0 ! pt_regs ptr

/* Fall through. */
ld [%sp + STACKFRAME_SZ + PT_PSR], %t_psr
Expand Down
117 changes: 31 additions & 86 deletions arch/sparc/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ extern void fpsave(unsigned long *fpregs, unsigned long *fsr,
void *fpqueue, unsigned long *fpqdepth);
extern void fpload(unsigned long *fpregs, unsigned long *fsr);

asmlinkage int do_signal(sigset_t *oldset, struct pt_regs * regs,
unsigned long orig_o0, int restart_syscall);

/* Signal frames: the original one (compatible with SunOS):
*
* Set up a signal frame... Make the stack look the way SunOS
Expand Down Expand Up @@ -95,98 +92,30 @@ struct rt_signal_frame {
#define NF_ALIGNEDSZ (((sizeof(struct new_signal_frame) + 7) & (~7)))
#define RT_ALIGNEDSZ (((sizeof(struct rt_signal_frame) + 7) & (~7)))

/*
* atomically swap in the new signal mask, and wait for a signal.
* This is really tricky on the Sparc, watch out...
*/
asmlinkage void _sigpause_common(old_sigset_t set, struct pt_regs *regs)
static int _sigpause_common(old_sigset_t set)
{
sigset_t saveset;

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

regs->pc = regs->npc;
regs->npc += 4;

/* Condition codes and return value where set here for sigpause,
* and so got used by setup_frame, which again causes sigreturn()
* to return -EINTR.
*/
while (1) {
current->state = TASK_INTERRUPTIBLE;
schedule();
/*
* Return -EINTR and set condition code here,
* so the interrupted system call actually returns
* these.
*/
regs->psr |= PSR_C;
regs->u_regs[UREG_I0] = EINTR;
if (do_signal(&saveset, regs, 0, 0))
return;
}
}
current->state = TASK_INTERRUPTIBLE;
schedule();
set_thread_flag(TIF_RESTORE_SIGMASK);

asmlinkage void do_sigpause(unsigned int set, struct pt_regs *regs)
{
_sigpause_common(set, regs);
return -ERESTARTNOHAND;
}

asmlinkage void do_sigsuspend (struct pt_regs *regs)
asmlinkage int sys_sigpause(unsigned int set)
{
_sigpause_common(regs->u_regs[UREG_I0], regs);
return _sigpause_common(set);
}

asmlinkage void do_rt_sigsuspend(sigset_t __user *uset, size_t sigsetsize,
struct pt_regs *regs)
asmlinkage int sys_sigsuspend(old_sigset_t set)
{
sigset_t oldset, set;

/* XXX: Don't preclude handling different sized sigset_t's. */
if (sigsetsize != sizeof(sigset_t)) {
regs->psr |= PSR_C;
regs->u_regs[UREG_I0] = EINVAL;
return;
}

if (copy_from_user(&set, uset, sizeof(set))) {
regs->psr |= PSR_C;
regs->u_regs[UREG_I0] = EFAULT;
return;
}

sigdelsetmask(&set, ~_BLOCKABLE);
spin_lock_irq(&current->sighand->siglock);
oldset = current->blocked;
current->blocked = set;
recalc_sigpending();
spin_unlock_irq(&current->sighand->siglock);

regs->pc = regs->npc;
regs->npc += 4;

/* Condition codes and return value where set here for sigpause,
* and so got used by setup_frame, which again causes sigreturn()
* to return -EINTR.
*/
while (1) {
current->state = TASK_INTERRUPTIBLE;
schedule();
/*
* Return -EINTR and set condition code here,
* so the interrupted system call actually returns
* these.
*/
regs->psr |= PSR_C;
regs->u_regs[UREG_I0] = EINTR;
if (do_signal(&oldset, regs, 0, 0))
return;
}
return _sigpause_common(set);
}

static inline int
Expand Down Expand Up @@ -1067,13 +996,13 @@ static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs,
* want to handle. Thus you cannot kill init even with a SIGKILL even by
* mistake.
*/
asmlinkage int do_signal(sigset_t *oldset, struct pt_regs * regs,
unsigned long orig_i0, int restart_syscall)
asmlinkage void do_signal(struct pt_regs * regs, unsigned long orig_i0, int restart_syscall)
{
siginfo_t info;
struct sparc_deliver_cookie cookie;
struct k_sigaction ka;
int signr;
sigset_t *oldset;

/*
* XXX Disable svr4 signal handling until solaris emulation works.
Expand All @@ -1089,7 +1018,9 @@ asmlinkage int do_signal(sigset_t *oldset, struct pt_regs * regs,
cookie.restart_syscall = restart_syscall;
cookie.orig_i0 = orig_i0;

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

signr = get_signal_to_deliver(&info, &ka, regs, &cookie);
Expand All @@ -1098,7 +1029,14 @@ asmlinkage int do_signal(sigset_t *oldset, struct pt_regs * regs,
syscall_restart(cookie.orig_i0, regs, &ka.sa);
handle_signal(signr, &ka, &info, oldset,
regs, svr4_signal);
return 1;
/* 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;
}
if (cookie.restart_syscall &&
(regs->u_regs[UREG_I0] == ERESTARTNOHAND ||
Expand All @@ -1115,7 +1053,14 @@ asmlinkage int do_signal(sigset_t *oldset, struct pt_regs * regs,
regs->pc -= 4;
regs->npc -= 4;
}
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);
}
}

asmlinkage int
Expand Down
2 changes: 0 additions & 2 deletions arch/sparc/kernel/sparc_ksyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ struct poll {

extern int svr4_getcontext (svr4_ucontext_t *, struct pt_regs *);
extern int svr4_setcontext (svr4_ucontext_t *, struct pt_regs *);
void _sigpause_common (unsigned int set, struct pt_regs *);
extern void (*__copy_1page)(void *, const void *);
extern void __memmove(void *, const void *, __kernel_size_t);
extern void (*bzero_1page)(void *);
Expand Down Expand Up @@ -227,7 +226,6 @@ EXPORT_SYMBOL(kunmap_atomic);
/* Solaris/SunOS binary compatibility */
EXPORT_SYMBOL(svr4_setcontext);
EXPORT_SYMBOL(svr4_getcontext);
EXPORT_SYMBOL(_sigpause_common);

EXPORT_SYMBOL(dump_thread);

Expand Down
10 changes: 9 additions & 1 deletion arch/sparc/kernel/systbls.S
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ sys_call_table:
/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
/*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
/*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
/*280*/ .long sys_ni_syscall, sys_add_key, sys_request_key, sys_keyctl
/*280*/ .long sys_ni_syscall, sys_add_key, sys_request_key, sys_keyctl, sys_openat
/*285*/ .long sys_mkdirat, sys_mknodat, sys_fchownat, sys_futimesat, sys_newfstatat
/*290*/ .long sys_unlinkat, sys_renameat, sys_linkat, sys_symlinkat, sys_readlinkat
/*295*/ .long sys_fchmodat, sys_faccessat, sys_pselect6, sys_ppoll

#ifdef CONFIG_SUNOS_EMUL
/* Now the SunOS syscall table. */
Expand Down Expand Up @@ -181,6 +184,11 @@ sunos_sys_table:
.long sunos_nosys, sunos_nosys, sunos_nosys
.long sunos_nosys
/*280*/ .long sunos_nosys, sunos_nosys, sunos_nosys
.long sunos_nosys, sunos_nosys, sunos_nosys
.long sunos_nosys, sunos_nosys, sunos_nosys
.long sunos_nosys
/*290*/ .long sunos_nosys, sunos_nosys, sunos_nosys
.long sunos_nosys, sunos_nosys, sunos_nosys
.long sunos_nosys, sunos_nosys, sunos_nosys

#endif
23 changes: 0 additions & 23 deletions arch/sparc64/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,6 @@ execve_merge:
add %sp, PTREGS_OFF, %o0

.globl sys_pipe, sys_sigpause, sys_nis_syscall
.globl sys_sigsuspend, sys_rt_sigsuspend
.globl sys_rt_sigreturn
.globl sys_ptrace
.globl sys_sigaltstack
Expand All @@ -1440,28 +1439,6 @@ sys32_sigaltstack:
mov %i6, %o2
#endif
.align 32
sys_sigsuspend: add %sp, PTREGS_OFF, %o0
call do_sigsuspend
add %o7, 1f-.-4, %o7
nop
sys_rt_sigsuspend: /* NOTE: %o0,%o1 have a correct value already */
add %sp, PTREGS_OFF, %o2
call do_rt_sigsuspend
add %o7, 1f-.-4, %o7
nop
#ifdef CONFIG_COMPAT
.globl sys32_rt_sigsuspend
sys32_rt_sigsuspend: /* NOTE: %o0,%o1 have a correct value already */
srl %o0, 0, %o0
add %sp, PTREGS_OFF, %o2
call do_rt_sigsuspend32
add %o7, 1f-.-4, %o7
#endif
/* NOTE: %o0 has a correct value already */
sys_sigpause: add %sp, PTREGS_OFF, %o1
call do_sigpause
add %o7, 1f-.-4, %o7
nop
#ifdef CONFIG_COMPAT
.globl sys32_sigreturn
sys32_sigreturn:
Expand Down
Loading

0 comments on commit 2d7d5f0

Please sign in to comment.