Commit ae802127 authored by Anton Blanchard's avatar Anton Blanchard

ppc64: restore non rt signals, we need to verify that older 64bit glibcs dont use them

parent 09b54128
...@@ -228,6 +228,10 @@ _GLOBAL(ppc32_rt_sigreturn) ...@@ -228,6 +228,10 @@ _GLOBAL(ppc32_rt_sigreturn)
bl .sys32_rt_sigreturn bl .sys32_rt_sigreturn
b 80f b 80f
_GLOBAL(ppc64_sigreturn)
bl .sys_sigreturn
b 80f
_GLOBAL(ppc64_rt_sigreturn) _GLOBAL(ppc64_rt_sigreturn)
bl .sys_rt_sigreturn bl .sys_rt_sigreturn
......
...@@ -540,7 +540,7 @@ _GLOBAL(sys_call_table32) ...@@ -540,7 +540,7 @@ _GLOBAL(sys_call_table32)
.llong .sys32_ssetmask .llong .sys32_ssetmask
.llong .sys_setreuid /* 70 */ .llong .sys_setreuid /* 70 */
.llong .sys_setregid .llong .sys_setregid
.llong .sys32_sigsuspend .llong .sys_sigsuspend
.llong .compat_sys_sigpending .llong .compat_sys_sigpending
.llong .sys32_sethostname .llong .sys32_sethostname
.llong .sys32_setrlimit /* 75 */ .llong .sys32_setrlimit /* 75 */
...@@ -783,13 +783,13 @@ _GLOBAL(sys_call_table) ...@@ -783,13 +783,13 @@ _GLOBAL(sys_call_table)
.llong .sys_getppid .llong .sys_getppid
.llong .sys_getpgrp /* 65 */ .llong .sys_getpgrp /* 65 */
.llong .sys_setsid .llong .sys_setsid
.llong .sys_ni_syscall /* 32 bit only sigaction */ .llong .sys_sigaction
.llong .sys_sgetmask .llong .sys_sgetmask
.llong .sys_ssetmask .llong .sys_ssetmask
.llong .sys_setreuid /* 70 */ .llong .sys_setreuid /* 70 */
.llong .sys_setregid .llong .sys_setregid
.llong .sys_ni_syscall /* 32bit only sigsuspend */ .llong .sys_sigsuspend
.llong .sys_ni_syscall /* 32bit only sigpending */ .llong .sys_sigpending
.llong .sys_sethostname .llong .sys_sethostname
.llong .sys_setrlimit /* 75 */ .llong .sys_setrlimit /* 75 */
.llong .sys_ni_syscall /* old getrlimit syscall */ .llong .sys_ni_syscall /* old getrlimit syscall */
...@@ -835,14 +835,14 @@ _GLOBAL(sys_call_table) ...@@ -835,14 +835,14 @@ _GLOBAL(sys_call_table)
.llong .sys_sysinfo .llong .sys_sysinfo
.llong .sys_ipc .llong .sys_ipc
.llong .sys_fsync .llong .sys_fsync
.llong .sys_ni_syscall /* 32bit only sigreturn */ .llong .ppc64_sigreturn
.llong .sys_clone /* 120 */ .llong .sys_clone /* 120 */
.llong .sys_setdomainname .llong .sys_setdomainname
.llong .ppc64_newuname .llong .ppc64_newuname
.llong .sys_ni_syscall /* old modify_ldt syscall */ .llong .sys_ni_syscall /* old modify_ldt syscall */
.llong .sys_adjtimex .llong .sys_adjtimex
.llong .sys_mprotect /* 125 */ .llong .sys_mprotect /* 125 */
.llong .sys_ni_syscall /* 32bit only sigprocmask */ .llong .sys_sigprocmask
.llong .sys_ni_syscall /* old create_module syscall */ .llong .sys_ni_syscall /* old create_module syscall */
.llong .sys_init_module .llong .sys_init_module
.llong .sys_delete_module .llong .sys_delete_module
......
...@@ -99,6 +99,40 @@ struct rt_sigframe ...@@ -99,6 +99,40 @@ struct rt_sigframe
extern int do_signal(sigset_t *oldset, struct pt_regs *regs); extern int do_signal(sigset_t *oldset, struct pt_regs *regs);
/*
* Atomically swap in the new signal mask, and wait for a signal.
*/
long sys_sigsuspend(old_sigset_t mask, int p2, int p3, int p4, int p6, int p7,
struct pt_regs *regs)
{
sigset_t saveset;
mask &= _BLOCKABLE;
spin_lock_irq(&current->sig->siglock);
saveset = current->blocked;
siginitset(&current->blocked, mask);
recalc_sigpending();
spin_unlock_irq(&current->sig->siglock);
regs->result = -EINTR;
regs->gpr[3] = EINTR;
regs->ccr |= 0x10000000;
while (1) {
current->state = TASK_INTERRUPTIBLE;
schedule();
if (do_signal(&saveset, regs))
/*
* If a signal handler needs to be called,
* do_signal() has set R3 to the signal number (the
* first argument of the signal handler), so don't
* overwrite that with EINTR !
* In the other cases, do_signal() doesn't touch
* R3, so it's still set to -EINTR (see above).
*/
return regs->gpr[3];
}
}
long sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize, int p3, int p4, int p6, long sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize, int p3, int p4, int p6,
int p7, struct pt_regs *regs) int p7, struct pt_regs *regs)
{ {
...@@ -136,6 +170,37 @@ long sys_sigaltstack(const stack_t *uss, stack_t *uoss, unsigned long r5, ...@@ -136,6 +170,37 @@ long sys_sigaltstack(const stack_t *uss, stack_t *uoss, unsigned long r5,
return do_sigaltstack(uss, uoss, regs->gpr[1]); return do_sigaltstack(uss, uoss, regs->gpr[1]);
} }
long sys_sigaction(int sig, const struct old_sigaction *act,
struct old_sigaction *oact)
{
struct k_sigaction new_ka, old_ka;
int ret;
if (act) {
old_sigset_t mask;
if (verify_area(VERIFY_READ, act, sizeof(*act)) ||
__get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
__get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
return -EFAULT;
__get_user(new_ka.sa.sa_flags, &act->sa_flags);
__get_user(mask, &act->sa_mask);
siginitset(&new_ka.sa.sa_mask, mask);
}
ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
if (!ret && oact) {
if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) ||
__put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
__put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
return -EFAULT;
__put_user(old_ka.sa.sa_flags, &oact->sa_flags);
__put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
}
return ret;
}
/* /*
* When we have rt signals to deliver, we set up on the * When we have rt signals to deliver, we set up on the
* user stack, going down from the original stack pointer: * user stack, going down from the original stack pointer:
...@@ -263,6 +328,116 @@ static void setup_rt_frame(struct pt_regs *regs, struct sigregs *frame, ...@@ -263,6 +328,116 @@ static void setup_rt_frame(struct pt_regs *regs, struct sigregs *frame,
do_exit(SIGSEGV); do_exit(SIGSEGV);
} }
/*
* Do a signal return; undo the signal stack.
*/
long sys_sigreturn(unsigned long r3, unsigned long r4, unsigned long r5,
unsigned long r6, unsigned long r7, unsigned long r8,
struct pt_regs *regs)
{
struct sigcontext *sc, sigctx;
struct sigregs *sr;
elf_gregset_t saved_regs; /* an array of ELF_NGREG unsigned longs */
sigset_t set;
sc = (struct sigcontext *)(regs->gpr[1] + __SIGNAL_FRAMESIZE);
if (copy_from_user(&sigctx, sc, sizeof(sigctx)))
goto badframe;
set.sig[0] = sigctx.oldmask;
#if _NSIG_WORDS > 1
set.sig[1] = sigctx._unused[3];
#endif
sigdelsetmask(&set, ~_BLOCKABLE);
spin_lock_irq(&current->sig->siglock);
current->blocked = set;
recalc_sigpending();
spin_unlock_irq(&current->sig->siglock);
if (regs->msr & MSR_FP)
giveup_fpu(current);
/* restore registers */
sr = (struct sigregs *)sigctx.regs;
if (copy_from_user(saved_regs, &sr->gp_regs, sizeof(sr->gp_regs)))
goto badframe;
saved_regs[PT_MSR] = (regs->msr & ~MSR_USERCHANGE)
| (saved_regs[PT_MSR] & MSR_USERCHANGE);
saved_regs[PT_SOFTE] = regs->softe;
memcpy(regs, saved_regs, GP_REGS_SIZE);
if (copy_from_user(current->thread.fpr, &sr->fp_regs,
sizeof(sr->fp_regs)))
goto badframe;
return regs->result;
badframe:
do_exit(SIGSEGV);
}
/*
* Set up a signal frame.
*/
static void setup_frame(struct pt_regs *regs, struct sigregs *frame,
unsigned long newsp)
{
/* Handler is *really* a pointer to the function descriptor for
* the signal routine. The first entry in the function
* descriptor is the entry address of signal and the second
* entry is the TOC value we need to use.
*/
struct funct_descr_entry {
unsigned long entry;
unsigned long toc;
};
struct funct_descr_entry * funct_desc_ptr;
unsigned long temp_ptr;
struct sigcontext *sc = (struct sigcontext *)newsp;
if (verify_area(VERIFY_WRITE, frame, sizeof(*frame)))
goto badframe;
if (regs->msr & MSR_FP)
giveup_fpu(current);
if (__copy_to_user(&frame->gp_regs, regs, GP_REGS_SIZE)
|| __copy_to_user(&frame->fp_regs, current->thread.fpr,
ELF_NFPREG * sizeof(double))
/* li r0, __NR_sigreturn */
|| __put_user(0x38000000UL + __NR_sigreturn, &frame->tramp[0])
/* sc */
|| __put_user(0x44000002UL, &frame->tramp[1]))
goto badframe;
flush_icache_range((unsigned long)&frame->tramp[0],
(unsigned long)&frame->tramp[2]);
current->thread.fpscr = 0; /* turn off all fp exceptions */
newsp -= __SIGNAL_FRAMESIZE;
if (get_user(temp_ptr, &sc->handler))
goto badframe;
funct_desc_ptr = (struct funct_descr_entry *)temp_ptr;
if (put_user(regs->gpr[1], (unsigned long *)newsp)
|| get_user(regs->nip, &funct_desc_ptr ->entry)
|| get_user(regs->gpr[2],&funct_desc_ptr->toc)
|| get_user(regs->gpr[3], &sc->signal))
goto badframe;
regs->gpr[1] = newsp;
regs->gpr[4] = (unsigned long)sc;
regs->link = (unsigned long)frame->tramp;
return;
badframe:
#if DEBUG_SIG
printk("badframe in setup_frame, regs=%p frame=%p newsp=%lx\n",
regs, frame, newsp);
#endif
do_exit(SIGSEGV);
}
/* /*
* OK, we're invoking a handler * OK, we're invoking a handler
*/ */
...@@ -407,7 +582,10 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs) ...@@ -407,7 +582,10 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
if (newsp == frame) if (newsp == frame)
return 0; /* no signals delivered */ return 0; /* no signals delivered */
/* Invoke correct stack setup routine */
if (ka->sa.sa_flags & SA_SIGINFO)
setup_rt_frame(regs, (struct sigregs *)frame, newsp); setup_rt_frame(regs, (struct sigregs *)frame, newsp);
else
setup_frame(regs, (struct sigregs *)frame, newsp);
return 1; return 1;
} }
...@@ -112,43 +112,6 @@ struct rt_sigframe_32 { ...@@ -112,43 +112,6 @@ struct rt_sigframe_32 {
* setup_frame32 * setup_frame32
*/ */
/*
* Atomically swap in the new signal mask, and wait for a signal.
*/
extern int do_signal(sigset_t *oldset, struct pt_regs *regs);
long sys32_sigsuspend(old_sigset_t mask, int p2, int p3, int p4, int p6,
int p7, struct pt_regs *regs)
{
sigset_t saveset;
mask &= _BLOCKABLE;
spin_lock_irq(&current->sig->siglock);
saveset = current->blocked;
siginitset(&current->blocked, mask);
recalc_sigpending();
spin_unlock_irq(&current->sig->siglock);
regs->result = -EINTR;
regs->gpr[3] = EINTR;
regs->ccr |= 0x10000000;
while (1) {
current->state = TASK_INTERRUPTIBLE;
schedule();
if (do_signal(&saveset, regs))
/*
* If a signal handler needs to be called,
* do_signal() has set R3 to the signal number (the
* first argument of the signal handler), so don't
* overwrite that with EINTR !
* In the other cases, do_signal() doesn't touch
* R3, so it's still set to -EINTR (see above).
*/
return regs->gpr[3];
}
}
long sys32_sigaction(int sig, struct old_sigaction32 *act, long sys32_sigaction(int sig, struct old_sigaction32 *act,
struct old_sigaction32 *oact) struct old_sigaction32 *oact)
{ {
......
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