1 /* $Id: signal32.c,v 1.74 2002/02/09 19:49:30 davem Exp $
2 * arch/sparc64/kernel/signal32.c
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
7 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
8 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
11 #include <linux/sched.h>
12 #include <linux/kernel.h>
13 #include <linux/signal.h>
14 #include <linux/errno.h>
15 #include <linux/wait.h>
16 #include <linux/ptrace.h>
17 #include <linux/unistd.h>
19 #include <linux/tty.h>
20 #include <linux/smp_lock.h>
21 #include <linux/binfmts.h>
22 #include <linux/compat.h>
23 #include <linux/bitops.h>
25 #include <asm/uaccess.h>
26 #include <asm/ptrace.h>
28 #include <asm/pgtable.h>
29 #include <asm/psrcompat.h>
30 #include <asm/fpumacro.h>
31 #include <asm/visasm.h>
33 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
35 int do_signal32(sigset_t *oldset, struct pt_regs *regs,
36 unsigned long orig_o0, int ret_from_syscall);
38 /* Signal frames: the original one (compatible with SunOS):
40 * Set up a signal frame... Make the stack look the way SunOS
41 * expects it to look which is basically:
43 * ---------------------------------- <-- %sp at signal time
46 * Ptr to sigcontext area above
48 * The signal number itself
50 * ---------------------------------- <-- New %sp
52 struct signal_sframe32 {
53 struct reg_window32 sig_window;
56 /* struct sigcontext32 * */ u32 sig_scptr;
58 struct sigcontext32 sig_context;
59 unsigned int extramask[_COMPAT_NSIG_WORDS - 1];
62 /* This magic should be in g_upper[0] for all upper parts
65 #define SIGINFO_EXTRA_V8PLUS_MAGIC 0x130e269
67 unsigned int g_upper[8];
68 unsigned int o_upper[8];
70 } siginfo_extra_v8plus_t;
73 * And the new one, intended to be used for Linux applications only
74 * (we have enough in there to work with clone).
75 * All the interesting bits are in the info field.
77 struct new_signal_frame32 {
78 struct sparc_stackf32 ss;
80 /* __siginfo_fpu32_t * */ u32 fpu_save;
81 unsigned int insns[2];
82 unsigned int extramask[_COMPAT_NSIG_WORDS - 1];
83 unsigned int extra_size; /* Should be sizeof(siginfo_extra_v8plus_t) */
84 /* Only valid if (info.si_regs.psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS */
85 siginfo_extra_v8plus_t v8plus;
86 __siginfo_fpu_t fpu_state;
89 typedef struct compat_siginfo{
95 int _pad[SI_PAD_SIZE32];
99 compat_pid_t _pid; /* sender's pid */
100 unsigned int _uid; /* sender's uid */
103 /* POSIX.1b timers */
105 compat_timer_t _tid; /* timer id */
106 int _overrun; /* overrun count */
107 compat_sigval_t _sigval; /* same as below */
108 int _sys_private; /* not to be passed to user */
111 /* POSIX.1b signals */
113 compat_pid_t _pid; /* sender's pid */
114 unsigned int _uid; /* sender's uid */
115 compat_sigval_t _sigval;
120 compat_pid_t _pid; /* which child */
121 unsigned int _uid; /* sender's uid */
122 int _status; /* exit code */
123 compat_clock_t _utime;
124 compat_clock_t _stime;
127 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */
129 u32 _addr; /* faulting insn/memory ref. */
135 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
141 struct rt_signal_frame32 {
142 struct sparc_stackf32 ss;
143 compat_siginfo_t info;
144 struct pt_regs32 regs;
145 compat_sigset_t mask;
146 /* __siginfo_fpu32_t * */ u32 fpu_save;
147 unsigned int insns[2];
149 unsigned int extra_size; /* Should be sizeof(siginfo_extra_v8plus_t) */
150 /* Only valid if (regs.psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS */
151 siginfo_extra_v8plus_t v8plus;
152 __siginfo_fpu_t fpu_state;
156 #define SF_ALIGNEDSZ (((sizeof(struct signal_sframe32) + 7) & (~7)))
157 #define NF_ALIGNEDSZ (((sizeof(struct new_signal_frame32) + 7) & (~7)))
158 #define RT_ALIGNEDSZ (((sizeof(struct rt_signal_frame32) + 7) & (~7)))
160 int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from)
164 if (!access_ok(VERIFY_WRITE, to, sizeof(compat_siginfo_t)))
167 /* If you change siginfo_t structure, please be sure
168 this code is fixed accordingly.
169 It should never copy any pad contained in the structure
170 to avoid security leaks, but must copy the generic
171 3 ints plus the relevant union member.
172 This routine must convert siginfo from 64bit to 32bit as well
174 err = __put_user(from->si_signo, &to->si_signo);
175 err |= __put_user(from->si_errno, &to->si_errno);
176 err |= __put_user((short)from->si_code, &to->si_code);
177 if (from->si_code < 0)
178 err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
180 switch (from->si_code >> 16) {
181 case __SI_TIMER >> 16:
182 err |= __put_user(from->si_tid, &to->si_tid);
183 err |= __put_user(from->si_overrun, &to->si_overrun);
184 err |= __put_user(from->si_int, &to->si_int);
186 case __SI_CHLD >> 16:
187 err |= __put_user(from->si_utime, &to->si_utime);
188 err |= __put_user(from->si_stime, &to->si_stime);
189 err |= __put_user(from->si_status, &to->si_status);
191 err |= __put_user(from->si_pid, &to->si_pid);
192 err |= __put_user(from->si_uid, &to->si_uid);
194 case __SI_FAULT >> 16:
195 err |= __put_user(from->si_trapno, &to->si_trapno);
196 err |= __put_user((unsigned long)from->si_addr, &to->si_addr);
198 case __SI_POLL >> 16:
199 err |= __put_user(from->si_band, &to->si_band);
200 err |= __put_user(from->si_fd, &to->si_fd);
202 case __SI_RT >> 16: /* This is not generated by the kernel as of now. */
203 case __SI_MESGQ >> 16:
204 err |= __put_user(from->si_pid, &to->si_pid);
205 err |= __put_user(from->si_uid, &to->si_uid);
206 err |= __put_user(from->si_int, &to->si_int);
213 /* CAUTION: This is just a very minimalist implementation for the
214 * sake of compat_sys_rt_sigqueueinfo()
216 int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
218 if (!access_ok(VERIFY_WRITE, from, sizeof(compat_siginfo_t)))
221 if (copy_from_user(to, from, 3*sizeof(int)) ||
222 copy_from_user(to->_sifields._pad, from->_sifields._pad,
230 * atomically swap in the new signal mask, and wait for a signal.
231 * This is really tricky on the Sparc, watch out...
233 asmlinkage void _sigpause32_common(compat_old_sigset_t set, struct pt_regs *regs)
238 spin_lock_irq(¤t->sighand->siglock);
239 saveset = current->blocked;
240 siginitset(¤t->blocked, set);
242 spin_unlock_irq(¤t->sighand->siglock);
244 regs->tpc = regs->tnpc;
246 if (test_thread_flag(TIF_32BIT)) {
247 regs->tpc &= 0xffffffff;
248 regs->tnpc &= 0xffffffff;
251 /* Condition codes and return value where set here for sigpause,
252 * and so got used by setup_frame, which again causes sigreturn()
256 current->state = TASK_INTERRUPTIBLE;
259 * Return -EINTR and set condition code here,
260 * so the interrupted system call actually returns
263 regs->tstate |= TSTATE_ICARRY;
264 regs->u_regs[UREG_I0] = EINTR;
265 if (do_signal32(&saveset, regs, 0, 0))
270 asmlinkage void do_rt_sigsuspend32(u32 uset, size_t sigsetsize, struct pt_regs *regs)
272 sigset_t oldset, set;
273 compat_sigset_t set32;
275 /* XXX: Don't preclude handling different sized sigset_t's. */
276 if (((compat_size_t)sigsetsize) != sizeof(sigset_t)) {
277 regs->tstate |= TSTATE_ICARRY;
278 regs->u_regs[UREG_I0] = EINVAL;
281 if (copy_from_user(&set32, compat_ptr(uset), sizeof(set32))) {
282 regs->tstate |= TSTATE_ICARRY;
283 regs->u_regs[UREG_I0] = EFAULT;
286 switch (_NSIG_WORDS) {
287 case 4: set.sig[3] = set32.sig[6] + (((long)set32.sig[7]) << 32);
288 case 3: set.sig[2] = set32.sig[4] + (((long)set32.sig[5]) << 32);
289 case 2: set.sig[1] = set32.sig[2] + (((long)set32.sig[3]) << 32);
290 case 1: set.sig[0] = set32.sig[0] + (((long)set32.sig[1]) << 32);
292 sigdelsetmask(&set, ~_BLOCKABLE);
293 spin_lock_irq(¤t->sighand->siglock);
294 oldset = current->blocked;
295 current->blocked = set;
297 spin_unlock_irq(¤t->sighand->siglock);
299 regs->tpc = regs->tnpc;
301 if (test_thread_flag(TIF_32BIT)) {
302 regs->tpc &= 0xffffffff;
303 regs->tnpc &= 0xffffffff;
306 /* Condition codes and return value where set here for sigpause,
307 * and so got used by setup_frame, which again causes sigreturn()
311 current->state = TASK_INTERRUPTIBLE;
314 * Return -EINTR and set condition code here,
315 * so the interrupted system call actually returns
318 regs->tstate |= TSTATE_ICARRY;
319 regs->u_regs[UREG_I0] = EINTR;
320 if (do_signal32(&oldset, regs, 0, 0))
325 static int restore_fpu_state32(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
327 unsigned long *fpregs = current_thread_info()->fpregs;
331 err = __get_user(fprs, &fpu->si_fprs);
333 regs->tstate &= ~TSTATE_PEF;
335 err |= copy_from_user(fpregs, &fpu->si_float_regs[0], (sizeof(unsigned int) * 32));
337 err |= copy_from_user(fpregs+16, &fpu->si_float_regs[32], (sizeof(unsigned int) * 32));
338 err |= __get_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
339 err |= __get_user(current_thread_info()->gsr[0], &fpu->si_gsr);
340 current_thread_info()->fpsaved[0] |= fprs;
344 void do_new_sigreturn32(struct pt_regs *regs)
346 struct new_signal_frame32 __user *sf;
348 unsigned pc, npc, fpu_save;
350 unsigned seta[_COMPAT_NSIG_WORDS];
353 regs->u_regs[UREG_FP] &= 0x00000000ffffffffUL;
354 sf = (struct new_signal_frame32 __user *) regs->u_regs[UREG_FP];
356 /* 1. Make sure we are not getting garbage from the user */
357 if (!access_ok(VERIFY_READ, sf, sizeof(*sf)) ||
358 (((unsigned long) sf) & 3))
361 get_user(pc, &sf->info.si_regs.pc);
362 __get_user(npc, &sf->info.si_regs.npc);
367 if (test_thread_flag(TIF_32BIT)) {
374 /* 2. Restore the state */
375 err = __get_user(regs->y, &sf->info.si_regs.y);
376 err |= __get_user(psr, &sf->info.si_regs.psr);
378 for (i = UREG_G1; i <= UREG_I7; i++)
379 err |= __get_user(regs->u_regs[i], &sf->info.si_regs.u_regs[i]);
380 if ((psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS) {
381 err |= __get_user(i, &sf->v8plus.g_upper[0]);
382 if (i == SIGINFO_EXTRA_V8PLUS_MAGIC) {
385 for (i = UREG_G1; i <= UREG_I7; i++)
386 err |= __get_user(((u32 *)regs->u_regs)[2*i], &sf->v8plus.g_upper[i]);
387 err |= __get_user(asi, &sf->v8plus.asi);
388 regs->tstate &= ~TSTATE_ASI;
389 regs->tstate |= ((asi & 0xffUL) << 24UL);
393 /* User can only change condition codes in %tstate. */
394 regs->tstate &= ~(TSTATE_ICC|TSTATE_XCC);
395 regs->tstate |= psr_to_tstate_icc(psr);
397 err |= __get_user(fpu_save, &sf->fpu_save);
399 err |= restore_fpu_state32(regs, &sf->fpu_state);
400 err |= __get_user(seta[0], &sf->info.si_mask);
401 err |= copy_from_user(seta+1, &sf->extramask,
402 (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int));
405 switch (_NSIG_WORDS) {
406 case 4: set.sig[3] = seta[6] + (((long)seta[7]) << 32);
407 case 3: set.sig[2] = seta[4] + (((long)seta[5]) << 32);
408 case 2: set.sig[1] = seta[2] + (((long)seta[3]) << 32);
409 case 1: set.sig[0] = seta[0] + (((long)seta[1]) << 32);
411 sigdelsetmask(&set, ~_BLOCKABLE);
412 spin_lock_irq(¤t->sighand->siglock);
413 current->blocked = set;
415 spin_unlock_irq(¤t->sighand->siglock);
419 force_sig(SIGSEGV, current);
422 asmlinkage void do_sigreturn32(struct pt_regs *regs)
424 struct sigcontext32 __user *scptr;
425 unsigned int pc, npc, psr;
427 unsigned int seta[_COMPAT_NSIG_WORDS];
430 /* Always make any pending restarted system calls return -EINTR */
431 current_thread_info()->restart_block.fn = do_no_restart_syscall;
433 synchronize_user_stack();
434 if (test_thread_flag(TIF_NEWSIGNALS)) {
435 do_new_sigreturn32(regs);
439 scptr = (struct sigcontext32 __user *)
440 (regs->u_regs[UREG_I0] & 0x00000000ffffffffUL);
441 /* Check sanity of the user arg. */
442 if (!access_ok(VERIFY_READ, scptr, sizeof(struct sigcontext32)) ||
443 (((unsigned long) scptr) & 3))
446 err = __get_user(pc, &scptr->sigc_pc);
447 err |= __get_user(npc, &scptr->sigc_npc);
450 goto segv; /* Nice try. */
452 err |= __get_user(seta[0], &scptr->sigc_mask);
453 /* Note that scptr + 1 points to extramask */
454 err |= copy_from_user(seta+1, scptr + 1,
455 (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int));
458 switch (_NSIG_WORDS) {
459 case 4: set.sig[3] = seta[6] + (((long)seta[7]) << 32);
460 case 3: set.sig[2] = seta[4] + (((long)seta[5]) << 32);
461 case 2: set.sig[1] = seta[2] + (((long)seta[3]) << 32);
462 case 1: set.sig[0] = seta[0] + (((long)seta[1]) << 32);
464 sigdelsetmask(&set, ~_BLOCKABLE);
465 spin_lock_irq(¤t->sighand->siglock);
466 current->blocked = set;
468 spin_unlock_irq(¤t->sighand->siglock);
470 if (test_thread_flag(TIF_32BIT)) {
476 err = __get_user(regs->u_regs[UREG_FP], &scptr->sigc_sp);
477 err |= __get_user(regs->u_regs[UREG_I0], &scptr->sigc_o0);
478 err |= __get_user(regs->u_regs[UREG_G1], &scptr->sigc_g1);
480 /* User can only change condition codes in %tstate. */
481 err |= __get_user(psr, &scptr->sigc_psr);
484 regs->tstate &= ~(TSTATE_ICC|TSTATE_XCC);
485 regs->tstate |= psr_to_tstate_icc(psr);
489 force_sig(SIGSEGV, current);
492 asmlinkage void do_rt_sigreturn32(struct pt_regs *regs)
494 struct rt_signal_frame32 __user *sf;
495 unsigned int psr, pc, npc, fpu_save, u_ss_sp;
498 compat_sigset_t seta;
502 /* Always make any pending restarted system calls return -EINTR */
503 current_thread_info()->restart_block.fn = do_no_restart_syscall;
505 synchronize_user_stack();
506 regs->u_regs[UREG_FP] &= 0x00000000ffffffffUL;
507 sf = (struct rt_signal_frame32 __user *) regs->u_regs[UREG_FP];
509 /* 1. Make sure we are not getting garbage from the user */
510 if (!access_ok(VERIFY_READ, sf, sizeof(*sf)) ||
511 (((unsigned long) sf) & 3))
514 get_user(pc, &sf->regs.pc);
515 __get_user(npc, &sf->regs.npc);
520 if (test_thread_flag(TIF_32BIT)) {
527 /* 2. Restore the state */
528 err = __get_user(regs->y, &sf->regs.y);
529 err |= __get_user(psr, &sf->regs.psr);
531 for (i = UREG_G1; i <= UREG_I7; i++)
532 err |= __get_user(regs->u_regs[i], &sf->regs.u_regs[i]);
533 if ((psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS) {
534 err |= __get_user(i, &sf->v8plus.g_upper[0]);
535 if (i == SIGINFO_EXTRA_V8PLUS_MAGIC) {
538 for (i = UREG_G1; i <= UREG_I7; i++)
539 err |= __get_user(((u32 *)regs->u_regs)[2*i], &sf->v8plus.g_upper[i]);
540 err |= __get_user(asi, &sf->v8plus.asi);
541 regs->tstate &= ~TSTATE_ASI;
542 regs->tstate |= ((asi & 0xffUL) << 24UL);
546 /* User can only change condition codes in %tstate. */
547 regs->tstate &= ~(TSTATE_ICC|TSTATE_XCC);
548 regs->tstate |= psr_to_tstate_icc(psr);
550 err |= __get_user(fpu_save, &sf->fpu_save);
552 err |= restore_fpu_state32(regs, &sf->fpu_state);
553 err |= copy_from_user(&seta, &sf->mask, sizeof(compat_sigset_t));
554 err |= __get_user(u_ss_sp, &sf->stack.ss_sp);
555 st.ss_sp = compat_ptr(u_ss_sp);
556 err |= __get_user(st.ss_flags, &sf->stack.ss_flags);
557 err |= __get_user(st.ss_size, &sf->stack.ss_size);
561 /* It is more difficult to avoid calling this function than to
562 call it and ignore errors. */
565 do_sigaltstack((stack_t __user *) &st, NULL, (unsigned long)sf);
568 switch (_NSIG_WORDS) {
569 case 4: set.sig[3] = seta.sig[6] + (((long)seta.sig[7]) << 32);
570 case 3: set.sig[2] = seta.sig[4] + (((long)seta.sig[5]) << 32);
571 case 2: set.sig[1] = seta.sig[2] + (((long)seta.sig[3]) << 32);
572 case 1: set.sig[0] = seta.sig[0] + (((long)seta.sig[1]) << 32);
574 sigdelsetmask(&set, ~_BLOCKABLE);
575 spin_lock_irq(¤t->sighand->siglock);
576 current->blocked = set;
578 spin_unlock_irq(¤t->sighand->siglock);
581 force_sig(SIGSEGV, current);
584 /* Checks if the fp is valid */
585 static int invalid_frame_pointer(void __user *fp, int fplen)
587 if ((((unsigned long) fp) & 7) || ((unsigned long)fp) > 0x100000000ULL - fplen)
592 static void __user *get_sigframe(struct sigaction *sa, struct pt_regs *regs, unsigned long framesize)
596 regs->u_regs[UREG_FP] &= 0x00000000ffffffffUL;
597 sp = regs->u_regs[UREG_FP];
599 /* This is the X/Open sanctioned signal stack switching. */
600 if (sa->sa_flags & SA_ONSTACK) {
601 if (!on_sig_stack(sp) && !((current->sas_ss_sp + current->sas_ss_size) & 7))
602 sp = current->sas_ss_sp + current->sas_ss_size;
604 return (void __user *)(sp - framesize);
608 setup_frame32(struct sigaction *sa, struct pt_regs *regs, int signr, sigset_t *oldset, siginfo_t *info)
610 struct signal_sframe32 __user *sframep;
611 struct sigcontext32 __user *sc;
612 unsigned int seta[_COMPAT_NSIG_WORDS];
614 void __user *sig_address;
616 unsigned long pc = regs->tpc;
617 unsigned long npc = regs->tnpc;
620 if (test_thread_flag(TIF_32BIT)) {
625 synchronize_user_stack();
626 save_and_clear_fpu();
628 sframep = (struct signal_sframe32 __user *)
629 get_sigframe(sa, regs, SF_ALIGNEDSZ);
630 if (invalid_frame_pointer(sframep, sizeof(*sframep))){
631 /* Don't change signal code and address, so that
632 * post mortem debuggers can have a look.
637 sc = &sframep->sig_context;
639 /* We've already made sure frame pointer isn't in kernel space... */
640 err = __put_user((sas_ss_flags(regs->u_regs[UREG_FP]) == SS_ONSTACK),
643 switch (_NSIG_WORDS) {
644 case 4: seta[7] = (oldset->sig[3] >> 32);
645 seta[6] = oldset->sig[3];
646 case 3: seta[5] = (oldset->sig[2] >> 32);
647 seta[4] = oldset->sig[2];
648 case 2: seta[3] = (oldset->sig[1] >> 32);
649 seta[2] = oldset->sig[1];
650 case 1: seta[1] = (oldset->sig[0] >> 32);
651 seta[0] = oldset->sig[0];
653 err |= __put_user(seta[0], &sc->sigc_mask);
654 err |= __copy_to_user(sframep->extramask, seta + 1,
655 (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int));
656 err |= __put_user(regs->u_regs[UREG_FP], &sc->sigc_sp);
657 err |= __put_user(pc, &sc->sigc_pc);
658 err |= __put_user(npc, &sc->sigc_npc);
659 psr = tstate_to_psr(regs->tstate);
660 if (current_thread_info()->fpsaved[0] & FPRS_FEF)
662 err |= __put_user(psr, &sc->sigc_psr);
663 err |= __put_user(regs->u_regs[UREG_G1], &sc->sigc_g1);
664 err |= __put_user(regs->u_regs[UREG_I0], &sc->sigc_o0);
665 err |= __put_user(get_thread_wsaved(), &sc->sigc_oswins);
667 err |= copy_in_user((u32 __user *)sframep,
668 (u32 __user *)(regs->u_regs[UREG_FP]),
669 sizeof(struct reg_window32));
671 set_thread_wsaved(0); /* So process is allowed to execute. */
672 err |= __put_user(signr, &sframep->sig_num);
675 if (SI_FROMKERNEL (info) && (info->si_code & __SI_MASK) == __SI_FAULT) {
676 sig_address = info->si_addr;
679 switch (info->si_code) {
680 case SEGV_MAPERR: sig_code = SUBSIG_NOMAPPING; break;
681 default: sig_code = SUBSIG_PROTECTION; break;
685 switch (info->si_code) {
686 case ILL_ILLOPC: sig_code = SUBSIG_ILLINST; break;
687 case ILL_PRVOPC: sig_code = SUBSIG_PRIVINST; break;
688 case ILL_ILLTRP: sig_code = SUBSIG_BADTRAP(info->si_trapno); break;
689 default: sig_code = SUBSIG_STACK; break;
693 switch (info->si_code) {
694 case FPE_INTDIV: sig_code = SUBSIG_IDIVZERO; break;
695 case FPE_INTOVF: sig_code = SUBSIG_FPINTOVFL; break;
696 case FPE_FLTDIV: sig_code = SUBSIG_FPDIVZERO; break;
697 case FPE_FLTOVF: sig_code = SUBSIG_FPOVFLOW; break;
698 case FPE_FLTUND: sig_code = SUBSIG_FPUNFLOW; break;
699 case FPE_FLTRES: sig_code = SUBSIG_FPINEXACT; break;
700 case FPE_FLTINV: sig_code = SUBSIG_FPOPERROR; break;
701 default: sig_code = SUBSIG_FPERROR; break;
705 switch (info->si_code) {
706 case BUS_ADRALN: sig_code = SUBSIG_ALIGNMENT; break;
707 case BUS_ADRERR: sig_code = SUBSIG_MISCERROR; break;
708 default: sig_code = SUBSIG_BUSTIMEOUT; break;
712 switch (info->si_code) {
713 case EMT_TAGOVF: sig_code = SUBSIG_TAG; break;
717 if (info->si_code == (__SI_FAULT|0x100)) {
718 /* See sys_sunos32.c */
719 sig_code = info->si_trapno;
726 err |= __put_user(ptr_to_compat(sig_address), &sframep->sig_address);
727 err |= __put_user(sig_code, &sframep->sig_code);
728 err |= __put_user(ptr_to_compat(sc), &sframep->sig_scptr);
732 regs->u_regs[UREG_FP] = (unsigned long) sframep;
733 regs->tpc = (unsigned long) sa->sa_handler;
734 regs->tnpc = (regs->tpc + 4);
735 if (test_thread_flag(TIF_32BIT)) {
736 regs->tpc &= 0xffffffff;
737 regs->tnpc &= 0xffffffff;
742 force_sigsegv(signr, current);
746 static int save_fpu_state32(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
748 unsigned long *fpregs = current_thread_info()->fpregs;
752 fprs = current_thread_info()->fpsaved[0];
754 err |= copy_to_user(&fpu->si_float_regs[0], fpregs,
755 (sizeof(unsigned int) * 32));
757 err |= copy_to_user(&fpu->si_float_regs[32], fpregs+16,
758 (sizeof(unsigned int) * 32));
759 err |= __put_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
760 err |= __put_user(current_thread_info()->gsr[0], &fpu->si_gsr);
761 err |= __put_user(fprs, &fpu->si_fprs);
766 static void new_setup_frame32(struct k_sigaction *ka, struct pt_regs *regs,
767 int signo, sigset_t *oldset)
769 struct new_signal_frame32 __user *sf;
773 unsigned int seta[_COMPAT_NSIG_WORDS];
775 /* 1. Make sure everything is clean */
776 synchronize_user_stack();
777 save_and_clear_fpu();
779 sigframe_size = NF_ALIGNEDSZ;
780 if (!(current_thread_info()->fpsaved[0] & FPRS_FEF))
781 sigframe_size -= sizeof(__siginfo_fpu_t);
783 sf = (struct new_signal_frame32 __user *)
784 get_sigframe(&ka->sa, regs, sigframe_size);
786 if (invalid_frame_pointer(sf, sigframe_size))
789 if (get_thread_wsaved() != 0)
792 /* 2. Save the current process state */
793 if (test_thread_flag(TIF_32BIT)) {
794 regs->tpc &= 0xffffffff;
795 regs->tnpc &= 0xffffffff;
797 err = put_user(regs->tpc, &sf->info.si_regs.pc);
798 err |= __put_user(regs->tnpc, &sf->info.si_regs.npc);
799 err |= __put_user(regs->y, &sf->info.si_regs.y);
800 psr = tstate_to_psr(regs->tstate);
801 if (current_thread_info()->fpsaved[0] & FPRS_FEF)
803 err |= __put_user(psr, &sf->info.si_regs.psr);
804 for (i = 0; i < 16; i++)
805 err |= __put_user(regs->u_regs[i], &sf->info.si_regs.u_regs[i]);
806 err |= __put_user(sizeof(siginfo_extra_v8plus_t), &sf->extra_size);
807 err |= __put_user(SIGINFO_EXTRA_V8PLUS_MAGIC, &sf->v8plus.g_upper[0]);
808 for (i = 1; i < 16; i++)
809 err |= __put_user(((u32 *)regs->u_regs)[2*i],
810 &sf->v8plus.g_upper[i]);
811 err |= __put_user((regs->tstate & TSTATE_ASI) >> 24UL,
815 err |= save_fpu_state32(regs, &sf->fpu_state);
816 err |= __put_user((u64)&sf->fpu_state, &sf->fpu_save);
818 err |= __put_user(0, &sf->fpu_save);
821 switch (_NSIG_WORDS) {
822 case 4: seta[7] = (oldset->sig[3] >> 32);
823 seta[6] = oldset->sig[3];
824 case 3: seta[5] = (oldset->sig[2] >> 32);
825 seta[4] = oldset->sig[2];
826 case 2: seta[3] = (oldset->sig[1] >> 32);
827 seta[2] = oldset->sig[1];
828 case 1: seta[1] = (oldset->sig[0] >> 32);
829 seta[0] = oldset->sig[0];
831 err |= __put_user(seta[0], &sf->info.si_mask);
832 err |= __copy_to_user(sf->extramask, seta + 1,
833 (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int));
835 err |= copy_in_user((u32 __user *)sf,
836 (u32 __user *)(regs->u_regs[UREG_FP]),
837 sizeof(struct reg_window32));
842 /* 3. signal handler back-trampoline and parameters */
843 regs->u_regs[UREG_FP] = (unsigned long) sf;
844 regs->u_regs[UREG_I0] = signo;
845 regs->u_regs[UREG_I1] = (unsigned long) &sf->info;
846 regs->u_regs[UREG_I2] = (unsigned long) &sf->info;
848 /* 4. signal handler */
849 regs->tpc = (unsigned long) ka->sa.sa_handler;
850 regs->tnpc = (regs->tpc + 4);
851 if (test_thread_flag(TIF_32BIT)) {
852 regs->tpc &= 0xffffffff;
853 regs->tnpc &= 0xffffffff;
856 /* 5. return to kernel instructions */
857 if (ka->ka_restorer) {
858 regs->u_regs[UREG_I7] = (unsigned long)ka->ka_restorer;
860 /* Flush instruction space. */
861 unsigned long address = ((unsigned long)&(sf->insns[0]));
862 pgd_t *pgdp = pgd_offset(current->mm, address);
863 pud_t *pudp = pud_offset(pgdp, address);
864 pmd_t *pmdp = pmd_offset(pudp, address);
867 regs->u_regs[UREG_I7] = (unsigned long) (&(sf->insns[0]) - 2);
869 err = __put_user(0x821020d8, &sf->insns[0]); /*mov __NR_sigreturn, %g1*/
870 err |= __put_user(0x91d02010, &sf->insns[1]); /*t 0x10*/
875 ptep = pte_offset_map(pmdp, address);
876 if (pte_present(*ptep)) {
877 unsigned long page = (unsigned long)
878 page_address(pte_page(*ptep));
881 __asm__ __volatile__("flush %0 + %1"
884 "r" (address & (PAGE_SIZE - 1))
895 force_sigsegv(signo, current);
898 /* Setup a Solaris stack frame */
900 setup_svr4_frame32(struct sigaction *sa, unsigned long pc, unsigned long npc,
901 struct pt_regs *regs, int signr, sigset_t *oldset)
903 svr4_signal_frame_t __user *sfp;
904 svr4_gregset_t __user *gr;
905 svr4_siginfo_t __user *si;
906 svr4_mcontext_t __user *mc;
907 svr4_gwindows_t __user *gw;
908 svr4_ucontext_t __user *uc;
913 synchronize_user_stack();
914 save_and_clear_fpu();
916 regs->u_regs[UREG_FP] &= 0x00000000ffffffffUL;
917 sfp = (svr4_signal_frame_t __user *)
918 get_sigframe(sa, regs,
919 sizeof(struct reg_window32) + SVR4_SF_ALIGNED);
921 if (invalid_frame_pointer(sfp, sizeof(*sfp)))
924 /* Start with a clean frame pointer and fill it */
925 err = clear_user(sfp, sizeof(*sfp));
927 /* Setup convenience variables */
934 /* FIXME: where am I supposed to put this?
935 * sc->sigc_onstack = old_status;
936 * anyways, it does not look like it is used for anything at all.
938 setv.sigbits[0] = oldset->sig[0];
939 setv.sigbits[1] = (oldset->sig[0] >> 32);
940 if (_NSIG_WORDS >= 2) {
941 setv.sigbits[2] = oldset->sig[1];
942 setv.sigbits[3] = (oldset->sig[1] >> 32);
943 err |= __copy_to_user(&uc->sigmask, &setv, sizeof(svr4_sigset_t));
945 err |= __copy_to_user(&uc->sigmask, &setv,
946 2 * sizeof(unsigned int));
948 /* Store registers */
949 if (test_thread_flag(TIF_32BIT)) {
950 regs->tpc &= 0xffffffff;
951 regs->tnpc &= 0xffffffff;
953 err |= __put_user(regs->tpc, &((*gr)[SVR4_PC]));
954 err |= __put_user(regs->tnpc, &((*gr)[SVR4_NPC]));
955 psr = tstate_to_psr(regs->tstate);
956 if (current_thread_info()->fpsaved[0] & FPRS_FEF)
958 err |= __put_user(psr, &((*gr)[SVR4_PSR]));
959 err |= __put_user(regs->y, &((*gr)[SVR4_Y]));
961 /* Copy g[1..7] and o[0..7] registers */
962 for (i = 0; i < 7; i++)
963 err |= __put_user(regs->u_regs[UREG_G1+i], (&(*gr)[SVR4_G1])+i);
964 for (i = 0; i < 8; i++)
965 err |= __put_user(regs->u_regs[UREG_I0+i], (&(*gr)[SVR4_O0])+i);
967 /* Setup sigaltstack */
968 err |= __put_user(current->sas_ss_sp, &uc->stack.sp);
969 err |= __put_user(sas_ss_flags(regs->u_regs[UREG_FP]), &uc->stack.flags);
970 err |= __put_user(current->sas_ss_size, &uc->stack.size);
972 /* Save the currently window file: */
974 /* 1. Link sfp->uc->gwins to our windows */
975 err |= __put_user(ptr_to_compat(gw), &mc->gwin);
977 /* 2. Number of windows to restore at setcontext (): */
978 err |= __put_user(get_thread_wsaved(), &gw->count);
980 /* 3. We just pay attention to the gw->count field on setcontext */
981 set_thread_wsaved(0); /* So process is allowed to execute. */
983 /* Setup the signal information. Solaris expects a bunch of
984 * information to be passed to the signal handler, we don't provide
985 * that much currently, should use siginfo.
987 err |= __put_user(signr, &si->siginfo.signo);
988 err |= __put_user(SVR4_SINOINFO, &si->siginfo.code);
992 regs->u_regs[UREG_FP] = (unsigned long) sfp;
993 regs->tpc = (unsigned long) sa->sa_handler;
994 regs->tnpc = (regs->tpc + 4);
995 if (test_thread_flag(TIF_32BIT)) {
996 regs->tpc &= 0xffffffff;
997 regs->tnpc &= 0xffffffff;
1000 /* Arguments passed to signal handler */
1001 if (regs->u_regs[14]){
1002 struct reg_window32 __user *rw = (struct reg_window32 __user *)
1003 (regs->u_regs[14] & 0x00000000ffffffffUL);
1005 err |= __put_user(signr, &rw->ins[0]);
1006 err |= __put_user((u64)si, &rw->ins[1]);
1007 err |= __put_user((u64)uc, &rw->ins[2]);
1008 err |= __put_user((u64)sfp, &rw->ins[6]); /* frame pointer */
1012 regs->u_regs[UREG_I0] = signr;
1013 regs->u_regs[UREG_I1] = (u32)(u64) si;
1014 regs->u_regs[UREG_I2] = (u32)(u64) uc;
1019 force_sigsegv(signr, current);
1023 svr4_getcontext(svr4_ucontext_t __user *uc, struct pt_regs *regs)
1025 svr4_gregset_t __user *gr;
1026 svr4_mcontext_t __user *mc;
1031 synchronize_user_stack();
1032 save_and_clear_fpu();
1034 if (get_thread_wsaved())
1037 err = clear_user(uc, sizeof(*uc));
1039 /* Setup convenience variables */
1043 setv.sigbits[0] = current->blocked.sig[0];
1044 setv.sigbits[1] = (current->blocked.sig[0] >> 32);
1045 if (_NSIG_WORDS >= 2) {
1046 setv.sigbits[2] = current->blocked.sig[1];
1047 setv.sigbits[3] = (current->blocked.sig[1] >> 32);
1048 err |= __copy_to_user(&uc->sigmask, &setv, sizeof(svr4_sigset_t));
1050 err |= __copy_to_user(&uc->sigmask, &setv, 2 * sizeof(unsigned));
1052 /* Store registers */
1053 if (test_thread_flag(TIF_32BIT)) {
1054 regs->tpc &= 0xffffffff;
1055 regs->tnpc &= 0xffffffff;
1057 err |= __put_user(regs->tpc, &uc->mcontext.greg[SVR4_PC]);
1058 err |= __put_user(regs->tnpc, &uc->mcontext.greg[SVR4_NPC]);
1060 psr = tstate_to_psr(regs->tstate) & ~PSR_EF;
1061 if (current_thread_info()->fpsaved[0] & FPRS_FEF)
1063 err |= __put_user(psr, &uc->mcontext.greg[SVR4_PSR]);
1065 err |= __put_user(regs->y, &uc->mcontext.greg[SVR4_Y]);
1067 /* Copy g[1..7] and o[0..7] registers */
1068 for (i = 0; i < 7; i++)
1069 err |= __put_user(regs->u_regs[UREG_G1+i], (&(*gr)[SVR4_G1])+i);
1070 for (i = 0; i < 8; i++)
1071 err |= __put_user(regs->u_regs[UREG_I0+i], (&(*gr)[SVR4_O0])+i);
1073 /* Setup sigaltstack */
1074 err |= __put_user(current->sas_ss_sp, &uc->stack.sp);
1075 err |= __put_user(sas_ss_flags(regs->u_regs[UREG_FP]), &uc->stack.flags);
1076 err |= __put_user(current->sas_ss_size, &uc->stack.size);
1078 /* The register file is not saved
1079 * we have already stuffed all of it with sync_user_stack
1081 return (err ? -EFAULT : 0);
1085 /* Set the context for a svr4 application, this is Solaris way to sigreturn */
1086 asmlinkage int svr4_setcontext(svr4_ucontext_t __user *c, struct pt_regs *regs)
1088 svr4_gregset_t __user *gr;
1089 mm_segment_t old_fs;
1090 u32 pc, npc, psr, u_ss_sp;
1096 /* Fixme: restore windows, or is this already taken care of in
1097 * svr4_setup_frame when sync_user_windows is done?
1099 flush_user_windows();
1101 if (get_thread_wsaved())
1104 if (((unsigned long) c) & 3){
1105 printk("Unaligned structure passed\n");
1109 if (!__access_ok(c, sizeof(*c))) {
1110 /* Miguel, add nice debugging msg _here_. ;-) */
1114 /* Check for valid PC and nPC */
1115 gr = &c->mcontext.greg;
1116 err = __get_user(pc, &((*gr)[SVR4_PC]));
1117 err |= __get_user(npc, &((*gr)[SVR4_NPC]));
1121 /* Retrieve information from passed ucontext */
1122 /* note that nPC is ored a 1, this is used to inform entry.S */
1123 /* that we don't want it to mess with our PC and nPC */
1125 err |= copy_from_user(&setv, &c->sigmask, sizeof(svr4_sigset_t));
1126 set.sig[0] = setv.sigbits[0] | (((long)setv.sigbits[1]) << 32);
1127 if (_NSIG_WORDS >= 2)
1128 set.sig[1] = setv.sigbits[2] | (((long)setv.sigbits[3]) << 32);
1130 err |= __get_user(u_ss_sp, &c->stack.sp);
1131 st.ss_sp = compat_ptr(u_ss_sp);
1132 err |= __get_user(st.ss_flags, &c->stack.flags);
1133 err |= __get_user(st.ss_size, &c->stack.size);
1137 /* It is more difficult to avoid calling this function than to
1138 call it and ignore errors. */
1141 do_sigaltstack((stack_t __user *) &st, NULL, regs->u_regs[UREG_I6]);
1144 sigdelsetmask(&set, ~_BLOCKABLE);
1145 spin_lock_irq(¤t->sighand->siglock);
1146 current->blocked = set;
1147 recalc_sigpending();
1148 spin_unlock_irq(¤t->sighand->siglock);
1150 regs->tnpc = npc | 1;
1151 if (test_thread_flag(TIF_32BIT)) {
1152 regs->tpc &= 0xffffffff;
1153 regs->tnpc &= 0xffffffff;
1155 err |= __get_user(regs->y, &((*gr)[SVR4_Y]));
1156 err |= __get_user(psr, &((*gr)[SVR4_PSR]));
1157 regs->tstate &= ~(TSTATE_ICC|TSTATE_XCC);
1158 regs->tstate |= psr_to_tstate_icc(psr);
1160 /* Restore g[1..7] and o[0..7] registers */
1161 for (i = 0; i < 7; i++)
1162 err |= __get_user(regs->u_regs[UREG_G1+i], (&(*gr)[SVR4_G1])+i);
1163 for (i = 0; i < 8; i++)
1164 err |= __get_user(regs->u_regs[UREG_I0+i], (&(*gr)[SVR4_O0])+i);
1173 static void setup_rt_frame32(struct k_sigaction *ka, struct pt_regs *regs,
1174 unsigned long signr, sigset_t *oldset,
1177 struct rt_signal_frame32 __user *sf;
1181 compat_sigset_t seta;
1183 /* 1. Make sure everything is clean */
1184 synchronize_user_stack();
1185 save_and_clear_fpu();
1187 sigframe_size = RT_ALIGNEDSZ;
1188 if (!(current_thread_info()->fpsaved[0] & FPRS_FEF))
1189 sigframe_size -= sizeof(__siginfo_fpu_t);
1191 sf = (struct rt_signal_frame32 __user *)
1192 get_sigframe(&ka->sa, regs, sigframe_size);
1194 if (invalid_frame_pointer(sf, sigframe_size))
1197 if (get_thread_wsaved() != 0)
1200 /* 2. Save the current process state */
1201 if (test_thread_flag(TIF_32BIT)) {
1202 regs->tpc &= 0xffffffff;
1203 regs->tnpc &= 0xffffffff;
1205 err = put_user(regs->tpc, &sf->regs.pc);
1206 err |= __put_user(regs->tnpc, &sf->regs.npc);
1207 err |= __put_user(regs->y, &sf->regs.y);
1208 psr = tstate_to_psr(regs->tstate);
1209 if (current_thread_info()->fpsaved[0] & FPRS_FEF)
1211 err |= __put_user(psr, &sf->regs.psr);
1212 for (i = 0; i < 16; i++)
1213 err |= __put_user(regs->u_regs[i], &sf->regs.u_regs[i]);
1214 err |= __put_user(sizeof(siginfo_extra_v8plus_t), &sf->extra_size);
1215 err |= __put_user(SIGINFO_EXTRA_V8PLUS_MAGIC, &sf->v8plus.g_upper[0]);
1216 for (i = 1; i < 16; i++)
1217 err |= __put_user(((u32 *)regs->u_regs)[2*i],
1218 &sf->v8plus.g_upper[i]);
1219 err |= __put_user((regs->tstate & TSTATE_ASI) >> 24UL,
1223 err |= save_fpu_state32(regs, &sf->fpu_state);
1224 err |= __put_user((u64)&sf->fpu_state, &sf->fpu_save);
1226 err |= __put_user(0, &sf->fpu_save);
1229 /* Update the siginfo structure. */
1230 err |= copy_siginfo_to_user32(&sf->info, info);
1232 /* Setup sigaltstack */
1233 err |= __put_user(current->sas_ss_sp, &sf->stack.ss_sp);
1234 err |= __put_user(sas_ss_flags(regs->u_regs[UREG_FP]), &sf->stack.ss_flags);
1235 err |= __put_user(current->sas_ss_size, &sf->stack.ss_size);
1237 switch (_NSIG_WORDS) {
1238 case 4: seta.sig[7] = (oldset->sig[3] >> 32);
1239 seta.sig[6] = oldset->sig[3];
1240 case 3: seta.sig[5] = (oldset->sig[2] >> 32);
1241 seta.sig[4] = oldset->sig[2];
1242 case 2: seta.sig[3] = (oldset->sig[1] >> 32);
1243 seta.sig[2] = oldset->sig[1];
1244 case 1: seta.sig[1] = (oldset->sig[0] >> 32);
1245 seta.sig[0] = oldset->sig[0];
1247 err |= __copy_to_user(&sf->mask, &seta, sizeof(compat_sigset_t));
1249 err |= copy_in_user((u32 __user *)sf,
1250 (u32 __user *)(regs->u_regs[UREG_FP]),
1251 sizeof(struct reg_window32));
1255 /* 3. signal handler back-trampoline and parameters */
1256 regs->u_regs[UREG_FP] = (unsigned long) sf;
1257 regs->u_regs[UREG_I0] = signr;
1258 regs->u_regs[UREG_I1] = (unsigned long) &sf->info;
1259 regs->u_regs[UREG_I2] = (unsigned long) &sf->regs;
1261 /* 4. signal handler */
1262 regs->tpc = (unsigned long) ka->sa.sa_handler;
1263 regs->tnpc = (regs->tpc + 4);
1264 if (test_thread_flag(TIF_32BIT)) {
1265 regs->tpc &= 0xffffffff;
1266 regs->tnpc &= 0xffffffff;
1269 /* 5. return to kernel instructions */
1270 if (ka->ka_restorer)
1271 regs->u_regs[UREG_I7] = (unsigned long)ka->ka_restorer;
1273 /* Flush instruction space. */
1274 unsigned long address = ((unsigned long)&(sf->insns[0]));
1275 pgd_t *pgdp = pgd_offset(current->mm, address);
1276 pud_t *pudp = pud_offset(pgdp, address);
1277 pmd_t *pmdp = pmd_offset(pudp, address);
1280 regs->u_regs[UREG_I7] = (unsigned long) (&(sf->insns[0]) - 2);
1282 /* mov __NR_rt_sigreturn, %g1 */
1283 err |= __put_user(0x82102065, &sf->insns[0]);
1286 err |= __put_user(0x91d02010, &sf->insns[1]);
1291 ptep = pte_offset_map(pmdp, address);
1292 if (pte_present(*ptep)) {
1293 unsigned long page = (unsigned long)
1294 page_address(pte_page(*ptep));
1297 __asm__ __volatile__("flush %0 + %1"
1300 "r" (address & (PAGE_SIZE - 1))
1311 force_sigsegv(signr, current);
1314 static inline void handle_signal32(unsigned long signr, struct k_sigaction *ka,
1316 sigset_t *oldset, struct pt_regs *regs,
1320 setup_svr4_frame32(&ka->sa, regs->tpc, regs->tnpc,
1321 regs, signr, oldset);
1323 if (ka->sa.sa_flags & SA_SIGINFO)
1324 setup_rt_frame32(ka, regs, signr, oldset, info);
1325 else if (test_thread_flag(TIF_NEWSIGNALS))
1326 new_setup_frame32(ka, regs, signr, oldset);
1328 setup_frame32(&ka->sa, regs, signr, oldset, info);
1330 spin_lock_irq(¤t->sighand->siglock);
1331 sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask);
1332 if (!(ka->sa.sa_flags & SA_NOMASK))
1333 sigaddset(¤t->blocked,signr);
1334 recalc_sigpending();
1335 spin_unlock_irq(¤t->sighand->siglock);
1338 static inline void syscall_restart32(unsigned long orig_i0, struct pt_regs *regs,
1339 struct sigaction *sa)
1341 switch (regs->u_regs[UREG_I0]) {
1342 case ERESTART_RESTARTBLOCK:
1343 case ERESTARTNOHAND:
1344 no_system_call_restart:
1345 regs->u_regs[UREG_I0] = EINTR;
1346 regs->tstate |= TSTATE_ICARRY;
1349 if (!(sa->sa_flags & SA_RESTART))
1350 goto no_system_call_restart;
1352 case ERESTARTNOINTR:
1353 regs->u_regs[UREG_I0] = orig_i0;
1359 /* Note that 'init' is a special process: it doesn't get signals it doesn't
1360 * want to handle. Thus you cannot kill init even with a SIGKILL even by
1363 int do_signal32(sigset_t *oldset, struct pt_regs * regs,
1364 unsigned long orig_i0, int restart_syscall)
1367 struct signal_deliver_cookie cookie;
1368 struct k_sigaction ka;
1370 int svr4_signal = current->personality == PER_SVR4;
1372 cookie.restart_syscall = restart_syscall;
1373 cookie.orig_i0 = orig_i0;
1375 signr = get_signal_to_deliver(&info, &ka, regs, &cookie);
1377 if (cookie.restart_syscall)
1378 syscall_restart32(orig_i0, regs, &ka.sa);
1379 handle_signal32(signr, &ka, &info, oldset,
1383 if (cookie.restart_syscall &&
1384 (regs->u_regs[UREG_I0] == ERESTARTNOHAND ||
1385 regs->u_regs[UREG_I0] == ERESTARTSYS ||
1386 regs->u_regs[UREG_I0] == ERESTARTNOINTR)) {
1387 /* replay the system call when we are done */
1388 regs->u_regs[UREG_I0] = cookie.orig_i0;
1392 if (cookie.restart_syscall &&
1393 regs->u_regs[UREG_I0] == ERESTART_RESTARTBLOCK) {
1394 regs->u_regs[UREG_G1] = __NR_restart_syscall;
1406 asmlinkage int do_sys32_sigstack(u32 u_ssptr, u32 u_ossptr, unsigned long sp)
1408 struct sigstack32 __user *ssptr =
1409 (struct sigstack32 __user *)((unsigned long)(u_ssptr));
1410 struct sigstack32 __user *ossptr =
1411 (struct sigstack32 __user *)((unsigned long)(u_ossptr));
1414 /* First see if old state is wanted. */
1416 if (put_user(current->sas_ss_sp + current->sas_ss_size,
1417 &ossptr->the_stack) ||
1418 __put_user(on_sig_stack(sp), &ossptr->cur_status))
1422 /* Now see if we want to update the new state. */
1426 if (get_user(ss_sp, &ssptr->the_stack))
1429 /* If the current stack was set with sigaltstack, don't
1430 * swap stacks while we are on it.
1433 if (current->sas_ss_sp && on_sig_stack(sp))
1436 /* Since we don't know the extent of the stack, and we don't
1437 * track onstack-ness, but rather calculate it, we must
1438 * presume a size. Ho hum this interface is lossy.
1440 current->sas_ss_sp = (unsigned long)ss_sp - SIGSTKSZ;
1441 current->sas_ss_size = SIGSTKSZ;
1449 asmlinkage long do_sys32_sigaltstack(u32 ussa, u32 uossa, unsigned long sp)
1454 mm_segment_t old_fs;
1455 stack_t32 __user *uss32 = compat_ptr(ussa);
1456 stack_t32 __user *uoss32 = compat_ptr(uossa);
1458 if (ussa && (get_user(u_ss_sp, &uss32->ss_sp) ||
1459 __get_user(uss.ss_flags, &uss32->ss_flags) ||
1460 __get_user(uss.ss_size, &uss32->ss_size)))
1462 uss.ss_sp = compat_ptr(u_ss_sp);
1465 ret = do_sigaltstack(ussa ? (stack_t __user *) &uss : NULL,
1466 uossa ? (stack_t __user *) &uoss : NULL, sp);
1468 if (!ret && uossa && (put_user(ptr_to_compat(uoss.ss_sp), &uoss32->ss_sp) ||
1469 __put_user(uoss.ss_flags, &uoss32->ss_flags) ||
1470 __put_user(uoss.ss_size, &uoss32->ss_size)))