2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* irixsig.c: WHEEE, IRIX signals! YOW, am I compatible or what?!?!
|
|
|
|
*
|
|
|
|
* Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
|
|
|
|
* Copyright (C) 1997 - 2000 Ralf Baechle (ralf@gnu.org)
|
|
|
|
* Copyright (C) 2000 Silicon Graphics, Inc.
|
|
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/time.h>
|
|
|
|
#include <linux/ptrace.h>
|
2006-06-25 14:47:41 +02:00
|
|
|
#include <linux/resource.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#include <asm/ptrace.h>
|
|
|
|
#include <asm/uaccess.h>
|
2006-08-03 22:53:10 +02:00
|
|
|
#include <asm/unistd.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#undef DEBUG_SIG
|
|
|
|
|
|
|
|
#define _S(nr) (1<<((nr)-1))
|
|
|
|
|
|
|
|
#define _BLOCKABLE (~(_S(SIGKILL) | _S(SIGSTOP)))
|
|
|
|
|
2007-10-29 16:00:37 +01:00
|
|
|
#define _IRIX_NSIG 128
|
|
|
|
#define _IRIX_NSIG_BPW BITS_PER_LONG
|
|
|
|
#define _IRIX_NSIG_WORDS (_IRIX_NSIG / _IRIX_NSIG_BPW)
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
typedef struct {
|
2007-10-29 16:00:37 +01:00
|
|
|
unsigned long sig[_IRIX_NSIG_WORDS];
|
2005-04-17 00:20:36 +02:00
|
|
|
} irix_sigset_t;
|
|
|
|
|
|
|
|
struct sigctx_irix5 {
|
|
|
|
u32 rmask, cp0_status;
|
|
|
|
u64 pc;
|
|
|
|
u64 regs[32];
|
|
|
|
u64 fpregs[32];
|
|
|
|
u32 usedfp, fpcsr, fpeir, sstk_flags;
|
|
|
|
u64 hi, lo;
|
|
|
|
u64 cp0_cause, cp0_badvaddr, _unused0;
|
|
|
|
irix_sigset_t sigset;
|
|
|
|
u64 weird_fpu_thing;
|
|
|
|
u64 _unused1[31];
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef DEBUG_SIG
|
|
|
|
/* Debugging */
|
|
|
|
static inline void dump_irix5_sigctx(struct sigctx_irix5 *c)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
printk("misc: rmask[%08lx] status[%08lx] pc[%08lx]\n",
|
|
|
|
(unsigned long) c->rmask,
|
|
|
|
(unsigned long) c->cp0_status,
|
|
|
|
(unsigned long) c->pc);
|
|
|
|
printk("regs: ");
|
|
|
|
for(i = 0; i < 16; i++)
|
|
|
|
printk("[%d]<%08lx> ", i, (unsigned long) c->regs[i]);
|
|
|
|
printk("\nregs: ");
|
|
|
|
for(i = 16; i < 32; i++)
|
|
|
|
printk("[%d]<%08lx> ", i, (unsigned long) c->regs[i]);
|
|
|
|
printk("\nfpregs: ");
|
|
|
|
for(i = 0; i < 16; i++)
|
|
|
|
printk("[%d]<%08lx> ", i, (unsigned long) c->fpregs[i]);
|
|
|
|
printk("\nfpregs: ");
|
|
|
|
for(i = 16; i < 32; i++)
|
|
|
|
printk("[%d]<%08lx> ", i, (unsigned long) c->fpregs[i]);
|
|
|
|
printk("misc: usedfp[%d] fpcsr[%08lx] fpeir[%08lx] stk_flgs[%08lx]\n",
|
|
|
|
(int) c->usedfp, (unsigned long) c->fpcsr,
|
|
|
|
(unsigned long) c->fpeir, (unsigned long) c->sstk_flags);
|
|
|
|
printk("misc: hi[%08lx] lo[%08lx] cause[%08lx] badvaddr[%08lx]\n",
|
|
|
|
(unsigned long) c->hi, (unsigned long) c->lo,
|
|
|
|
(unsigned long) c->cp0_cause, (unsigned long) c->cp0_badvaddr);
|
|
|
|
printk("misc: sigset<0>[%08lx] sigset<1>[%08lx] sigset<2>[%08lx] "
|
|
|
|
"sigset<3>[%08lx]\n", (unsigned long) c->sigset.sig[0],
|
|
|
|
(unsigned long) c->sigset.sig[1],
|
|
|
|
(unsigned long) c->sigset.sig[2],
|
|
|
|
(unsigned long) c->sigset.sig[3]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
static int setup_irix_frame(struct k_sigaction *ka, struct pt_regs *regs,
|
|
|
|
int signr, sigset_t *oldmask)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2005-03-01 20:22:29 +01:00
|
|
|
struct sigctx_irix5 __user *ctx;
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned long sp;
|
2005-03-01 20:22:29 +01:00
|
|
|
int error, i;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
sp = regs->regs[29];
|
|
|
|
sp -= sizeof(struct sigctx_irix5);
|
|
|
|
sp &= ~(0xf);
|
2005-03-01 20:22:29 +01:00
|
|
|
ctx = (struct sigctx_irix5 __user *) sp;
|
2005-04-17 00:20:36 +02:00
|
|
|
if (!access_ok(VERIFY_WRITE, ctx, sizeof(*ctx)))
|
|
|
|
goto segv_and_exit;
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
error = __put_user(0, &ctx->weird_fpu_thing);
|
|
|
|
error |= __put_user(~(0x00000001), &ctx->rmask);
|
|
|
|
error |= __put_user(0, &ctx->regs[0]);
|
2005-04-17 00:20:36 +02:00
|
|
|
for(i = 1; i < 32; i++)
|
2005-03-01 20:22:29 +01:00
|
|
|
error |= __put_user((u64) regs->regs[i], &ctx->regs[i]);
|
|
|
|
|
|
|
|
error |= __put_user((u64) regs->hi, &ctx->hi);
|
|
|
|
error |= __put_user((u64) regs->lo, &ctx->lo);
|
|
|
|
error |= __put_user((u64) regs->cp0_epc, &ctx->pc);
|
|
|
|
error |= __put_user(!!used_math(), &ctx->usedfp);
|
|
|
|
error |= __put_user((u64) regs->cp0_cause, &ctx->cp0_cause);
|
|
|
|
error |= __put_user((u64) regs->cp0_badvaddr, &ctx->cp0_badvaddr);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
error |= __put_user(0, &ctx->sstk_flags); /* XXX sigstack unimp... todo... */
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
error |= __copy_to_user(&ctx->sigset, oldmask, sizeof(irix_sigset_t)) ? -EFAULT : 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
if (error)
|
|
|
|
goto segv_and_exit;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#ifdef DEBUG_SIG
|
|
|
|
dump_irix5_sigctx(ctx);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
regs->regs[4] = (unsigned long) signr;
|
|
|
|
regs->regs[5] = 0; /* XXX sigcode XXX */
|
|
|
|
regs->regs[6] = regs->regs[29] = sp;
|
|
|
|
regs->regs[7] = (unsigned long) ka->sa.sa_handler;
|
|
|
|
regs->regs[25] = regs->cp0_epc = (unsigned long) ka->sa_restorer;
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
return 1;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
segv_and_exit:
|
|
|
|
force_sigsegv(signr, current);
|
2005-03-01 20:22:29 +01:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
static int inline
|
2005-04-17 00:20:36 +02:00
|
|
|
setup_irix_rt_frame(struct k_sigaction * ka, struct pt_regs *regs,
|
|
|
|
int signr, sigset_t *oldmask, siginfo_t *info)
|
|
|
|
{
|
|
|
|
printk("Aiee: setup_tr_frame wants to be written");
|
|
|
|
do_exit(SIGSEGV);
|
|
|
|
}
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
static inline int handle_signal(unsigned long sig, siginfo_t *info,
|
2005-04-17 00:20:36 +02:00
|
|
|
struct k_sigaction *ka, sigset_t *oldset, struct pt_regs * regs)
|
|
|
|
{
|
2005-03-01 20:22:29 +01:00
|
|
|
int ret;
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
switch(regs->regs[0]) {
|
|
|
|
case ERESTARTNOHAND:
|
|
|
|
regs->regs[2] = EINTR;
|
|
|
|
break;
|
|
|
|
case ERESTARTSYS:
|
|
|
|
if(!(ka->sa.sa_flags & SA_RESTART)) {
|
|
|
|
regs->regs[2] = EINTR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* fallthrough */
|
|
|
|
case ERESTARTNOINTR: /* Userland will reload $v0. */
|
|
|
|
regs->cp0_epc -= 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
regs->regs[0] = 0; /* Don't deal with this again. */
|
|
|
|
|
|
|
|
if (ka->sa.sa_flags & SA_SIGINFO)
|
2005-03-01 20:22:29 +01:00
|
|
|
ret = setup_irix_rt_frame(ka, regs, sig, oldset, info);
|
2005-04-17 00:20:36 +02:00
|
|
|
else
|
2005-03-01 20:22:29 +01:00
|
|
|
ret = setup_irix_frame(ka, regs, sig, oldset);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
[PATCH] convert signal handling of NODEFER to act like other Unix boxes.
It has been reported that the way Linux handles NODEFER for signals is
not consistent with the way other Unix boxes handle it. I've written a
program to test the behavior of how this flag affects signals and had
several reports from people who ran this on various Unix boxes,
confirming that Linux seems to be unique on the way this is handled.
The way NODEFER affects signals on other Unix boxes is as follows:
1) If NODEFER is set, other signals in sa_mask are still blocked.
2) If NODEFER is set and the signal is in sa_mask, then the signal is
still blocked. (Note: this is the behavior of all tested but Linux _and_
NetBSD 2.0 *).
The way NODEFER affects signals on Linux:
1) If NODEFER is set, other signals are _not_ blocked regardless of
sa_mask (Even NetBSD doesn't do this).
2) If NODEFER is set and the signal is in sa_mask, then the signal being
handled is not blocked.
The patch converts signal handling in all current Linux architectures to
the way most Unix boxes work.
Unix boxes that were tested: DU4, AIX 5.2, Irix 6.5, NetBSD 2.0, SFU
3.5 on WinXP, AIX 5.3, Mac OSX, and of course Linux 2.6.13-rcX.
* NetBSD was the only other Unix to behave like Linux on point #2. The
main concern was brought up by point #1 which even NetBSD isn't like
Linux. So with this patch, we leave NetBSD as the lonely one that
behaves differently here with #2.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-08-29 17:44:09 +02:00
|
|
|
spin_lock_irq(¤t->sighand->siglock);
|
2007-10-12 00:46:15 +02:00
|
|
|
sigorsets(¤t->blocked, ¤t->blocked, &ka->sa.sa_mask);
|
[PATCH] convert signal handling of NODEFER to act like other Unix boxes.
It has been reported that the way Linux handles NODEFER for signals is
not consistent with the way other Unix boxes handle it. I've written a
program to test the behavior of how this flag affects signals and had
several reports from people who ran this on various Unix boxes,
confirming that Linux seems to be unique on the way this is handled.
The way NODEFER affects signals on other Unix boxes is as follows:
1) If NODEFER is set, other signals in sa_mask are still blocked.
2) If NODEFER is set and the signal is in sa_mask, then the signal is
still blocked. (Note: this is the behavior of all tested but Linux _and_
NetBSD 2.0 *).
The way NODEFER affects signals on Linux:
1) If NODEFER is set, other signals are _not_ blocked regardless of
sa_mask (Even NetBSD doesn't do this).
2) If NODEFER is set and the signal is in sa_mask, then the signal being
handled is not blocked.
The patch converts signal handling in all current Linux architectures to
the way most Unix boxes work.
Unix boxes that were tested: DU4, AIX 5.2, Irix 6.5, NetBSD 2.0, SFU
3.5 on WinXP, AIX 5.3, Mac OSX, and of course Linux 2.6.13-rcX.
* NetBSD was the only other Unix to behave like Linux on point #2. The
main concern was brought up by point #1 which even NetBSD isn't like
Linux. So with this patch, we leave NetBSD as the lonely one that
behaves differently here with #2.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-08-29 17:44:09 +02:00
|
|
|
if (!(ka->sa.sa_flags & SA_NODEFER))
|
2007-10-12 00:46:15 +02:00
|
|
|
sigaddset(¤t->blocked, sig);
|
[PATCH] convert signal handling of NODEFER to act like other Unix boxes.
It has been reported that the way Linux handles NODEFER for signals is
not consistent with the way other Unix boxes handle it. I've written a
program to test the behavior of how this flag affects signals and had
several reports from people who ran this on various Unix boxes,
confirming that Linux seems to be unique on the way this is handled.
The way NODEFER affects signals on other Unix boxes is as follows:
1) If NODEFER is set, other signals in sa_mask are still blocked.
2) If NODEFER is set and the signal is in sa_mask, then the signal is
still blocked. (Note: this is the behavior of all tested but Linux _and_
NetBSD 2.0 *).
The way NODEFER affects signals on Linux:
1) If NODEFER is set, other signals are _not_ blocked regardless of
sa_mask (Even NetBSD doesn't do this).
2) If NODEFER is set and the signal is in sa_mask, then the signal being
handled is not blocked.
The patch converts signal handling in all current Linux architectures to
the way most Unix boxes work.
Unix boxes that were tested: DU4, AIX 5.2, Irix 6.5, NetBSD 2.0, SFU
3.5 on WinXP, AIX 5.3, Mac OSX, and of course Linux 2.6.13-rcX.
* NetBSD was the only other Unix to behave like Linux on point #2. The
main concern was brought up by point #1 which even NetBSD isn't like
Linux. So with this patch, we leave NetBSD as the lonely one that
behaves differently here with #2.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-08-29 17:44:09 +02:00
|
|
|
recalc_sigpending();
|
|
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
2005-03-01 20:22:29 +01:00
|
|
|
|
|
|
|
return ret;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2006-08-03 22:53:10 +02:00
|
|
|
void do_irix_signal(struct pt_regs *regs)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct k_sigaction ka;
|
|
|
|
siginfo_t info;
|
|
|
|
int signr;
|
2006-08-03 22:53:10 +02:00
|
|
|
sigset_t *oldset;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We want the common case to go fast, which is why we may in certain
|
|
|
|
* cases get here from kernel mode. Just return without doing anything
|
|
|
|
* if so.
|
|
|
|
*/
|
|
|
|
if (!user_mode(regs))
|
2006-08-03 22:53:10 +02:00
|
|
|
return;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-08-03 22:53:10 +02:00
|
|
|
if (test_thread_flag(TIF_RESTORE_SIGMASK))
|
|
|
|
oldset = ¤t->saved_sigmask;
|
|
|
|
else
|
2005-04-17 00:20:36 +02:00
|
|
|
oldset = ¤t->blocked;
|
|
|
|
|
|
|
|
signr = get_signal_to_deliver(&info, &ka, regs, NULL);
|
2006-08-03 22:53:10 +02:00
|
|
|
if (signr > 0) {
|
|
|
|
/* Whee! Actually deliver the signal. */
|
|
|
|
if (handle_signal(signr, &info, &ka, oldset, regs) == 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;
|
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Who's code doesn't conform to the restartable syscall convention
|
|
|
|
* dies here!!! The li instruction, a single machine instruction,
|
|
|
|
* must directly be followed by the syscall instruction.
|
|
|
|
*/
|
|
|
|
if (regs->regs[0]) {
|
|
|
|
if (regs->regs[2] == ERESTARTNOHAND ||
|
|
|
|
regs->regs[2] == ERESTARTSYS ||
|
|
|
|
regs->regs[2] == ERESTARTNOINTR) {
|
|
|
|
regs->cp0_epc -= 8;
|
|
|
|
}
|
2006-08-03 22:53:10 +02:00
|
|
|
if (regs->regs[2] == ERESTART_RESTARTBLOCK) {
|
|
|
|
regs->regs[2] = __NR_restart_syscall;
|
|
|
|
regs->regs[7] = regs->regs[26];
|
|
|
|
regs->cp0_epc -= 4;
|
|
|
|
}
|
2006-08-08 04:47:01 +02:00
|
|
|
regs->regs[0] = 0; /* Don't deal with this again. */
|
2006-08-03 22:53:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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, ¤t->saved_sigmask, NULL);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
asmlinkage void
|
|
|
|
irix_sigreturn(struct pt_regs *regs)
|
|
|
|
{
|
2005-03-01 20:22:29 +01:00
|
|
|
struct sigctx_irix5 __user *context, *magic;
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned long umask, mask;
|
|
|
|
u64 *fregs;
|
2005-03-01 20:22:29 +01:00
|
|
|
u32 usedfp;
|
|
|
|
int error, sig, i, base = 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
sigset_t blocked;
|
|
|
|
|
|
|
|
/* Always make any pending restarted system calls return -EINTR */
|
|
|
|
current_thread_info()->restart_block.fn = do_no_restart_syscall;
|
|
|
|
|
|
|
|
if (regs->regs[2] == 1000)
|
|
|
|
base = 1;
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
context = (struct sigctx_irix5 __user *) regs->regs[base + 4];
|
|
|
|
magic = (struct sigctx_irix5 __user *) regs->regs[base + 5];
|
2005-04-17 00:20:36 +02:00
|
|
|
sig = (int) regs->regs[base + 6];
|
|
|
|
#ifdef DEBUG_SIG
|
|
|
|
printk("[%s:%d] IRIX sigreturn(scp[%p],ucp[%p],sig[%d])\n",
|
|
|
|
current->comm, current->pid, context, magic, sig);
|
|
|
|
#endif
|
|
|
|
if (!context)
|
|
|
|
context = magic;
|
|
|
|
if (!access_ok(VERIFY_READ, context, sizeof(struct sigctx_irix5)))
|
|
|
|
goto badframe;
|
|
|
|
|
|
|
|
#ifdef DEBUG_SIG
|
|
|
|
dump_irix5_sigctx(context);
|
|
|
|
#endif
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
error = __get_user(regs->cp0_epc, &context->pc);
|
|
|
|
error |= __get_user(umask, &context->rmask);
|
|
|
|
|
|
|
|
mask = 2;
|
2005-04-17 00:20:36 +02:00
|
|
|
for (i = 1; i < 32; i++, mask <<= 1) {
|
2005-03-01 20:22:29 +01:00
|
|
|
if (umask & mask)
|
|
|
|
error |= __get_user(regs->regs[i], &context->regs[i]);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2005-03-01 20:22:29 +01:00
|
|
|
error |= __get_user(regs->hi, &context->hi);
|
|
|
|
error |= __get_user(regs->lo, &context->lo);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
error |= __get_user(usedfp, &context->usedfp);
|
|
|
|
if ((umask & 1) && usedfp) {
|
2005-04-17 00:20:36 +02:00
|
|
|
fregs = (u64 *) ¤t->thread.fpu;
|
2005-03-01 20:22:29 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
for(i = 0; i < 32; i++)
|
2005-03-01 20:22:29 +01:00
|
|
|
error |= __get_user(fregs[i], &context->fpregs[i]);
|
2006-05-15 18:26:03 +02:00
|
|
|
error |= __get_user(current->thread.fpu.fcr31, &context->fpcsr);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX do sigstack crapola here... XXX */
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
error |= __copy_from_user(&blocked, &context->sigset, sizeof(blocked)) ? -EFAULT : 0;
|
|
|
|
|
|
|
|
if (error)
|
2005-04-17 00:20:36 +02:00
|
|
|
goto badframe;
|
|
|
|
|
|
|
|
sigdelsetmask(&blocked, ~_BLOCKABLE);
|
|
|
|
spin_lock_irq(¤t->sighand->siglock);
|
|
|
|
current->blocked = blocked;
|
|
|
|
recalc_sigpending();
|
|
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't let your children do this ...
|
|
|
|
*/
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"move\t$29,%0\n\t"
|
|
|
|
"j\tsyscall_exit"
|
|
|
|
:/* no outputs */
|
|
|
|
:"r" (®s));
|
|
|
|
/* Unreached */
|
|
|
|
|
|
|
|
badframe:
|
|
|
|
force_sig(SIGSEGV, current);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct sigact_irix5 {
|
|
|
|
int flags;
|
|
|
|
void (*handler)(int);
|
|
|
|
u32 sigset[4];
|
|
|
|
int _unused0[2];
|
|
|
|
};
|
|
|
|
|
2006-08-04 02:49:31 +02:00
|
|
|
#define SIG_SETMASK32 256 /* Goodie from SGI for BSD compatibility:
|
|
|
|
set only the low 32 bit of the sigset. */
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
#ifdef DEBUG_SIG
|
|
|
|
static inline void dump_sigact_irix5(struct sigact_irix5 *p)
|
|
|
|
{
|
|
|
|
printk("<f[%d] hndlr[%08lx] msk[%08lx]>", p->flags,
|
|
|
|
(unsigned long) p->handler,
|
|
|
|
(unsigned long) p->sigset[0]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
asmlinkage int
|
2005-03-01 20:22:29 +01:00
|
|
|
irix_sigaction(int sig, const struct sigaction __user *act,
|
|
|
|
struct sigaction __user *oact, void __user *trampoline)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct k_sigaction new_ka, old_ka;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
#ifdef DEBUG_SIG
|
|
|
|
printk(" (%d,%s,%s,%08lx) ", sig, (!new ? "0" : "NEW"),
|
|
|
|
(!old ? "0" : "OLD"), trampoline);
|
|
|
|
if(new) {
|
|
|
|
dump_sigact_irix5(new); printk(" ");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (act) {
|
|
|
|
sigset_t mask;
|
2005-03-01 20:22:29 +01:00
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!access_ok(VERIFY_READ, act, sizeof(*act)))
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EFAULT;
|
2005-03-01 20:22:29 +01:00
|
|
|
err = __get_user(new_ka.sa.sa_handler, &act->sa_handler);
|
|
|
|
err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
err |= __copy_from_user(&mask, &act->sa_mask, sizeof(sigset_t)) ? -EFAULT : 0;
|
|
|
|
if (err)
|
|
|
|
return err;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Hmmm... methinks IRIX libc always passes a valid trampoline
|
|
|
|
* value for all invocations of sigaction. Will have to
|
|
|
|
* investigate. POSIX POSIX, die die die...
|
|
|
|
*/
|
|
|
|
new_ka.sa_restorer = trampoline;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX Implement SIG_SETMASK32 for IRIX compatibility */
|
|
|
|
ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
|
|
|
|
|
|
|
|
if (!ret && oact) {
|
2005-03-01 20:22:29 +01:00
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
err = __put_user(old_ka.sa.sa_handler, &oact->sa_handler);
|
|
|
|
err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
|
|
|
|
err |= __copy_to_user(&oact->sa_mask, &old_ka.sa.sa_mask,
|
|
|
|
sizeof(sigset_t)) ? -EFAULT : 0;
|
|
|
|
if (err)
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
asmlinkage int irix_sigpending(irix_sigset_t __user *set)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
return do_sigpending(set, sizeof(*set));
|
|
|
|
}
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
asmlinkage int irix_sigprocmask(int how, irix_sigset_t __user *new,
|
|
|
|
irix_sigset_t __user *old)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
sigset_t oldbits, newbits;
|
|
|
|
|
|
|
|
if (new) {
|
|
|
|
if (!access_ok(VERIFY_READ, new, sizeof(*new)))
|
|
|
|
return -EFAULT;
|
2005-03-01 20:22:29 +01:00
|
|
|
if (__copy_from_user(&newbits, new, sizeof(unsigned long)*4))
|
|
|
|
return -EFAULT;
|
2005-04-17 00:20:36 +02:00
|
|
|
sigdelsetmask(&newbits, ~_BLOCKABLE);
|
|
|
|
|
|
|
|
spin_lock_irq(¤t->sighand->siglock);
|
|
|
|
oldbits = current->blocked;
|
|
|
|
|
|
|
|
switch(how) {
|
|
|
|
case 1:
|
|
|
|
sigorsets(&newbits, &oldbits, &newbits);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
sigandsets(&newbits, &oldbits, &newbits);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 256:
|
|
|
|
siginitset(&newbits, newbits.sig[0]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2007-11-15 02:00:06 +01:00
|
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
recalc_sigpending();
|
|
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
|
|
}
|
2005-03-01 20:22:29 +01:00
|
|
|
if (old)
|
|
|
|
return copy_to_user(old, ¤t->blocked,
|
|
|
|
sizeof(unsigned long)*4) ? -EFAULT : 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
asmlinkage int irix_sigsuspend(struct pt_regs *regs)
|
|
|
|
{
|
2006-08-03 22:53:10 +02:00
|
|
|
sigset_t newset;
|
2005-03-01 20:22:29 +01:00
|
|
|
sigset_t __user *uset;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
uset = (sigset_t __user *) regs->regs[4];
|
2005-04-17 00:20:36 +02:00
|
|
|
if (copy_from_user(&newset, uset, sizeof(sigset_t)))
|
|
|
|
return -EFAULT;
|
|
|
|
sigdelsetmask(&newset, ~_BLOCKABLE);
|
|
|
|
|
|
|
|
spin_lock_irq(¤t->sighand->siglock);
|
2006-08-03 22:53:10 +02:00
|
|
|
current->saved_sigmask = current->blocked;
|
2005-04-17 00:20:36 +02:00
|
|
|
current->blocked = newset;
|
|
|
|
recalc_sigpending();
|
|
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
|
|
|
2006-08-03 22:53:10 +02:00
|
|
|
current->state = TASK_INTERRUPTIBLE;
|
|
|
|
schedule();
|
|
|
|
set_thread_flag(TIF_RESTORE_SIGMASK);
|
|
|
|
return -ERESTARTNOHAND;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* hate hate hate... */
|
|
|
|
struct irix5_siginfo {
|
|
|
|
int sig, code, error;
|
|
|
|
union {
|
|
|
|
char unused[128 - (3 * 4)]; /* Safety net. */
|
|
|
|
struct {
|
|
|
|
int pid;
|
|
|
|
union {
|
|
|
|
int uid;
|
|
|
|
struct {
|
|
|
|
int utime, status, stime;
|
|
|
|
} child;
|
|
|
|
} procdata;
|
|
|
|
} procinfo;
|
|
|
|
|
|
|
|
unsigned long fault_addr;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
int fd;
|
|
|
|
long band;
|
|
|
|
} fileinfo;
|
|
|
|
|
|
|
|
unsigned long sigval;
|
|
|
|
} stuff;
|
|
|
|
};
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
asmlinkage int irix_sigpoll_sys(unsigned long __user *set,
|
|
|
|
struct irix5_siginfo __user *info, struct timespec __user *tp)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
long expire = MAX_SCHEDULE_TIMEOUT;
|
|
|
|
sigset_t kset;
|
|
|
|
int i, sig, error, timeo = 0;
|
2005-03-01 20:22:29 +01:00
|
|
|
struct timespec ktp;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#ifdef DEBUG_SIG
|
|
|
|
printk("[%s:%d] irix_sigpoll_sys(%p,%p,%p)\n",
|
|
|
|
current->comm, current->pid, set, info, tp);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Must always specify the signal set. */
|
|
|
|
if (!set)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
if (copy_from_user(&kset, set, sizeof(set)))
|
|
|
|
return -EFAULT;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if (info && clear_user(info, sizeof(*info))) {
|
|
|
|
error = -EFAULT;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tp) {
|
2005-03-01 20:22:29 +01:00
|
|
|
if (copy_from_user(&ktp, tp, sizeof(*tp)))
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EFAULT;
|
2005-03-01 20:22:29 +01:00
|
|
|
|
|
|
|
if (!ktp.tv_sec && !ktp.tv_nsec)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
expire = timespec_to_jiffies(&ktp) +
|
|
|
|
(ktp.tv_sec || ktp.tv_nsec);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
long tmp = 0;
|
|
|
|
|
2005-11-05 12:26:43 +01:00
|
|
|
expire = schedule_timeout_interruptible(expire);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2007-10-29 16:00:37 +01:00
|
|
|
for (i=0; i < _IRIX_NSIG_WORDS; i++)
|
2005-04-17 00:20:36 +02:00
|
|
|
tmp |= (current->pending.signal.sig[i] & kset.sig[i]);
|
|
|
|
|
|
|
|
if (tmp)
|
|
|
|
break;
|
|
|
|
if (!expire) {
|
|
|
|
timeo = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (signal_pending(current))
|
|
|
|
return -EINTR;
|
|
|
|
}
|
|
|
|
if (timeo)
|
|
|
|
return -EAGAIN;
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
for (sig = 1; i <= 65 /* IRIX_NSIG */; sig++) {
|
2005-04-17 00:20:36 +02:00
|
|
|
if (sigismember (&kset, sig))
|
|
|
|
continue;
|
|
|
|
if (sigismember (¤t->pending.signal, sig)) {
|
|
|
|
/* XXX need more than this... */
|
|
|
|
if (info)
|
2005-03-01 20:22:29 +01:00
|
|
|
return copy_to_user(&info->sig, &sig, sizeof(sig));
|
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Should not get here, but do something sane if we do. */
|
|
|
|
error = -EINTR;
|
|
|
|
|
|
|
|
out:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is here because of irix5_siginfo definition. */
|
|
|
|
#define IRIX_P_PID 0
|
|
|
|
#define IRIX_P_PGID 2
|
|
|
|
#define IRIX_P_ALL 7
|
|
|
|
|
|
|
|
#define W_EXITED 1
|
|
|
|
#define W_TRAPPED 2
|
|
|
|
#define W_STOPPED 4
|
|
|
|
#define W_CONT 8
|
|
|
|
#define W_NOHANG 64
|
|
|
|
|
|
|
|
#define W_MASK (W_EXITED | W_TRAPPED | W_STOPPED | W_CONT | W_NOHANG)
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
asmlinkage int irix_waitsys(int type, int pid,
|
|
|
|
struct irix5_siginfo __user *info, int options,
|
|
|
|
struct rusage __user *ru)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
int flag, retval;
|
|
|
|
DECLARE_WAITQUEUE(wait, current);
|
|
|
|
struct task_struct *tsk;
|
|
|
|
struct task_struct *p;
|
|
|
|
struct list_head *_p;
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
if (!info)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!access_ok(VERIFY_WRITE, info, sizeof(*info)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
if (ru)
|
|
|
|
if (!access_ok(VERIFY_WRITE, ru, sizeof(*ru)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
if (options & ~W_MASK)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (type != IRIX_P_PID && type != IRIX_P_PGID && type != IRIX_P_ALL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
add_wait_queue(¤t->signal->wait_chldexit, &wait);
|
|
|
|
repeat:
|
|
|
|
flag = 0;
|
|
|
|
current->state = TASK_INTERRUPTIBLE;
|
|
|
|
read_lock(&tasklist_lock);
|
|
|
|
tsk = current;
|
2007-10-12 00:46:15 +02:00
|
|
|
list_for_each(_p, &tsk->children) {
|
|
|
|
p = list_entry(_p, struct task_struct, sibling);
|
2005-04-17 00:20:36 +02:00
|
|
|
if ((type == IRIX_P_PID) && p->pid != pid)
|
|
|
|
continue;
|
2007-10-19 08:39:46 +02:00
|
|
|
if ((type == IRIX_P_PGID) && task_pgrp_nr(p) != pid)
|
2005-04-17 00:20:36 +02:00
|
|
|
continue;
|
|
|
|
if ((p->exit_signal != SIGCHLD))
|
|
|
|
continue;
|
|
|
|
flag = 1;
|
|
|
|
switch (p->state) {
|
|
|
|
case TASK_STOPPED:
|
|
|
|
if (!p->exit_code)
|
|
|
|
continue;
|
|
|
|
if (!(options & (W_TRAPPED|W_STOPPED)) &&
|
|
|
|
!(p->ptrace & PT_PTRACED))
|
|
|
|
continue;
|
|
|
|
read_unlock(&tasklist_lock);
|
|
|
|
|
|
|
|
/* move to end of parent's list to avoid starvation */
|
|
|
|
write_lock_irq(&tasklist_lock);
|
|
|
|
remove_parent(p);
|
2006-03-29 02:11:05 +02:00
|
|
|
add_parent(p);
|
2005-04-17 00:20:36 +02:00
|
|
|
write_unlock_irq(&tasklist_lock);
|
|
|
|
retval = ru ? getrusage(p, RUSAGE_BOTH, ru) : 0;
|
2005-03-01 20:22:29 +01:00
|
|
|
if (retval)
|
|
|
|
goto end_waitsys;
|
|
|
|
|
|
|
|
retval = __put_user(SIGCHLD, &info->sig);
|
|
|
|
retval |= __put_user(0, &info->code);
|
|
|
|
retval |= __put_user(p->pid, &info->stuff.procinfo.pid);
|
|
|
|
retval |= __put_user((p->exit_code >> 8) & 0xff,
|
|
|
|
&info->stuff.procinfo.procdata.child.status);
|
|
|
|
retval |= __put_user(p->utime, &info->stuff.procinfo.procdata.child.utime);
|
|
|
|
retval |= __put_user(p->stime, &info->stuff.procinfo.procdata.child.stime);
|
|
|
|
if (retval)
|
|
|
|
goto end_waitsys;
|
|
|
|
|
|
|
|
p->exit_code = 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
goto end_waitsys;
|
|
|
|
|
|
|
|
case EXIT_ZOMBIE:
|
|
|
|
current->signal->cutime += p->utime + p->signal->cutime;
|
|
|
|
current->signal->cstime += p->stime + p->signal->cstime;
|
|
|
|
if (ru != NULL)
|
|
|
|
getrusage(p, RUSAGE_BOTH, ru);
|
2005-03-01 20:22:29 +01:00
|
|
|
retval = __put_user(SIGCHLD, &info->sig);
|
|
|
|
retval |= __put_user(1, &info->code); /* CLD_EXITED */
|
|
|
|
retval |= __put_user(p->pid, &info->stuff.procinfo.pid);
|
|
|
|
retval |= __put_user((p->exit_code >> 8) & 0xff,
|
2005-04-17 00:20:36 +02:00
|
|
|
&info->stuff.procinfo.procdata.child.status);
|
2005-03-01 20:22:29 +01:00
|
|
|
retval |= __put_user(p->utime,
|
2005-04-17 00:20:36 +02:00
|
|
|
&info->stuff.procinfo.procdata.child.utime);
|
2005-03-01 20:22:29 +01:00
|
|
|
retval |= __put_user(p->stime,
|
2005-04-17 00:20:36 +02:00
|
|
|
&info->stuff.procinfo.procdata.child.stime);
|
2005-03-01 20:22:29 +01:00
|
|
|
if (retval)
|
|
|
|
return retval;
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (p->real_parent != p->parent) {
|
|
|
|
write_lock_irq(&tasklist_lock);
|
|
|
|
remove_parent(p);
|
|
|
|
p->parent = p->real_parent;
|
2006-03-29 02:11:05 +02:00
|
|
|
add_parent(p);
|
2005-04-17 00:20:36 +02:00
|
|
|
do_notify_parent(p, SIGCHLD);
|
|
|
|
write_unlock_irq(&tasklist_lock);
|
|
|
|
} else
|
|
|
|
release_task(p);
|
|
|
|
goto end_waitsys;
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
tsk = next_thread(tsk);
|
|
|
|
}
|
|
|
|
read_unlock(&tasklist_lock);
|
|
|
|
if (flag) {
|
|
|
|
retval = 0;
|
|
|
|
if (options & W_NOHANG)
|
|
|
|
goto end_waitsys;
|
|
|
|
retval = -ERESTARTSYS;
|
|
|
|
if (signal_pending(current))
|
|
|
|
goto end_waitsys;
|
|
|
|
current->state = TASK_INTERRUPTIBLE;
|
|
|
|
schedule();
|
|
|
|
goto repeat;
|
|
|
|
}
|
|
|
|
retval = -ECHILD;
|
|
|
|
end_waitsys:
|
|
|
|
current->state = TASK_RUNNING;
|
|
|
|
remove_wait_queue(¤t->signal->wait_chldexit, &wait);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct irix5_context {
|
|
|
|
u32 flags;
|
|
|
|
u32 link;
|
|
|
|
u32 sigmask[4];
|
|
|
|
struct { u32 sp, size, flags; } stack;
|
|
|
|
int regs[36];
|
|
|
|
u32 fpregs[32];
|
|
|
|
u32 fpcsr;
|
|
|
|
u32 _unused0;
|
|
|
|
u32 _unused1[47];
|
|
|
|
u32 weird_graphics_thing;
|
|
|
|
};
|
|
|
|
|
|
|
|
asmlinkage int irix_getcontext(struct pt_regs *regs)
|
|
|
|
{
|
2005-03-01 20:22:29 +01:00
|
|
|
int error, i, base = 0;
|
|
|
|
struct irix5_context __user *ctx;
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (regs->regs[2] == 1000)
|
|
|
|
base = 1;
|
2005-03-01 20:22:29 +01:00
|
|
|
ctx = (struct irix5_context __user *) regs->regs[base + 4];
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#ifdef DEBUG_SIG
|
|
|
|
printk("[%s:%d] irix_getcontext(%p)\n",
|
|
|
|
current->comm, current->pid, ctx);
|
|
|
|
#endif
|
|
|
|
|
2007-08-16 00:03:01 +02:00
|
|
|
if (!access_ok(VERIFY_WRITE, ctx, sizeof(*ctx)))
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EFAULT;
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
error = __put_user(current->thread.irix_oldctx, &ctx->link);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
error |= __copy_to_user(&ctx->sigmask, ¤t->blocked, sizeof(irix_sigset_t)) ? -EFAULT : 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* XXX Do sigstack stuff someday... */
|
2005-03-01 20:22:29 +01:00
|
|
|
error |= __put_user(0, &ctx->stack.sp);
|
|
|
|
error |= __put_user(0, &ctx->stack.size);
|
|
|
|
error |= __put_user(0, &ctx->stack.flags);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
error |= __put_user(0, &ctx->weird_graphics_thing);
|
|
|
|
error |= __put_user(0, &ctx->regs[0]);
|
2005-04-17 00:20:36 +02:00
|
|
|
for (i = 1; i < 32; i++)
|
2005-03-01 20:22:29 +01:00
|
|
|
error |= __put_user(regs->regs[i], &ctx->regs[i]);
|
|
|
|
error |= __put_user(regs->lo, &ctx->regs[32]);
|
|
|
|
error |= __put_user(regs->hi, &ctx->regs[33]);
|
|
|
|
error |= __put_user(regs->cp0_cause, &ctx->regs[34]);
|
|
|
|
error |= __put_user(regs->cp0_epc, &ctx->regs[35]);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
flags = 0x0f;
|
|
|
|
if (!used_math()) {
|
|
|
|
flags &= ~(0x08);
|
|
|
|
} else {
|
|
|
|
/* XXX wheee... */
|
|
|
|
printk("Wheee, no code for saving IRIX FPU context yet.\n");
|
|
|
|
}
|
2005-03-01 20:22:29 +01:00
|
|
|
error |= __put_user(flags, &ctx->flags);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
return error;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
asmlinkage void irix_setcontext(struct pt_regs *regs)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2005-03-01 20:22:29 +01:00
|
|
|
struct irix5_context __user *ctx;
|
|
|
|
int err, base = 0;
|
|
|
|
u32 flags;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
if (regs->regs[2] == 1000)
|
2005-04-17 00:20:36 +02:00
|
|
|
base = 1;
|
2005-03-01 20:22:29 +01:00
|
|
|
ctx = (struct irix5_context __user *) regs->regs[base + 4];
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#ifdef DEBUG_SIG
|
|
|
|
printk("[%s:%d] irix_setcontext(%p)\n",
|
|
|
|
current->comm, current->pid, ctx);
|
|
|
|
#endif
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
if (!access_ok(VERIFY_READ, ctx, sizeof(*ctx)))
|
|
|
|
goto segv_and_exit;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
err = __get_user(flags, &ctx->flags);
|
|
|
|
if (flags & 0x02) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/* XXX sigstack garbage, todo... */
|
|
|
|
printk("Wheee, cannot do sigstack stuff in setcontext\n");
|
|
|
|
}
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
if (flags & 0x04) {
|
2005-04-17 00:20:36 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* XXX extra control block stuff... todo... */
|
2005-03-01 20:22:29 +01:00
|
|
|
for (i = 1; i < 32; i++)
|
|
|
|
err |= __get_user(regs->regs[i], &ctx->regs[i]);
|
|
|
|
err |= __get_user(regs->lo, &ctx->regs[32]);
|
|
|
|
err |= __get_user(regs->hi, &ctx->regs[33]);
|
|
|
|
err |= __get_user(regs->cp0_epc, &ctx->regs[35]);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
if (flags & 0x08)
|
2005-04-17 00:20:36 +02:00
|
|
|
/* XXX fpu context, blah... */
|
2005-03-01 20:22:29 +01:00
|
|
|
printk(KERN_ERR "Wheee, cannot restore FPU context yet...\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
err |= __get_user(current->thread.irix_oldctx, &ctx->link);
|
|
|
|
if (err)
|
|
|
|
goto segv_and_exit;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't let your children do this ...
|
|
|
|
*/
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"move\t$29,%0\n\t"
|
|
|
|
"j\tsyscall_exit"
|
|
|
|
:/* no outputs */
|
|
|
|
:"r" (®s));
|
|
|
|
/* Unreached */
|
|
|
|
|
|
|
|
segv_and_exit:
|
|
|
|
force_sigsegv(SIGSEGV, current);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
struct irix_sigstack {
|
|
|
|
unsigned long sp;
|
|
|
|
int status;
|
|
|
|
};
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
asmlinkage int irix_sigstack(struct irix_sigstack __user *new,
|
|
|
|
struct irix_sigstack __user *old)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
#ifdef DEBUG_SIG
|
|
|
|
printk("[%s:%d] irix_sigstack(%p,%p)\n",
|
|
|
|
current->comm, current->pid, new, old);
|
|
|
|
#endif
|
2005-03-01 20:22:29 +01:00
|
|
|
if (new) {
|
2005-04-17 00:20:36 +02:00
|
|
|
if (!access_ok(VERIFY_READ, new, sizeof(*new)))
|
2005-03-01 20:22:29 +01:00
|
|
|
return -EFAULT;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
if (old) {
|
2005-04-17 00:20:36 +02:00
|
|
|
if (!access_ok(VERIFY_WRITE, old, sizeof(*old)))
|
2005-03-01 20:22:29 +01:00
|
|
|
return -EFAULT;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
struct irix_sigaltstack { unsigned long sp; int size; int status; };
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
asmlinkage int irix_sigaltstack(struct irix_sigaltstack __user *new,
|
|
|
|
struct irix_sigaltstack __user *old)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
#ifdef DEBUG_SIG
|
|
|
|
printk("[%s:%d] irix_sigaltstack(%p,%p)\n",
|
|
|
|
current->comm, current->pid, new, old);
|
|
|
|
#endif
|
2005-03-01 20:22:29 +01:00
|
|
|
if (new)
|
2005-04-17 00:20:36 +02:00
|
|
|
if (!access_ok(VERIFY_READ, new, sizeof(*new)))
|
2005-03-01 20:22:29 +01:00
|
|
|
return -EFAULT;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if (old) {
|
|
|
|
if (!access_ok(VERIFY_WRITE, old, sizeof(*old)))
|
2005-03-01 20:22:29 +01:00
|
|
|
return -EFAULT;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
struct irix_procset {
|
|
|
|
int cmd, ltype, lid, rtype, rid;
|
|
|
|
};
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
asmlinkage int irix_sigsendset(struct irix_procset __user *pset, int sig)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
if (!access_ok(VERIFY_READ, pset, sizeof(*pset)))
|
|
|
|
return -EFAULT;
|
|
|
|
#ifdef DEBUG_SIG
|
|
|
|
printk("[%s:%d] irix_sigsendset([%d,%d,%d,%d,%d],%d)\n",
|
|
|
|
current->comm, current->pid,
|
|
|
|
pset->cmd, pset->ltype, pset->lid, pset->rtype, pset->rid,
|
|
|
|
sig);
|
|
|
|
#endif
|
|
|
|
return -EINVAL;
|
|
|
|
}
|