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));
880 __asm__ __volatile__(
881 " membar #StoreStore\n"
883 : : "r" (page), "r" (address & (PAGE_SIZE - 1))
894 force_sigsegv(signo, current);
897 /* Setup a Solaris stack frame */
899 setup_svr4_frame32(struct sigaction *sa, unsigned long pc, unsigned long npc,
900 struct pt_regs *regs, int signr, sigset_t *oldset)
902 svr4_signal_frame_t __user *sfp;
903 svr4_gregset_t __user *gr;
904 svr4_siginfo_t __user *si;
905 svr4_mcontext_t __user *mc;
906 svr4_gwindows_t __user *gw;
907 svr4_ucontext_t __user *uc;
912 synchronize_user_stack();
913 save_and_clear_fpu();
915 regs->u_regs[UREG_FP] &= 0x00000000ffffffffUL;
916 sfp = (svr4_signal_frame_t __user *)
917 get_sigframe(sa, regs,
918 sizeof(struct reg_window32) + SVR4_SF_ALIGNED);
920 if (invalid_frame_pointer(sfp, sizeof(*sfp)))
923 /* Start with a clean frame pointer and fill it */
924 err = clear_user(sfp, sizeof(*sfp));
926 /* Setup convenience variables */
933 /* FIXME: where am I supposed to put this?
934 * sc->sigc_onstack = old_status;
935 * anyways, it does not look like it is used for anything at all.
937 setv.sigbits[0] = oldset->sig[0];
938 setv.sigbits[1] = (oldset->sig[0] >> 32);
939 if (_NSIG_WORDS >= 2) {
940 setv.sigbits[2] = oldset->sig[1];
941 setv.sigbits[3] = (oldset->sig[1] >> 32);
942 err |= __copy_to_user(&uc->sigmask, &setv, sizeof(svr4_sigset_t));
944 err |= __copy_to_user(&uc->sigmask, &setv,
945 2 * sizeof(unsigned int));
947 /* Store registers */
948 if (test_thread_flag(TIF_32BIT)) {
949 regs->tpc &= 0xffffffff;
950 regs->tnpc &= 0xffffffff;
952 err |= __put_user(regs->tpc, &((*gr)[SVR4_PC]));
953 err |= __put_user(regs->tnpc, &((*gr)[SVR4_NPC]));
954 psr = tstate_to_psr(regs->tstate);
955 if (current_thread_info()->fpsaved[0] & FPRS_FEF)
957 err |= __put_user(psr, &((*gr)[SVR4_PSR]));
958 err |= __put_user(regs->y, &((*gr)[SVR4_Y]));
960 /* Copy g[1..7] and o[0..7] registers */
961 for (i = 0; i < 7; i++)
962 err |= __put_user(regs->u_regs[UREG_G1+i], (&(*gr)[SVR4_G1])+i);
963 for (i = 0; i < 8; i++)
964 err |= __put_user(regs->u_regs[UREG_I0+i], (&(*gr)[SVR4_O0])+i);
966 /* Setup sigaltstack */
967 err |= __put_user(current->sas_ss_sp, &uc->stack.sp);
968 err |= __put_user(sas_ss_flags(regs->u_regs[UREG_FP]), &uc->stack.flags);
969 err |= __put_user(current->sas_ss_size, &uc->stack.size);
971 /* Save the currently window file: */
973 /* 1. Link sfp->uc->gwins to our windows */
974 err |= __put_user(ptr_to_compat(gw), &mc->gwin);
976 /* 2. Number of windows to restore at setcontext (): */
977 err |= __put_user(get_thread_wsaved(), &gw->count);
979 /* 3. We just pay attention to the gw->count field on setcontext */
980 set_thread_wsaved(0); /* So process is allowed to execute. */
982 /* Setup the signal information. Solaris expects a bunch of
983 * information to be passed to the signal handler, we don't provide
984 * that much currently, should use siginfo.
986 err |= __put_user(signr, &si->siginfo.signo);
987 err |= __put_user(SVR4_SINOINFO, &si->siginfo.code);
991 regs->u_regs[UREG_FP] = (unsigned long) sfp;
992 regs->tpc = (unsigned long) sa->sa_handler;
993 regs->tnpc = (regs->tpc + 4);
994 if (test_thread_flag(TIF_32BIT)) {
995 regs->tpc &= 0xffffffff;
996 regs->tnpc &= 0xffffffff;
999 /* Arguments passed to signal handler */
1000 if (regs->u_regs[14]){
1001 struct reg_window32 __user *rw = (struct reg_window32 __user *)
1002 (regs->u_regs[14] & 0x00000000ffffffffUL);
1004 err |= __put_user(signr, &rw->ins[0]);
1005 err |= __put_user((u64)si, &rw->ins[1]);
1006 err |= __put_user((u64)uc, &rw->ins[2]);
1007 err |= __put_user((u64)sfp, &rw->ins[6]); /* frame pointer */
1011 regs->u_regs[UREG_I0] = signr;
1012 regs->u_regs[UREG_I1] = (u32)(u64) si;
1013 regs->u_regs[UREG_I2] = (u32)(u64) uc;
1018 force_sigsegv(signr, current);
1022 svr4_getcontext(svr4_ucontext_t __user *uc, struct pt_regs *regs)
1024 svr4_gregset_t __user *gr;
1025 svr4_mcontext_t __user *mc;
1030 synchronize_user_stack();
1031 save_and_clear_fpu();
1033 if (get_thread_wsaved())
1036 err = clear_user(uc, sizeof(*uc));
1038 /* Setup convenience variables */
1042 setv.sigbits[0] = current->blocked.sig[0];
1043 setv.sigbits[1] = (current->blocked.sig[0] >> 32);
1044 if (_NSIG_WORDS >= 2) {
1045 setv.sigbits[2] = current->blocked.sig[1];
1046 setv.sigbits[3] = (current->blocked.sig[1] >> 32);
1047 err |= __copy_to_user(&uc->sigmask, &setv, sizeof(svr4_sigset_t));
1049 err |= __copy_to_user(&uc->sigmask, &setv, 2 * sizeof(unsigned));
1051 /* Store registers */
1052 if (test_thread_flag(TIF_32BIT)) {
1053 regs->tpc &= 0xffffffff;
1054 regs->tnpc &= 0xffffffff;
1056 err |= __put_user(regs->tpc, &uc->mcontext.greg[SVR4_PC]);
1057 err |= __put_user(regs->tnpc, &uc->mcontext.greg[SVR4_NPC]);
1059 psr = tstate_to_psr(regs->tstate) & ~PSR_EF;
1060 if (current_thread_info()->fpsaved[0] & FPRS_FEF)
1062 err |= __put_user(psr, &uc->mcontext.greg[SVR4_PSR]);
1064 err |= __put_user(regs->y, &uc->mcontext.greg[SVR4_Y]);
1066 /* Copy g[1..7] and o[0..7] registers */
1067 for (i = 0; i < 7; i++)
1068 err |= __put_user(regs->u_regs[UREG_G1+i], (&(*gr)[SVR4_G1])+i);
1069 for (i = 0; i < 8; i++)
1070 err |= __put_user(regs->u_regs[UREG_I0+i], (&(*gr)[SVR4_O0])+i);
1072 /* Setup sigaltstack */
1073 err |= __put_user(current->sas_ss_sp, &uc->stack.sp);
1074 err |= __put_user(sas_ss_flags(regs->u_regs[UREG_FP]), &uc->stack.flags);
1075 err |= __put_user(current->sas_ss_size, &uc->stack.size);
1077 /* The register file is not saved
1078 * we have already stuffed all of it with sync_user_stack
1080 return (err ? -EFAULT : 0);
1084 /* Set the context for a svr4 application, this is Solaris way to sigreturn */
1085 asmlinkage int svr4_setcontext(svr4_ucontext_t __user *c, struct pt_regs *regs)
1087 svr4_gregset_t __user *gr;
1088 mm_segment_t old_fs;
1089 u32 pc, npc, psr, u_ss_sp;
1095 /* Fixme: restore windows, or is this already taken care of in
1096 * svr4_setup_frame when sync_user_windows is done?
1098 flush_user_windows();
1100 if (get_thread_wsaved())
1103 if (((unsigned long) c) & 3){
1104 printk("Unaligned structure passed\n");
1108 if (!__access_ok(c, sizeof(*c))) {
1109 /* Miguel, add nice debugging msg _here_. ;-) */
1113 /* Check for valid PC and nPC */
1114 gr = &c->mcontext.greg;
1115 err = __get_user(pc, &((*gr)[SVR4_PC]));
1116 err |= __get_user(npc, &((*gr)[SVR4_NPC]));
1120 /* Retrieve information from passed ucontext */
1121 /* note that nPC is ored a 1, this is used to inform entry.S */
1122 /* that we don't want it to mess with our PC and nPC */
1124 err |= copy_from_user(&setv, &c->sigmask, sizeof(svr4_sigset_t));
1125 set.sig[0] = setv.sigbits[0] | (((long)setv.sigbits[1]) << 32);
1126 if (_NSIG_WORDS >= 2)
1127 set.sig[1] = setv.sigbits[2] | (((long)setv.sigbits[3]) << 32);
1129 err |= __get_user(u_ss_sp, &c->stack.sp);
1130 st.ss_sp = compat_ptr(u_ss_sp);
1131 err |= __get_user(st.ss_flags, &c->stack.flags);
1132 err |= __get_user(st.ss_size, &c->stack.size);
1136 /* It is more difficult to avoid calling this function than to
1137 call it and ignore errors. */
1140 do_sigaltstack((stack_t __user *) &st, NULL, regs->u_regs[UREG_I6]);
1143 sigdelsetmask(&set, ~_BLOCKABLE);
1144 spin_lock_irq(¤t->sighand->siglock);
1145 current->blocked = set;
1146 recalc_sigpending();
1147 spin_unlock_irq(¤t->sighand->siglock);
1149 regs->tnpc = npc | 1;
1150 if (test_thread_flag(TIF_32BIT)) {
1151 regs->tpc &= 0xffffffff;
1152 regs->tnpc &= 0xffffffff;
1154 err |= __get_user(regs->y, &((*gr)[SVR4_Y]));
1155 err |= __get_user(psr, &((*gr)[SVR4_PSR]));
1156 regs->tstate &= ~(TSTATE_ICC|TSTATE_XCC);
1157 regs->tstate |= psr_to_tstate_icc(psr);
1159 /* Restore g[1..7] and o[0..7] registers */
1160 for (i = 0; i < 7; i++)
1161 err |= __get_user(regs->u_regs[UREG_G1+i], (&(*gr)[SVR4_G1])+i);
1162 for (i = 0; i < 8; i++)
1163 err |= __get_user(regs->u_regs[UREG_I0+i], (&(*gr)[SVR4_O0])+i);
1172 static void setup_rt_frame32(struct k_sigaction *ka, struct pt_regs *regs,
1173 unsigned long signr, sigset_t *oldset,
1176 struct rt_signal_frame32 __user *sf;
1180 compat_sigset_t seta;
1182 /* 1. Make sure everything is clean */
1183 synchronize_user_stack();
1184 save_and_clear_fpu();
1186 sigframe_size = RT_ALIGNEDSZ;
1187 if (!(current_thread_info()->fpsaved[0] & FPRS_FEF))
1188 sigframe_size -= sizeof(__siginfo_fpu_t);
1190 sf = (struct rt_signal_frame32 __user *)
1191 get_sigframe(&ka->sa, regs, sigframe_size);
1193 if (invalid_frame_pointer(sf, sigframe_size))
1196 if (get_thread_wsaved() != 0)
1199 /* 2. Save the current process state */
1200 if (test_thread_flag(TIF_32BIT)) {
1201 regs->tpc &= 0xffffffff;
1202 regs->tnpc &= 0xffffffff;
1204 err = put_user(regs->tpc, &sf->regs.pc);
1205 err |= __put_user(regs->tnpc, &sf->regs.npc);
1206 err |= __put_user(regs->y, &sf->regs.y);
1207 psr = tstate_to_psr(regs->tstate);
1208 if (current_thread_info()->fpsaved[0] & FPRS_FEF)
1210 err |= __put_user(psr, &sf->regs.psr);
1211 for (i = 0; i < 16; i++)
1212 err |= __put_user(regs->u_regs[i], &sf->regs.u_regs[i]);
1213 err |= __put_user(sizeof(siginfo_extra_v8plus_t), &sf->extra_size);
1214 err |= __put_user(SIGINFO_EXTRA_V8PLUS_MAGIC, &sf->v8plus.g_upper[0]);
1215 for (i = 1; i < 16; i++)
1216 err |= __put_user(((u32 *)regs->u_regs)[2*i],
1217 &sf->v8plus.g_upper[i]);
1218 err |= __put_user((regs->tstate & TSTATE_ASI) >> 24UL,
1222 err |= save_fpu_state32(regs, &sf->fpu_state);
1223 err |= __put_user((u64)&sf->fpu_state, &sf->fpu_save);
1225 err |= __put_user(0, &sf->fpu_save);
1228 /* Update the siginfo structure. */
1229 err |= copy_siginfo_to_user32(&sf->info, info);
1231 /* Setup sigaltstack */
1232 err |= __put_user(current->sas_ss_sp, &sf->stack.ss_sp);
1233 err |= __put_user(sas_ss_flags(regs->u_regs[UREG_FP]), &sf->stack.ss_flags);
1234 err |= __put_user(current->sas_ss_size, &sf->stack.ss_size);
1236 switch (_NSIG_WORDS) {
1237 case 4: seta.sig[7] = (oldset->sig[3] >> 32);
1238 seta.sig[6] = oldset->sig[3];
1239 case 3: seta.sig[5] = (oldset->sig[2] >> 32);
1240 seta.sig[4] = oldset->sig[2];
1241 case 2: seta.sig[3] = (oldset->sig[1] >> 32);
1242 seta.sig[2] = oldset->sig[1];
1243 case 1: seta.sig[1] = (oldset->sig[0] >> 32);
1244 seta.sig[0] = oldset->sig[0];
1246 err |= __copy_to_user(&sf->mask, &seta, sizeof(compat_sigset_t));
1248 err |= copy_in_user((u32 __user *)sf,
1249 (u32 __user *)(regs->u_regs[UREG_FP]),
1250 sizeof(struct reg_window32));
1254 /* 3. signal handler back-trampoline and parameters */
1255 regs->u_regs[UREG_FP] = (unsigned long) sf;
1256 regs->u_regs[UREG_I0] = signr;
1257 regs->u_regs[UREG_I1] = (unsigned long) &sf->info;
1258 regs->u_regs[UREG_I2] = (unsigned long) &sf->regs;
1260 /* 4. signal handler */
1261 regs->tpc = (unsigned long) ka->sa.sa_handler;
1262 regs->tnpc = (regs->tpc + 4);
1263 if (test_thread_flag(TIF_32BIT)) {
1264 regs->tpc &= 0xffffffff;
1265 regs->tnpc &= 0xffffffff;
1268 /* 5. return to kernel instructions */
1269 if (ka->ka_restorer)
1270 regs->u_regs[UREG_I7] = (unsigned long)ka->ka_restorer;
1272 /* Flush instruction space. */
1273 unsigned long address = ((unsigned long)&(sf->insns[0]));
1274 pgd_t *pgdp = pgd_offset(current->mm, address);
1275 pud_t *pudp = pud_offset(pgdp, address);
1276 pmd_t *pmdp = pmd_offset(pudp, address);
1279 regs->u_regs[UREG_I7] = (unsigned long) (&(sf->insns[0]) - 2);
1281 /* mov __NR_rt_sigreturn, %g1 */
1282 err |= __put_user(0x82102065, &sf->insns[0]);
1285 err |= __put_user(0x91d02010, &sf->insns[1]);
1290 ptep = pte_offset_map(pmdp, address);
1291 if (pte_present(*ptep)) {
1292 unsigned long page = (unsigned long)
1293 page_address(pte_page(*ptep));
1295 __asm__ __volatile__(
1296 " membar #StoreStore\n"
1298 : : "r" (page), "r" (address & (PAGE_SIZE - 1))
1309 force_sigsegv(signr, current);
1312 static inline void handle_signal32(unsigned long signr, struct k_sigaction *ka,
1314 sigset_t *oldset, struct pt_regs *regs,
1318 setup_svr4_frame32(&ka->sa, regs->tpc, regs->tnpc,
1319 regs, signr, oldset);
1321 if (ka->sa.sa_flags & SA_SIGINFO)
1322 setup_rt_frame32(ka, regs, signr, oldset, info);
1323 else if (test_thread_flag(TIF_NEWSIGNALS))
1324 new_setup_frame32(ka, regs, signr, oldset);
1326 setup_frame32(&ka->sa, regs, signr, oldset, info);
1328 if (!(ka->sa.sa_flags & SA_NOMASK)) {
1329 spin_lock_irq(¤t->sighand->siglock);
1330 sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask);
1331 sigaddset(¤t->blocked,signr);
1332 recalc_sigpending();
1333 spin_unlock_irq(¤t->sighand->siglock);
1337 static inline void syscall_restart32(unsigned long orig_i0, struct pt_regs *regs,
1338 struct sigaction *sa)
1340 switch (regs->u_regs[UREG_I0]) {
1341 case ERESTART_RESTARTBLOCK:
1342 case ERESTARTNOHAND:
1343 no_system_call_restart:
1344 regs->u_regs[UREG_I0] = EINTR;
1345 regs->tstate |= TSTATE_ICARRY;
1348 if (!(sa->sa_flags & SA_RESTART))
1349 goto no_system_call_restart;
1351 case ERESTARTNOINTR:
1352 regs->u_regs[UREG_I0] = orig_i0;
1358 /* Note that 'init' is a special process: it doesn't get signals it doesn't
1359 * want to handle. Thus you cannot kill init even with a SIGKILL even by
1362 int do_signal32(sigset_t *oldset, struct pt_regs * regs,
1363 unsigned long orig_i0, int restart_syscall)
1366 struct signal_deliver_cookie cookie;
1367 struct k_sigaction ka;
1369 int svr4_signal = current->personality == PER_SVR4;
1371 cookie.restart_syscall = restart_syscall;
1372 cookie.orig_i0 = orig_i0;
1374 signr = get_signal_to_deliver(&info, &ka, regs, &cookie);
1376 if (cookie.restart_syscall)
1377 syscall_restart32(orig_i0, regs, &ka.sa);
1378 handle_signal32(signr, &ka, &info, oldset,
1382 if (cookie.restart_syscall &&
1383 (regs->u_regs[UREG_I0] == ERESTARTNOHAND ||
1384 regs->u_regs[UREG_I0] == ERESTARTSYS ||
1385 regs->u_regs[UREG_I0] == ERESTARTNOINTR)) {
1386 /* replay the system call when we are done */
1387 regs->u_regs[UREG_I0] = cookie.orig_i0;
1391 if (cookie.restart_syscall &&
1392 regs->u_regs[UREG_I0] == ERESTART_RESTARTBLOCK) {
1393 regs->u_regs[UREG_G1] = __NR_restart_syscall;
1405 asmlinkage int do_sys32_sigstack(u32 u_ssptr, u32 u_ossptr, unsigned long sp)
1407 struct sigstack32 __user *ssptr =
1408 (struct sigstack32 __user *)((unsigned long)(u_ssptr));
1409 struct sigstack32 __user *ossptr =
1410 (struct sigstack32 __user *)((unsigned long)(u_ossptr));
1413 /* First see if old state is wanted. */
1415 if (put_user(current->sas_ss_sp + current->sas_ss_size,
1416 &ossptr->the_stack) ||
1417 __put_user(on_sig_stack(sp), &ossptr->cur_status))
1421 /* Now see if we want to update the new state. */
1425 if (get_user(ss_sp, &ssptr->the_stack))
1428 /* If the current stack was set with sigaltstack, don't
1429 * swap stacks while we are on it.
1432 if (current->sas_ss_sp && on_sig_stack(sp))
1435 /* Since we don't know the extent of the stack, and we don't
1436 * track onstack-ness, but rather calculate it, we must
1437 * presume a size. Ho hum this interface is lossy.
1439 current->sas_ss_sp = (unsigned long)ss_sp - SIGSTKSZ;
1440 current->sas_ss_size = SIGSTKSZ;
1448 asmlinkage long do_sys32_sigaltstack(u32 ussa, u32 uossa, unsigned long sp)
1453 mm_segment_t old_fs;
1454 stack_t32 __user *uss32 = compat_ptr(ussa);
1455 stack_t32 __user *uoss32 = compat_ptr(uossa);
1457 if (ussa && (get_user(u_ss_sp, &uss32->ss_sp) ||
1458 __get_user(uss.ss_flags, &uss32->ss_flags) ||
1459 __get_user(uss.ss_size, &uss32->ss_size)))
1461 uss.ss_sp = compat_ptr(u_ss_sp);
1464 ret = do_sigaltstack(ussa ? (stack_t __user *) &uss : NULL,
1465 uossa ? (stack_t __user *) &uoss : NULL, sp);
1467 if (!ret && uossa && (put_user(ptr_to_compat(uoss.ss_sp), &uoss32->ss_sp) ||
1468 __put_user(uoss.ss_flags, &uoss32->ss_flags) ||
1469 __put_user(uoss.ss_size, &uoss32->ss_size)))