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>
32 #include <asm/compat_signal.h>
34 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
36 /* Signal frames: the original one (compatible with SunOS):
38 * Set up a signal frame... Make the stack look the way SunOS
39 * expects it to look which is basically:
41 * ---------------------------------- <-- %sp at signal time
44 * Ptr to sigcontext area above
46 * The signal number itself
48 * ---------------------------------- <-- New %sp
50 struct signal_sframe32 {
51 struct reg_window32 sig_window;
54 /* struct sigcontext32 * */ u32 sig_scptr;
56 struct sigcontext32 sig_context;
57 unsigned int extramask[_COMPAT_NSIG_WORDS - 1];
60 /* This magic should be in g_upper[0] for all upper parts
63 #define SIGINFO_EXTRA_V8PLUS_MAGIC 0x130e269
65 unsigned int g_upper[8];
66 unsigned int o_upper[8];
68 } siginfo_extra_v8plus_t;
71 * And the new one, intended to be used for Linux applications only
72 * (we have enough in there to work with clone).
73 * All the interesting bits are in the info field.
75 struct new_signal_frame32 {
76 struct sparc_stackf32 ss;
78 /* __siginfo_fpu32_t * */ u32 fpu_save;
79 unsigned int insns[2];
80 unsigned int extramask[_COMPAT_NSIG_WORDS - 1];
81 unsigned int extra_size; /* Should be sizeof(siginfo_extra_v8plus_t) */
82 /* Only valid if (info.si_regs.psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS */
83 siginfo_extra_v8plus_t v8plus;
84 __siginfo_fpu_t fpu_state;
87 typedef struct compat_siginfo{
93 int _pad[SI_PAD_SIZE32];
97 compat_pid_t _pid; /* sender's pid */
98 unsigned int _uid; /* sender's uid */
101 /* POSIX.1b timers */
103 compat_timer_t _tid; /* timer id */
104 int _overrun; /* overrun count */
105 compat_sigval_t _sigval; /* same as below */
106 int _sys_private; /* not to be passed to user */
109 /* POSIX.1b signals */
111 compat_pid_t _pid; /* sender's pid */
112 unsigned int _uid; /* sender's uid */
113 compat_sigval_t _sigval;
118 compat_pid_t _pid; /* which child */
119 unsigned int _uid; /* sender's uid */
120 int _status; /* exit code */
121 compat_clock_t _utime;
122 compat_clock_t _stime;
125 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */
127 u32 _addr; /* faulting insn/memory ref. */
133 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
139 struct rt_signal_frame32 {
140 struct sparc_stackf32 ss;
141 compat_siginfo_t info;
142 struct pt_regs32 regs;
143 compat_sigset_t mask;
144 /* __siginfo_fpu32_t * */ u32 fpu_save;
145 unsigned int insns[2];
147 unsigned int extra_size; /* Should be sizeof(siginfo_extra_v8plus_t) */
148 /* Only valid if (regs.psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS */
149 siginfo_extra_v8plus_t v8plus;
150 __siginfo_fpu_t fpu_state;
154 #define SF_ALIGNEDSZ (((sizeof(struct signal_sframe32) + 7) & (~7)))
155 #define NF_ALIGNEDSZ (((sizeof(struct new_signal_frame32) + 7) & (~7)))
156 #define RT_ALIGNEDSZ (((sizeof(struct rt_signal_frame32) + 7) & (~7)))
158 int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from)
162 if (!access_ok(VERIFY_WRITE, to, sizeof(compat_siginfo_t)))
165 /* If you change siginfo_t structure, please be sure
166 this code is fixed accordingly.
167 It should never copy any pad contained in the structure
168 to avoid security leaks, but must copy the generic
169 3 ints plus the relevant union member.
170 This routine must convert siginfo from 64bit to 32bit as well
172 err = __put_user(from->si_signo, &to->si_signo);
173 err |= __put_user(from->si_errno, &to->si_errno);
174 err |= __put_user((short)from->si_code, &to->si_code);
175 if (from->si_code < 0)
176 err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
178 switch (from->si_code >> 16) {
179 case __SI_TIMER >> 16:
180 err |= __put_user(from->si_tid, &to->si_tid);
181 err |= __put_user(from->si_overrun, &to->si_overrun);
182 err |= __put_user(from->si_int, &to->si_int);
184 case __SI_CHLD >> 16:
185 err |= __put_user(from->si_utime, &to->si_utime);
186 err |= __put_user(from->si_stime, &to->si_stime);
187 err |= __put_user(from->si_status, &to->si_status);
189 err |= __put_user(from->si_pid, &to->si_pid);
190 err |= __put_user(from->si_uid, &to->si_uid);
192 case __SI_FAULT >> 16:
193 err |= __put_user(from->si_trapno, &to->si_trapno);
194 err |= __put_user((unsigned long)from->si_addr, &to->si_addr);
196 case __SI_POLL >> 16:
197 err |= __put_user(from->si_band, &to->si_band);
198 err |= __put_user(from->si_fd, &to->si_fd);
200 case __SI_RT >> 16: /* This is not generated by the kernel as of now. */
201 case __SI_MESGQ >> 16:
202 err |= __put_user(from->si_pid, &to->si_pid);
203 err |= __put_user(from->si_uid, &to->si_uid);
204 err |= __put_user(from->si_int, &to->si_int);
211 /* CAUTION: This is just a very minimalist implementation for the
212 * sake of compat_sys_rt_sigqueueinfo()
214 int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
216 if (!access_ok(VERIFY_WRITE, from, sizeof(compat_siginfo_t)))
219 if (copy_from_user(to, from, 3*sizeof(int)) ||
220 copy_from_user(to->_sifields._pad, from->_sifields._pad,
227 static int restore_fpu_state32(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
229 unsigned long *fpregs = current_thread_info()->fpregs;
233 err = __get_user(fprs, &fpu->si_fprs);
235 regs->tstate &= ~TSTATE_PEF;
237 err |= copy_from_user(fpregs, &fpu->si_float_regs[0], (sizeof(unsigned int) * 32));
239 err |= copy_from_user(fpregs+16, &fpu->si_float_regs[32], (sizeof(unsigned int) * 32));
240 err |= __get_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
241 err |= __get_user(current_thread_info()->gsr[0], &fpu->si_gsr);
242 current_thread_info()->fpsaved[0] |= fprs;
246 void do_new_sigreturn32(struct pt_regs *regs)
248 struct new_signal_frame32 __user *sf;
250 unsigned pc, npc, fpu_save;
252 unsigned seta[_COMPAT_NSIG_WORDS];
255 regs->u_regs[UREG_FP] &= 0x00000000ffffffffUL;
256 sf = (struct new_signal_frame32 __user *) regs->u_regs[UREG_FP];
258 /* 1. Make sure we are not getting garbage from the user */
259 if (!access_ok(VERIFY_READ, sf, sizeof(*sf)) ||
260 (((unsigned long) sf) & 3))
263 get_user(pc, &sf->info.si_regs.pc);
264 __get_user(npc, &sf->info.si_regs.npc);
269 if (test_thread_flag(TIF_32BIT)) {
276 /* 2. Restore the state */
277 err = __get_user(regs->y, &sf->info.si_regs.y);
278 err |= __get_user(psr, &sf->info.si_regs.psr);
280 for (i = UREG_G1; i <= UREG_I7; i++)
281 err |= __get_user(regs->u_regs[i], &sf->info.si_regs.u_regs[i]);
282 if ((psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS) {
283 err |= __get_user(i, &sf->v8plus.g_upper[0]);
284 if (i == SIGINFO_EXTRA_V8PLUS_MAGIC) {
287 for (i = UREG_G1; i <= UREG_I7; i++)
288 err |= __get_user(((u32 *)regs->u_regs)[2*i], &sf->v8plus.g_upper[i]);
289 err |= __get_user(asi, &sf->v8plus.asi);
290 regs->tstate &= ~TSTATE_ASI;
291 regs->tstate |= ((asi & 0xffUL) << 24UL);
295 /* User can only change condition codes in %tstate. */
296 regs->tstate &= ~(TSTATE_ICC|TSTATE_XCC);
297 regs->tstate |= psr_to_tstate_icc(psr);
299 err |= __get_user(fpu_save, &sf->fpu_save);
301 err |= restore_fpu_state32(regs, &sf->fpu_state);
302 err |= __get_user(seta[0], &sf->info.si_mask);
303 err |= copy_from_user(seta+1, &sf->extramask,
304 (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int));
307 switch (_NSIG_WORDS) {
308 case 4: set.sig[3] = seta[6] + (((long)seta[7]) << 32);
309 case 3: set.sig[2] = seta[4] + (((long)seta[5]) << 32);
310 case 2: set.sig[1] = seta[2] + (((long)seta[3]) << 32);
311 case 1: set.sig[0] = seta[0] + (((long)seta[1]) << 32);
313 sigdelsetmask(&set, ~_BLOCKABLE);
314 spin_lock_irq(¤t->sighand->siglock);
315 current->blocked = set;
317 spin_unlock_irq(¤t->sighand->siglock);
321 force_sig(SIGSEGV, current);
324 asmlinkage void do_sigreturn32(struct pt_regs *regs)
326 struct sigcontext32 __user *scptr;
327 unsigned int pc, npc, psr;
329 unsigned int seta[_COMPAT_NSIG_WORDS];
332 /* Always make any pending restarted system calls return -EINTR */
333 current_thread_info()->restart_block.fn = do_no_restart_syscall;
335 synchronize_user_stack();
336 if (test_thread_flag(TIF_NEWSIGNALS)) {
337 do_new_sigreturn32(regs);
341 scptr = (struct sigcontext32 __user *)
342 (regs->u_regs[UREG_I0] & 0x00000000ffffffffUL);
343 /* Check sanity of the user arg. */
344 if (!access_ok(VERIFY_READ, scptr, sizeof(struct sigcontext32)) ||
345 (((unsigned long) scptr) & 3))
348 err = __get_user(pc, &scptr->sigc_pc);
349 err |= __get_user(npc, &scptr->sigc_npc);
352 goto segv; /* Nice try. */
354 err |= __get_user(seta[0], &scptr->sigc_mask);
355 /* Note that scptr + 1 points to extramask */
356 err |= copy_from_user(seta+1, scptr + 1,
357 (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int));
360 switch (_NSIG_WORDS) {
361 case 4: set.sig[3] = seta[6] + (((long)seta[7]) << 32);
362 case 3: set.sig[2] = seta[4] + (((long)seta[5]) << 32);
363 case 2: set.sig[1] = seta[2] + (((long)seta[3]) << 32);
364 case 1: set.sig[0] = seta[0] + (((long)seta[1]) << 32);
366 sigdelsetmask(&set, ~_BLOCKABLE);
367 spin_lock_irq(¤t->sighand->siglock);
368 current->blocked = set;
370 spin_unlock_irq(¤t->sighand->siglock);
372 if (test_thread_flag(TIF_32BIT)) {
378 err = __get_user(regs->u_regs[UREG_FP], &scptr->sigc_sp);
379 err |= __get_user(regs->u_regs[UREG_I0], &scptr->sigc_o0);
380 err |= __get_user(regs->u_regs[UREG_G1], &scptr->sigc_g1);
382 /* User can only change condition codes in %tstate. */
383 err |= __get_user(psr, &scptr->sigc_psr);
386 regs->tstate &= ~(TSTATE_ICC|TSTATE_XCC);
387 regs->tstate |= psr_to_tstate_icc(psr);
391 force_sig(SIGSEGV, current);
394 asmlinkage void do_rt_sigreturn32(struct pt_regs *regs)
396 struct rt_signal_frame32 __user *sf;
397 unsigned int psr, pc, npc, fpu_save, u_ss_sp;
400 compat_sigset_t seta;
404 /* Always make any pending restarted system calls return -EINTR */
405 current_thread_info()->restart_block.fn = do_no_restart_syscall;
407 synchronize_user_stack();
408 regs->u_regs[UREG_FP] &= 0x00000000ffffffffUL;
409 sf = (struct rt_signal_frame32 __user *) regs->u_regs[UREG_FP];
411 /* 1. Make sure we are not getting garbage from the user */
412 if (!access_ok(VERIFY_READ, sf, sizeof(*sf)) ||
413 (((unsigned long) sf) & 3))
416 get_user(pc, &sf->regs.pc);
417 __get_user(npc, &sf->regs.npc);
422 if (test_thread_flag(TIF_32BIT)) {
429 /* 2. Restore the state */
430 err = __get_user(regs->y, &sf->regs.y);
431 err |= __get_user(psr, &sf->regs.psr);
433 for (i = UREG_G1; i <= UREG_I7; i++)
434 err |= __get_user(regs->u_regs[i], &sf->regs.u_regs[i]);
435 if ((psr & (PSR_VERS|PSR_IMPL)) == PSR_V8PLUS) {
436 err |= __get_user(i, &sf->v8plus.g_upper[0]);
437 if (i == SIGINFO_EXTRA_V8PLUS_MAGIC) {
440 for (i = UREG_G1; i <= UREG_I7; i++)
441 err |= __get_user(((u32 *)regs->u_regs)[2*i], &sf->v8plus.g_upper[i]);
442 err |= __get_user(asi, &sf->v8plus.asi);
443 regs->tstate &= ~TSTATE_ASI;
444 regs->tstate |= ((asi & 0xffUL) << 24UL);
448 /* User can only change condition codes in %tstate. */
449 regs->tstate &= ~(TSTATE_ICC|TSTATE_XCC);
450 regs->tstate |= psr_to_tstate_icc(psr);
452 err |= __get_user(fpu_save, &sf->fpu_save);
454 err |= restore_fpu_state32(regs, &sf->fpu_state);
455 err |= copy_from_user(&seta, &sf->mask, sizeof(compat_sigset_t));
456 err |= __get_user(u_ss_sp, &sf->stack.ss_sp);
457 st.ss_sp = compat_ptr(u_ss_sp);
458 err |= __get_user(st.ss_flags, &sf->stack.ss_flags);
459 err |= __get_user(st.ss_size, &sf->stack.ss_size);
463 /* It is more difficult to avoid calling this function than to
464 call it and ignore errors. */
467 do_sigaltstack((stack_t __user *) &st, NULL, (unsigned long)sf);
470 switch (_NSIG_WORDS) {
471 case 4: set.sig[3] = seta.sig[6] + (((long)seta.sig[7]) << 32);
472 case 3: set.sig[2] = seta.sig[4] + (((long)seta.sig[5]) << 32);
473 case 2: set.sig[1] = seta.sig[2] + (((long)seta.sig[3]) << 32);
474 case 1: set.sig[0] = seta.sig[0] + (((long)seta.sig[1]) << 32);
476 sigdelsetmask(&set, ~_BLOCKABLE);
477 spin_lock_irq(¤t->sighand->siglock);
478 current->blocked = set;
480 spin_unlock_irq(¤t->sighand->siglock);
483 force_sig(SIGSEGV, current);
486 /* Checks if the fp is valid */
487 static int invalid_frame_pointer(void __user *fp, int fplen)
489 if ((((unsigned long) fp) & 7) || ((unsigned long)fp) > 0x100000000ULL - fplen)
494 static void __user *get_sigframe(struct sigaction *sa, struct pt_regs *regs, unsigned long framesize)
498 regs->u_regs[UREG_FP] &= 0x00000000ffffffffUL;
499 sp = regs->u_regs[UREG_FP];
501 /* This is the X/Open sanctioned signal stack switching. */
502 if (sa->sa_flags & SA_ONSTACK) {
503 if (!on_sig_stack(sp) && !((current->sas_ss_sp + current->sas_ss_size) & 7))
504 sp = current->sas_ss_sp + current->sas_ss_size;
506 return (void __user *)(sp - framesize);
510 setup_frame32(struct sigaction *sa, struct pt_regs *regs, int signr, sigset_t *oldset, siginfo_t *info)
512 struct signal_sframe32 __user *sframep;
513 struct sigcontext32 __user *sc;
514 unsigned int seta[_COMPAT_NSIG_WORDS];
516 void __user *sig_address;
518 unsigned long pc = regs->tpc;
519 unsigned long npc = regs->tnpc;
522 if (test_thread_flag(TIF_32BIT)) {
527 synchronize_user_stack();
528 save_and_clear_fpu();
530 sframep = (struct signal_sframe32 __user *)
531 get_sigframe(sa, regs, SF_ALIGNEDSZ);
532 if (invalid_frame_pointer(sframep, sizeof(*sframep))){
533 /* Don't change signal code and address, so that
534 * post mortem debuggers can have a look.
539 sc = &sframep->sig_context;
541 /* We've already made sure frame pointer isn't in kernel space... */
542 err = __put_user((sas_ss_flags(regs->u_regs[UREG_FP]) == SS_ONSTACK),
545 switch (_NSIG_WORDS) {
546 case 4: seta[7] = (oldset->sig[3] >> 32);
547 seta[6] = oldset->sig[3];
548 case 3: seta[5] = (oldset->sig[2] >> 32);
549 seta[4] = oldset->sig[2];
550 case 2: seta[3] = (oldset->sig[1] >> 32);
551 seta[2] = oldset->sig[1];
552 case 1: seta[1] = (oldset->sig[0] >> 32);
553 seta[0] = oldset->sig[0];
555 err |= __put_user(seta[0], &sc->sigc_mask);
556 err |= __copy_to_user(sframep->extramask, seta + 1,
557 (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int));
558 err |= __put_user(regs->u_regs[UREG_FP], &sc->sigc_sp);
559 err |= __put_user(pc, &sc->sigc_pc);
560 err |= __put_user(npc, &sc->sigc_npc);
561 psr = tstate_to_psr(regs->tstate);
562 if (current_thread_info()->fpsaved[0] & FPRS_FEF)
564 err |= __put_user(psr, &sc->sigc_psr);
565 err |= __put_user(regs->u_regs[UREG_G1], &sc->sigc_g1);
566 err |= __put_user(regs->u_regs[UREG_I0], &sc->sigc_o0);
567 err |= __put_user(get_thread_wsaved(), &sc->sigc_oswins);
569 err |= copy_in_user((u32 __user *)sframep,
570 (u32 __user *)(regs->u_regs[UREG_FP]),
571 sizeof(struct reg_window32));
573 set_thread_wsaved(0); /* So process is allowed to execute. */
574 err |= __put_user(signr, &sframep->sig_num);
577 if (SI_FROMKERNEL (info) && (info->si_code & __SI_MASK) == __SI_FAULT) {
578 sig_address = info->si_addr;
581 switch (info->si_code) {
582 case SEGV_MAPERR: sig_code = SUBSIG_NOMAPPING; break;
583 default: sig_code = SUBSIG_PROTECTION; break;
587 switch (info->si_code) {
588 case ILL_ILLOPC: sig_code = SUBSIG_ILLINST; break;
589 case ILL_PRVOPC: sig_code = SUBSIG_PRIVINST; break;
590 case ILL_ILLTRP: sig_code = SUBSIG_BADTRAP(info->si_trapno); break;
591 default: sig_code = SUBSIG_STACK; break;
595 switch (info->si_code) {
596 case FPE_INTDIV: sig_code = SUBSIG_IDIVZERO; break;
597 case FPE_INTOVF: sig_code = SUBSIG_FPINTOVFL; break;
598 case FPE_FLTDIV: sig_code = SUBSIG_FPDIVZERO; break;
599 case FPE_FLTOVF: sig_code = SUBSIG_FPOVFLOW; break;
600 case FPE_FLTUND: sig_code = SUBSIG_FPUNFLOW; break;
601 case FPE_FLTRES: sig_code = SUBSIG_FPINEXACT; break;
602 case FPE_FLTINV: sig_code = SUBSIG_FPOPERROR; break;
603 default: sig_code = SUBSIG_FPERROR; break;
607 switch (info->si_code) {
608 case BUS_ADRALN: sig_code = SUBSIG_ALIGNMENT; break;
609 case BUS_ADRERR: sig_code = SUBSIG_MISCERROR; break;
610 default: sig_code = SUBSIG_BUSTIMEOUT; break;
614 switch (info->si_code) {
615 case EMT_TAGOVF: sig_code = SUBSIG_TAG; break;
619 if (info->si_code == (__SI_FAULT|0x100)) {
620 /* See sys_sunos32.c */
621 sig_code = info->si_trapno;
628 err |= __put_user(ptr_to_compat(sig_address), &sframep->sig_address);
629 err |= __put_user(sig_code, &sframep->sig_code);
630 err |= __put_user(ptr_to_compat(sc), &sframep->sig_scptr);
634 regs->u_regs[UREG_FP] = (unsigned long) sframep;
635 regs->tpc = (unsigned long) sa->sa_handler;
636 regs->tnpc = (regs->tpc + 4);
637 if (test_thread_flag(TIF_32BIT)) {
638 regs->tpc &= 0xffffffff;
639 regs->tnpc &= 0xffffffff;
644 force_sigsegv(signr, current);
648 static int save_fpu_state32(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
650 unsigned long *fpregs = current_thread_info()->fpregs;
654 fprs = current_thread_info()->fpsaved[0];
656 err |= copy_to_user(&fpu->si_float_regs[0], fpregs,
657 (sizeof(unsigned int) * 32));
659 err |= copy_to_user(&fpu->si_float_regs[32], fpregs+16,
660 (sizeof(unsigned int) * 32));
661 err |= __put_user(current_thread_info()->xfsr[0], &fpu->si_fsr);
662 err |= __put_user(current_thread_info()->gsr[0], &fpu->si_gsr);
663 err |= __put_user(fprs, &fpu->si_fprs);
668 static void new_setup_frame32(struct k_sigaction *ka, struct pt_regs *regs,
669 int signo, sigset_t *oldset)
671 struct new_signal_frame32 __user *sf;
675 unsigned int seta[_COMPAT_NSIG_WORDS];
677 /* 1. Make sure everything is clean */
678 synchronize_user_stack();
679 save_and_clear_fpu();
681 sigframe_size = NF_ALIGNEDSZ;
682 if (!(current_thread_info()->fpsaved[0] & FPRS_FEF))
683 sigframe_size -= sizeof(__siginfo_fpu_t);
685 sf = (struct new_signal_frame32 __user *)
686 get_sigframe(&ka->sa, regs, sigframe_size);
688 if (invalid_frame_pointer(sf, sigframe_size))
691 if (get_thread_wsaved() != 0)
694 /* 2. Save the current process state */
695 if (test_thread_flag(TIF_32BIT)) {
696 regs->tpc &= 0xffffffff;
697 regs->tnpc &= 0xffffffff;
699 err = put_user(regs->tpc, &sf->info.si_regs.pc);
700 err |= __put_user(regs->tnpc, &sf->info.si_regs.npc);
701 err |= __put_user(regs->y, &sf->info.si_regs.y);
702 psr = tstate_to_psr(regs->tstate);
703 if (current_thread_info()->fpsaved[0] & FPRS_FEF)
705 err |= __put_user(psr, &sf->info.si_regs.psr);
706 for (i = 0; i < 16; i++)
707 err |= __put_user(regs->u_regs[i], &sf->info.si_regs.u_regs[i]);
708 err |= __put_user(sizeof(siginfo_extra_v8plus_t), &sf->extra_size);
709 err |= __put_user(SIGINFO_EXTRA_V8PLUS_MAGIC, &sf->v8plus.g_upper[0]);
710 for (i = 1; i < 16; i++)
711 err |= __put_user(((u32 *)regs->u_regs)[2*i],
712 &sf->v8plus.g_upper[i]);
713 err |= __put_user((regs->tstate & TSTATE_ASI) >> 24UL,
717 err |= save_fpu_state32(regs, &sf->fpu_state);
718 err |= __put_user((u64)&sf->fpu_state, &sf->fpu_save);
720 err |= __put_user(0, &sf->fpu_save);
723 switch (_NSIG_WORDS) {
724 case 4: seta[7] = (oldset->sig[3] >> 32);
725 seta[6] = oldset->sig[3];
726 case 3: seta[5] = (oldset->sig[2] >> 32);
727 seta[4] = oldset->sig[2];
728 case 2: seta[3] = (oldset->sig[1] >> 32);
729 seta[2] = oldset->sig[1];
730 case 1: seta[1] = (oldset->sig[0] >> 32);
731 seta[0] = oldset->sig[0];
733 err |= __put_user(seta[0], &sf->info.si_mask);
734 err |= __copy_to_user(sf->extramask, seta + 1,
735 (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int));
737 err |= copy_in_user((u32 __user *)sf,
738 (u32 __user *)(regs->u_regs[UREG_FP]),
739 sizeof(struct reg_window32));
744 /* 3. signal handler back-trampoline and parameters */
745 regs->u_regs[UREG_FP] = (unsigned long) sf;
746 regs->u_regs[UREG_I0] = signo;
747 regs->u_regs[UREG_I1] = (unsigned long) &sf->info;
748 regs->u_regs[UREG_I2] = (unsigned long) &sf->info;
750 /* 4. signal handler */
751 regs->tpc = (unsigned long) ka->sa.sa_handler;
752 regs->tnpc = (regs->tpc + 4);
753 if (test_thread_flag(TIF_32BIT)) {
754 regs->tpc &= 0xffffffff;
755 regs->tnpc &= 0xffffffff;
758 /* 5. return to kernel instructions */
759 if (ka->ka_restorer) {
760 regs->u_regs[UREG_I7] = (unsigned long)ka->ka_restorer;
762 /* Flush instruction space. */
763 unsigned long address = ((unsigned long)&(sf->insns[0]));
764 pgd_t *pgdp = pgd_offset(current->mm, address);
765 pud_t *pudp = pud_offset(pgdp, address);
766 pmd_t *pmdp = pmd_offset(pudp, address);
770 regs->u_regs[UREG_I7] = (unsigned long) (&(sf->insns[0]) - 2);
772 err = __put_user(0x821020d8, &sf->insns[0]); /*mov __NR_sigreturn, %g1*/
773 err |= __put_user(0x91d02010, &sf->insns[1]); /*t 0x10*/
778 ptep = pte_offset_map(pmdp, address);
780 if (pte_present(pte)) {
781 unsigned long page = (unsigned long)
782 page_address(pte_page(pte));
785 __asm__ __volatile__("flush %0 + %1"
788 "r" (address & (PAGE_SIZE - 1))
799 force_sigsegv(signo, current);
802 /* Setup a Solaris stack frame */
804 setup_svr4_frame32(struct sigaction *sa, unsigned long pc, unsigned long npc,
805 struct pt_regs *regs, int signr, sigset_t *oldset)
807 svr4_signal_frame_t __user *sfp;
808 svr4_gregset_t __user *gr;
809 svr4_siginfo_t __user *si;
810 svr4_mcontext_t __user *mc;
811 svr4_gwindows_t __user *gw;
812 svr4_ucontext_t __user *uc;
817 synchronize_user_stack();
818 save_and_clear_fpu();
820 regs->u_regs[UREG_FP] &= 0x00000000ffffffffUL;
821 sfp = (svr4_signal_frame_t __user *)
822 get_sigframe(sa, regs,
823 sizeof(struct reg_window32) + SVR4_SF_ALIGNED);
825 if (invalid_frame_pointer(sfp, sizeof(*sfp)))
828 /* Start with a clean frame pointer and fill it */
829 err = clear_user(sfp, sizeof(*sfp));
831 /* Setup convenience variables */
838 /* FIXME: where am I supposed to put this?
839 * sc->sigc_onstack = old_status;
840 * anyways, it does not look like it is used for anything at all.
842 setv.sigbits[0] = oldset->sig[0];
843 setv.sigbits[1] = (oldset->sig[0] >> 32);
844 if (_NSIG_WORDS >= 2) {
845 setv.sigbits[2] = oldset->sig[1];
846 setv.sigbits[3] = (oldset->sig[1] >> 32);
847 err |= __copy_to_user(&uc->sigmask, &setv, sizeof(svr4_sigset_t));
849 err |= __copy_to_user(&uc->sigmask, &setv,
850 2 * sizeof(unsigned int));
852 /* Store registers */
853 if (test_thread_flag(TIF_32BIT)) {
854 regs->tpc &= 0xffffffff;
855 regs->tnpc &= 0xffffffff;
857 err |= __put_user(regs->tpc, &((*gr)[SVR4_PC]));
858 err |= __put_user(regs->tnpc, &((*gr)[SVR4_NPC]));
859 psr = tstate_to_psr(regs->tstate);
860 if (current_thread_info()->fpsaved[0] & FPRS_FEF)
862 err |= __put_user(psr, &((*gr)[SVR4_PSR]));
863 err |= __put_user(regs->y, &((*gr)[SVR4_Y]));
865 /* Copy g[1..7] and o[0..7] registers */
866 for (i = 0; i < 7; i++)
867 err |= __put_user(regs->u_regs[UREG_G1+i], (&(*gr)[SVR4_G1])+i);
868 for (i = 0; i < 8; i++)
869 err |= __put_user(regs->u_regs[UREG_I0+i], (&(*gr)[SVR4_O0])+i);
871 /* Setup sigaltstack */
872 err |= __put_user(current->sas_ss_sp, &uc->stack.sp);
873 err |= __put_user(sas_ss_flags(regs->u_regs[UREG_FP]), &uc->stack.flags);
874 err |= __put_user(current->sas_ss_size, &uc->stack.size);
876 /* Save the currently window file: */
878 /* 1. Link sfp->uc->gwins to our windows */
879 err |= __put_user(ptr_to_compat(gw), &mc->gwin);
881 /* 2. Number of windows to restore at setcontext (): */
882 err |= __put_user(get_thread_wsaved(), &gw->count);
884 /* 3. We just pay attention to the gw->count field on setcontext */
885 set_thread_wsaved(0); /* So process is allowed to execute. */
887 /* Setup the signal information. Solaris expects a bunch of
888 * information to be passed to the signal handler, we don't provide
889 * that much currently, should use siginfo.
891 err |= __put_user(signr, &si->siginfo.signo);
892 err |= __put_user(SVR4_SINOINFO, &si->siginfo.code);
896 regs->u_regs[UREG_FP] = (unsigned long) sfp;
897 regs->tpc = (unsigned long) sa->sa_handler;
898 regs->tnpc = (regs->tpc + 4);
899 if (test_thread_flag(TIF_32BIT)) {
900 regs->tpc &= 0xffffffff;
901 regs->tnpc &= 0xffffffff;
904 /* Arguments passed to signal handler */
905 if (regs->u_regs[14]){
906 struct reg_window32 __user *rw = (struct reg_window32 __user *)
907 (regs->u_regs[14] & 0x00000000ffffffffUL);
909 err |= __put_user(signr, &rw->ins[0]);
910 err |= __put_user((u64)si, &rw->ins[1]);
911 err |= __put_user((u64)uc, &rw->ins[2]);
912 err |= __put_user((u64)sfp, &rw->ins[6]); /* frame pointer */
916 regs->u_regs[UREG_I0] = signr;
917 regs->u_regs[UREG_I1] = (u32)(u64) si;
918 regs->u_regs[UREG_I2] = (u32)(u64) uc;
923 force_sigsegv(signr, current);
927 svr4_getcontext(svr4_ucontext_t __user *uc, struct pt_regs *regs)
929 svr4_gregset_t __user *gr;
930 svr4_mcontext_t __user *mc;
935 synchronize_user_stack();
936 save_and_clear_fpu();
938 if (get_thread_wsaved())
941 err = clear_user(uc, sizeof(*uc));
943 /* Setup convenience variables */
947 setv.sigbits[0] = current->blocked.sig[0];
948 setv.sigbits[1] = (current->blocked.sig[0] >> 32);
949 if (_NSIG_WORDS >= 2) {
950 setv.sigbits[2] = current->blocked.sig[1];
951 setv.sigbits[3] = (current->blocked.sig[1] >> 32);
952 err |= __copy_to_user(&uc->sigmask, &setv, sizeof(svr4_sigset_t));
954 err |= __copy_to_user(&uc->sigmask, &setv, 2 * sizeof(unsigned));
956 /* Store registers */
957 if (test_thread_flag(TIF_32BIT)) {
958 regs->tpc &= 0xffffffff;
959 regs->tnpc &= 0xffffffff;
961 err |= __put_user(regs->tpc, &uc->mcontext.greg[SVR4_PC]);
962 err |= __put_user(regs->tnpc, &uc->mcontext.greg[SVR4_NPC]);
964 psr = tstate_to_psr(regs->tstate) & ~PSR_EF;
965 if (current_thread_info()->fpsaved[0] & FPRS_FEF)
967 err |= __put_user(psr, &uc->mcontext.greg[SVR4_PSR]);
969 err |= __put_user(regs->y, &uc->mcontext.greg[SVR4_Y]);
971 /* Copy g[1..7] and o[0..7] registers */
972 for (i = 0; i < 7; i++)
973 err |= __put_user(regs->u_regs[UREG_G1+i], (&(*gr)[SVR4_G1])+i);
974 for (i = 0; i < 8; i++)
975 err |= __put_user(regs->u_regs[UREG_I0+i], (&(*gr)[SVR4_O0])+i);
977 /* Setup sigaltstack */
978 err |= __put_user(current->sas_ss_sp, &uc->stack.sp);
979 err |= __put_user(sas_ss_flags(regs->u_regs[UREG_FP]), &uc->stack.flags);
980 err |= __put_user(current->sas_ss_size, &uc->stack.size);
982 /* The register file is not saved
983 * we have already stuffed all of it with sync_user_stack
985 return (err ? -EFAULT : 0);
989 /* Set the context for a svr4 application, this is Solaris way to sigreturn */
990 asmlinkage int svr4_setcontext(svr4_ucontext_t __user *c, struct pt_regs *regs)
992 svr4_gregset_t __user *gr;
994 u32 pc, npc, psr, u_ss_sp;
1000 /* Fixme: restore windows, or is this already taken care of in
1001 * svr4_setup_frame when sync_user_windows is done?
1003 flush_user_windows();
1005 if (get_thread_wsaved())
1008 if (((unsigned long) c) & 3){
1009 printk("Unaligned structure passed\n");
1013 if (!__access_ok(c, sizeof(*c))) {
1014 /* Miguel, add nice debugging msg _here_. ;-) */
1018 /* Check for valid PC and nPC */
1019 gr = &c->mcontext.greg;
1020 err = __get_user(pc, &((*gr)[SVR4_PC]));
1021 err |= __get_user(npc, &((*gr)[SVR4_NPC]));
1025 /* Retrieve information from passed ucontext */
1026 /* note that nPC is ored a 1, this is used to inform entry.S */
1027 /* that we don't want it to mess with our PC and nPC */
1029 err |= copy_from_user(&setv, &c->sigmask, sizeof(svr4_sigset_t));
1030 set.sig[0] = setv.sigbits[0] | (((long)setv.sigbits[1]) << 32);
1031 if (_NSIG_WORDS >= 2)
1032 set.sig[1] = setv.sigbits[2] | (((long)setv.sigbits[3]) << 32);
1034 err |= __get_user(u_ss_sp, &c->stack.sp);
1035 st.ss_sp = compat_ptr(u_ss_sp);
1036 err |= __get_user(st.ss_flags, &c->stack.flags);
1037 err |= __get_user(st.ss_size, &c->stack.size);
1041 /* It is more difficult to avoid calling this function than to
1042 call it and ignore errors. */
1045 do_sigaltstack((stack_t __user *) &st, NULL, regs->u_regs[UREG_I6]);
1048 sigdelsetmask(&set, ~_BLOCKABLE);
1049 spin_lock_irq(¤t->sighand->siglock);
1050 current->blocked = set;
1051 recalc_sigpending();
1052 spin_unlock_irq(¤t->sighand->siglock);
1054 regs->tnpc = npc | 1;
1055 if (test_thread_flag(TIF_32BIT)) {
1056 regs->tpc &= 0xffffffff;
1057 regs->tnpc &= 0xffffffff;
1059 err |= __get_user(regs->y, &((*gr)[SVR4_Y]));
1060 err |= __get_user(psr, &((*gr)[SVR4_PSR]));
1061 regs->tstate &= ~(TSTATE_ICC|TSTATE_XCC);
1062 regs->tstate |= psr_to_tstate_icc(psr);
1064 /* Restore g[1..7] and o[0..7] registers */
1065 for (i = 0; i < 7; i++)
1066 err |= __get_user(regs->u_regs[UREG_G1+i], (&(*gr)[SVR4_G1])+i);
1067 for (i = 0; i < 8; i++)
1068 err |= __get_user(regs->u_regs[UREG_I0+i], (&(*gr)[SVR4_O0])+i);
1077 static void setup_rt_frame32(struct k_sigaction *ka, struct pt_regs *regs,
1078 unsigned long signr, sigset_t *oldset,
1081 struct rt_signal_frame32 __user *sf;
1085 compat_sigset_t seta;
1087 /* 1. Make sure everything is clean */
1088 synchronize_user_stack();
1089 save_and_clear_fpu();
1091 sigframe_size = RT_ALIGNEDSZ;
1092 if (!(current_thread_info()->fpsaved[0] & FPRS_FEF))
1093 sigframe_size -= sizeof(__siginfo_fpu_t);
1095 sf = (struct rt_signal_frame32 __user *)
1096 get_sigframe(&ka->sa, regs, sigframe_size);
1098 if (invalid_frame_pointer(sf, sigframe_size))
1101 if (get_thread_wsaved() != 0)
1104 /* 2. Save the current process state */
1105 if (test_thread_flag(TIF_32BIT)) {
1106 regs->tpc &= 0xffffffff;
1107 regs->tnpc &= 0xffffffff;
1109 err = put_user(regs->tpc, &sf->regs.pc);
1110 err |= __put_user(regs->tnpc, &sf->regs.npc);
1111 err |= __put_user(regs->y, &sf->regs.y);
1112 psr = tstate_to_psr(regs->tstate);
1113 if (current_thread_info()->fpsaved[0] & FPRS_FEF)
1115 err |= __put_user(psr, &sf->regs.psr);
1116 for (i = 0; i < 16; i++)
1117 err |= __put_user(regs->u_regs[i], &sf->regs.u_regs[i]);
1118 err |= __put_user(sizeof(siginfo_extra_v8plus_t), &sf->extra_size);
1119 err |= __put_user(SIGINFO_EXTRA_V8PLUS_MAGIC, &sf->v8plus.g_upper[0]);
1120 for (i = 1; i < 16; i++)
1121 err |= __put_user(((u32 *)regs->u_regs)[2*i],
1122 &sf->v8plus.g_upper[i]);
1123 err |= __put_user((regs->tstate & TSTATE_ASI) >> 24UL,
1127 err |= save_fpu_state32(regs, &sf->fpu_state);
1128 err |= __put_user((u64)&sf->fpu_state, &sf->fpu_save);
1130 err |= __put_user(0, &sf->fpu_save);
1133 /* Update the siginfo structure. */
1134 err |= copy_siginfo_to_user32(&sf->info, info);
1136 /* Setup sigaltstack */
1137 err |= __put_user(current->sas_ss_sp, &sf->stack.ss_sp);
1138 err |= __put_user(sas_ss_flags(regs->u_regs[UREG_FP]), &sf->stack.ss_flags);
1139 err |= __put_user(current->sas_ss_size, &sf->stack.ss_size);
1141 switch (_NSIG_WORDS) {
1142 case 4: seta.sig[7] = (oldset->sig[3] >> 32);
1143 seta.sig[6] = oldset->sig[3];
1144 case 3: seta.sig[5] = (oldset->sig[2] >> 32);
1145 seta.sig[4] = oldset->sig[2];
1146 case 2: seta.sig[3] = (oldset->sig[1] >> 32);
1147 seta.sig[2] = oldset->sig[1];
1148 case 1: seta.sig[1] = (oldset->sig[0] >> 32);
1149 seta.sig[0] = oldset->sig[0];
1151 err |= __copy_to_user(&sf->mask, &seta, sizeof(compat_sigset_t));
1153 err |= copy_in_user((u32 __user *)sf,
1154 (u32 __user *)(regs->u_regs[UREG_FP]),
1155 sizeof(struct reg_window32));
1159 /* 3. signal handler back-trampoline and parameters */
1160 regs->u_regs[UREG_FP] = (unsigned long) sf;
1161 regs->u_regs[UREG_I0] = signr;
1162 regs->u_regs[UREG_I1] = (unsigned long) &sf->info;
1163 regs->u_regs[UREG_I2] = (unsigned long) &sf->regs;
1165 /* 4. signal handler */
1166 regs->tpc = (unsigned long) ka->sa.sa_handler;
1167 regs->tnpc = (regs->tpc + 4);
1168 if (test_thread_flag(TIF_32BIT)) {
1169 regs->tpc &= 0xffffffff;
1170 regs->tnpc &= 0xffffffff;
1173 /* 5. return to kernel instructions */
1174 if (ka->ka_restorer)
1175 regs->u_regs[UREG_I7] = (unsigned long)ka->ka_restorer;
1177 /* Flush instruction space. */
1178 unsigned long address = ((unsigned long)&(sf->insns[0]));
1179 pgd_t *pgdp = pgd_offset(current->mm, address);
1180 pud_t *pudp = pud_offset(pgdp, address);
1181 pmd_t *pmdp = pmd_offset(pudp, address);
1184 regs->u_regs[UREG_I7] = (unsigned long) (&(sf->insns[0]) - 2);
1186 /* mov __NR_rt_sigreturn, %g1 */
1187 err |= __put_user(0x82102065, &sf->insns[0]);
1190 err |= __put_user(0x91d02010, &sf->insns[1]);
1195 ptep = pte_offset_map(pmdp, address);
1196 if (pte_present(*ptep)) {
1197 unsigned long page = (unsigned long)
1198 page_address(pte_page(*ptep));
1201 __asm__ __volatile__("flush %0 + %1"
1204 "r" (address & (PAGE_SIZE - 1))
1215 force_sigsegv(signr, current);
1218 static inline void handle_signal32(unsigned long signr, struct k_sigaction *ka,
1220 sigset_t *oldset, struct pt_regs *regs,
1224 setup_svr4_frame32(&ka->sa, regs->tpc, regs->tnpc,
1225 regs, signr, oldset);
1227 if (ka->sa.sa_flags & SA_SIGINFO)
1228 setup_rt_frame32(ka, regs, signr, oldset, info);
1229 else if (test_thread_flag(TIF_NEWSIGNALS))
1230 new_setup_frame32(ka, regs, signr, oldset);
1232 setup_frame32(&ka->sa, regs, signr, oldset, info);
1234 spin_lock_irq(¤t->sighand->siglock);
1235 sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask);
1236 if (!(ka->sa.sa_flags & SA_NOMASK))
1237 sigaddset(¤t->blocked,signr);
1238 recalc_sigpending();
1239 spin_unlock_irq(¤t->sighand->siglock);
1242 static inline void syscall_restart32(unsigned long orig_i0, struct pt_regs *regs,
1243 struct sigaction *sa)
1245 switch (regs->u_regs[UREG_I0]) {
1246 case ERESTART_RESTARTBLOCK:
1247 case ERESTARTNOHAND:
1248 no_system_call_restart:
1249 regs->u_regs[UREG_I0] = EINTR;
1250 regs->tstate |= TSTATE_ICARRY;
1253 if (!(sa->sa_flags & SA_RESTART))
1254 goto no_system_call_restart;
1256 case ERESTARTNOINTR:
1257 regs->u_regs[UREG_I0] = orig_i0;
1263 /* Note that 'init' is a special process: it doesn't get signals it doesn't
1264 * want to handle. Thus you cannot kill init even with a SIGKILL even by
1267 void do_signal32(sigset_t *oldset, struct pt_regs * regs,
1268 unsigned long orig_i0, int restart_syscall)
1271 struct signal_deliver_cookie cookie;
1272 struct k_sigaction ka;
1274 int svr4_signal = current->personality == PER_SVR4;
1276 cookie.restart_syscall = restart_syscall;
1277 cookie.orig_i0 = orig_i0;
1279 signr = get_signal_to_deliver(&info, &ka, regs, &cookie);
1281 if (cookie.restart_syscall)
1282 syscall_restart32(orig_i0, regs, &ka.sa);
1283 handle_signal32(signr, &ka, &info, oldset,
1286 /* a signal was successfully delivered; the saved
1287 * sigmask will have been stored in the signal frame,
1288 * and will be restored by sigreturn, so we can simply
1289 * clear the TIF_RESTORE_SIGMASK flag.
1291 if (test_thread_flag(TIF_RESTORE_SIGMASK))
1292 clear_thread_flag(TIF_RESTORE_SIGMASK);
1295 if (cookie.restart_syscall &&
1296 (regs->u_regs[UREG_I0] == ERESTARTNOHAND ||
1297 regs->u_regs[UREG_I0] == ERESTARTSYS ||
1298 regs->u_regs[UREG_I0] == ERESTARTNOINTR)) {
1299 /* replay the system call when we are done */
1300 regs->u_regs[UREG_I0] = cookie.orig_i0;
1304 if (cookie.restart_syscall &&
1305 regs->u_regs[UREG_I0] == ERESTART_RESTARTBLOCK) {
1306 regs->u_regs[UREG_G1] = __NR_restart_syscall;
1311 /* if there's no signal to deliver, we just put the saved sigmask
1314 if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
1315 clear_thread_flag(TIF_RESTORE_SIGMASK);
1316 sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL);
1325 asmlinkage int do_sys32_sigstack(u32 u_ssptr, u32 u_ossptr, unsigned long sp)
1327 struct sigstack32 __user *ssptr =
1328 (struct sigstack32 __user *)((unsigned long)(u_ssptr));
1329 struct sigstack32 __user *ossptr =
1330 (struct sigstack32 __user *)((unsigned long)(u_ossptr));
1333 /* First see if old state is wanted. */
1335 if (put_user(current->sas_ss_sp + current->sas_ss_size,
1336 &ossptr->the_stack) ||
1337 __put_user(on_sig_stack(sp), &ossptr->cur_status))
1341 /* Now see if we want to update the new state. */
1345 if (get_user(ss_sp, &ssptr->the_stack))
1348 /* If the current stack was set with sigaltstack, don't
1349 * swap stacks while we are on it.
1352 if (current->sas_ss_sp && on_sig_stack(sp))
1355 /* Since we don't know the extent of the stack, and we don't
1356 * track onstack-ness, but rather calculate it, we must
1357 * presume a size. Ho hum this interface is lossy.
1359 current->sas_ss_sp = (unsigned long)ss_sp - SIGSTKSZ;
1360 current->sas_ss_size = SIGSTKSZ;
1368 asmlinkage long do_sys32_sigaltstack(u32 ussa, u32 uossa, unsigned long sp)
1373 mm_segment_t old_fs;
1374 stack_t32 __user *uss32 = compat_ptr(ussa);
1375 stack_t32 __user *uoss32 = compat_ptr(uossa);
1377 if (ussa && (get_user(u_ss_sp, &uss32->ss_sp) ||
1378 __get_user(uss.ss_flags, &uss32->ss_flags) ||
1379 __get_user(uss.ss_size, &uss32->ss_size)))
1381 uss.ss_sp = compat_ptr(u_ss_sp);
1384 ret = do_sigaltstack(ussa ? (stack_t __user *) &uss : NULL,
1385 uossa ? (stack_t __user *) &uoss : NULL, sp);
1387 if (!ret && uossa && (put_user(ptr_to_compat(uoss.ss_sp), &uoss32->ss_sp) ||
1388 __put_user(uoss.ss_flags, &uoss32->ss_flags) ||
1389 __put_user(uoss.ss_size, &uoss32->ss_size)))