1 /* $Id: signal.c,v 1.110 2002/02/08 03:57:14 davem Exp $
2 * linux/arch/sparc/kernel/signal.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)
10 #include <linux/sched.h>
11 #include <linux/kernel.h>
12 #include <linux/signal.h>
13 #include <linux/errno.h>
14 #include <linux/wait.h>
15 #include <linux/ptrace.h>
16 #include <linux/unistd.h>
18 #include <linux/tty.h>
19 #include <linux/smp.h>
20 #include <linux/binfmts.h> /* do_coredum */
21 #include <linux/bitops.h>
23 #include <asm/uaccess.h>
24 #include <asm/ptrace.h>
25 #include <asm/pgalloc.h>
26 #include <asm/pgtable.h>
27 #include <asm/cacheflush.h> /* flush_sig_insns */
29 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
31 extern void fpsave(unsigned long *fpregs, unsigned long *fsr,
32 void *fpqueue, unsigned long *fpqdepth);
33 extern void fpload(unsigned long *fpregs, unsigned long *fsr);
35 /* Signal frames: the original one (compatible with SunOS):
37 * Set up a signal frame... Make the stack look the way SunOS
38 * expects it to look which is basically:
40 * ---------------------------------- <-- %sp at signal time
43 * Ptr to sigcontext area above
45 * The signal number itself
47 * ---------------------------------- <-- New %sp
49 struct signal_sframe {
50 struct reg_window sig_window;
53 struct sigcontext __user *sig_scptr;
55 struct sigcontext sig_context;
56 unsigned int extramask[_NSIG_WORDS - 1];
60 * And the new one, intended to be used for Linux applications only
61 * (we have enough in there to work with clone).
62 * All the interesting bits are in the info field.
65 struct new_signal_frame {
66 struct sparc_stackf ss;
68 __siginfo_fpu_t __user *fpu_save;
69 unsigned long insns[2] __attribute__ ((aligned (8)));
70 unsigned int extramask[_NSIG_WORDS - 1];
71 unsigned int extra_size; /* Should be 0 */
72 __siginfo_fpu_t fpu_state;
75 struct rt_signal_frame {
76 struct sparc_stackf ss;
80 __siginfo_fpu_t __user *fpu_save;
81 unsigned int insns[2];
83 unsigned int extra_size; /* Should be 0 */
84 __siginfo_fpu_t fpu_state;
88 #define SF_ALIGNEDSZ (((sizeof(struct signal_sframe) + 7) & (~7)))
89 #define NF_ALIGNEDSZ (((sizeof(struct new_signal_frame) + 7) & (~7)))
90 #define RT_ALIGNEDSZ (((sizeof(struct rt_signal_frame) + 7) & (~7)))
92 static int _sigpause_common(old_sigset_t set)
95 spin_lock_irq(¤t->sighand->siglock);
96 current->saved_sigmask = current->blocked;
97 siginitset(¤t->blocked, set);
99 spin_unlock_irq(¤t->sighand->siglock);
101 current->state = TASK_INTERRUPTIBLE;
103 set_thread_flag(TIF_RESTORE_SIGMASK);
105 return -ERESTARTNOHAND;
108 asmlinkage int sys_sigpause(unsigned int set)
110 return _sigpause_common(set);
113 asmlinkage int sys_sigsuspend(old_sigset_t set)
115 return _sigpause_common(set);
119 restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
123 if (test_tsk_thread_flag(current, TIF_USEDFPU))
124 regs->psr &= ~PSR_EF;
126 if (current == last_task_used_math) {
127 last_task_used_math = NULL;
128 regs->psr &= ~PSR_EF;
132 clear_tsk_thread_flag(current, TIF_USEDFPU);
134 if (!access_ok(VERIFY_READ, fpu, sizeof(*fpu)))
137 err = __copy_from_user(¤t->thread.float_regs[0], &fpu->si_float_regs[0],
138 (sizeof(unsigned long) * 32));
139 err |= __get_user(current->thread.fsr, &fpu->si_fsr);
140 err |= __get_user(current->thread.fpqdepth, &fpu->si_fpqdepth);
141 if (current->thread.fpqdepth != 0)
142 err |= __copy_from_user(¤t->thread.fpqueue[0],
144 ((sizeof(unsigned long) +
145 (sizeof(unsigned long *)))*16));
149 static inline void do_new_sigreturn (struct pt_regs *regs)
151 struct new_signal_frame __user *sf;
152 unsigned long up_psr, pc, npc;
154 __siginfo_fpu_t __user *fpu_save;
157 sf = (struct new_signal_frame __user *) regs->u_regs[UREG_FP];
159 /* 1. Make sure we are not getting garbage from the user */
160 if (!access_ok(VERIFY_READ, sf, sizeof(*sf)))
163 if (((unsigned long) sf) & 3)
166 err = __get_user(pc, &sf->info.si_regs.pc);
167 err |= __get_user(npc, &sf->info.si_regs.npc);
172 /* 2. Restore the state */
174 err |= __copy_from_user(regs, &sf->info.si_regs, sizeof(struct pt_regs));
176 /* User can only change condition codes and FPU enabling in %psr. */
177 regs->psr = (up_psr & ~(PSR_ICC | PSR_EF))
178 | (regs->psr & (PSR_ICC | PSR_EF));
180 err |= __get_user(fpu_save, &sf->fpu_save);
183 err |= restore_fpu_state(regs, fpu_save);
185 /* This is pretty much atomic, no amount locking would prevent
186 * the races which exist anyways.
188 err |= __get_user(set.sig[0], &sf->info.si_mask);
189 err |= __copy_from_user(&set.sig[1], &sf->extramask,
190 (_NSIG_WORDS-1) * sizeof(unsigned int));
195 sigdelsetmask(&set, ~_BLOCKABLE);
196 spin_lock_irq(¤t->sighand->siglock);
197 current->blocked = set;
199 spin_unlock_irq(¤t->sighand->siglock);
203 force_sig(SIGSEGV, current);
206 asmlinkage void do_sigreturn(struct pt_regs *regs)
208 struct sigcontext __user *scptr;
209 unsigned long pc, npc, psr;
213 /* Always make any pending restarted system calls return -EINTR */
214 current_thread_info()->restart_block.fn = do_no_restart_syscall;
216 synchronize_user_stack();
218 if (current->thread.new_signal) {
219 do_new_sigreturn(regs);
223 scptr = (struct sigcontext __user *) regs->u_regs[UREG_I0];
225 /* Check sanity of the user arg. */
226 if (!access_ok(VERIFY_READ, scptr, sizeof(struct sigcontext)) ||
227 (((unsigned long) scptr) & 3))
230 err = __get_user(pc, &scptr->sigc_pc);
231 err |= __get_user(npc, &scptr->sigc_npc);
236 /* This is pretty much atomic, no amount locking would prevent
237 * the races which exist anyways.
239 err |= __get_user(set.sig[0], &scptr->sigc_mask);
240 /* Note that scptr + 1 points to extramask */
241 err |= __copy_from_user(&set.sig[1], scptr + 1,
242 (_NSIG_WORDS - 1) * sizeof(unsigned int));
247 sigdelsetmask(&set, ~_BLOCKABLE);
248 spin_lock_irq(¤t->sighand->siglock);
249 current->blocked = set;
251 spin_unlock_irq(¤t->sighand->siglock);
256 err = __get_user(regs->u_regs[UREG_FP], &scptr->sigc_sp);
257 err |= __get_user(regs->u_regs[UREG_I0], &scptr->sigc_o0);
258 err |= __get_user(regs->u_regs[UREG_G1], &scptr->sigc_g1);
260 /* User can only change condition codes in %psr. */
261 err |= __get_user(psr, &scptr->sigc_psr);
265 regs->psr &= ~(PSR_ICC);
266 regs->psr |= (psr & PSR_ICC);
270 force_sig(SIGSEGV, current);
273 asmlinkage void do_rt_sigreturn(struct pt_regs *regs)
275 struct rt_signal_frame __user *sf;
276 unsigned int psr, pc, npc;
277 __siginfo_fpu_t __user *fpu_save;
283 synchronize_user_stack();
284 sf = (struct rt_signal_frame __user *) regs->u_regs[UREG_FP];
285 if (!access_ok(VERIFY_READ, sf, sizeof(*sf)) ||
286 (((unsigned long) sf) & 0x03))
289 err = __get_user(pc, &sf->regs.pc);
290 err |= __get_user(npc, &sf->regs.npc);
291 err |= ((pc | npc) & 0x03);
293 err |= __get_user(regs->y, &sf->regs.y);
294 err |= __get_user(psr, &sf->regs.psr);
296 err |= __copy_from_user(®s->u_regs[UREG_G1],
297 &sf->regs.u_regs[UREG_G1], 15 * sizeof(u32));
299 regs->psr = (regs->psr & ~PSR_ICC) | (psr & PSR_ICC);
301 err |= __get_user(fpu_save, &sf->fpu_save);
304 err |= restore_fpu_state(regs, fpu_save);
305 err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t));
307 err |= __copy_from_user(&st, &sf->stack, sizeof(stack_t));
315 /* It is more difficult to avoid calling this function than to
316 * call it and ignore errors.
320 do_sigaltstack((const stack_t __user *) &st, NULL, (unsigned long)sf);
323 sigdelsetmask(&set, ~_BLOCKABLE);
324 spin_lock_irq(¤t->sighand->siglock);
325 current->blocked = set;
327 spin_unlock_irq(¤t->sighand->siglock);
330 force_sig(SIGSEGV, current);
333 /* Checks if the fp is valid */
334 static inline int invalid_frame_pointer(void __user *fp, int fplen)
336 if ((((unsigned long) fp) & 7) ||
337 !__access_ok((unsigned long)fp, fplen) ||
338 ((sparc_cpu_model == sun4 || sparc_cpu_model == sun4c) &&
339 ((unsigned long) fp < 0xe0000000 && (unsigned long) fp >= 0x20000000)))
345 static inline void __user *get_sigframe(struct sigaction *sa, struct pt_regs *regs, unsigned long framesize)
349 sp = regs->u_regs[UREG_FP];
351 /* This is the X/Open sanctioned signal stack switching. */
352 if (sa->sa_flags & SA_ONSTACK) {
353 if (!on_sig_stack(sp) && !((current->sas_ss_sp + current->sas_ss_size) & 7))
354 sp = current->sas_ss_sp + current->sas_ss_size;
356 return (void __user *)(sp - framesize);
360 setup_frame(struct sigaction *sa, struct pt_regs *regs, int signr, sigset_t *oldset, siginfo_t *info)
362 struct signal_sframe __user *sframep;
363 struct sigcontext __user *sc;
365 unsigned long pc = regs->pc;
366 unsigned long npc = regs->npc;
367 struct thread_info *tp = current_thread_info();
368 void __user *sig_address;
371 synchronize_user_stack();
372 sframep = (struct signal_sframe __user *)
373 get_sigframe(sa, regs, SF_ALIGNEDSZ);
374 if (invalid_frame_pointer(sframep, sizeof(*sframep))){
375 /* Don't change signal code and address, so that
376 * post mortem debuggers can have a look.
378 goto sigill_and_return;
381 sc = &sframep->sig_context;
383 /* We've already made sure frame pointer isn't in kernel space... */
384 err = __put_user((sas_ss_flags(regs->u_regs[UREG_FP]) == SS_ONSTACK),
386 err |= __put_user(oldset->sig[0], &sc->sigc_mask);
387 err |= __copy_to_user(sframep->extramask, &oldset->sig[1],
388 (_NSIG_WORDS - 1) * sizeof(unsigned int));
389 err |= __put_user(regs->u_regs[UREG_FP], &sc->sigc_sp);
390 err |= __put_user(pc, &sc->sigc_pc);
391 err |= __put_user(npc, &sc->sigc_npc);
392 err |= __put_user(regs->psr, &sc->sigc_psr);
393 err |= __put_user(regs->u_regs[UREG_G1], &sc->sigc_g1);
394 err |= __put_user(regs->u_regs[UREG_I0], &sc->sigc_o0);
395 err |= __put_user(tp->w_saved, &sc->sigc_oswins);
397 for (window = 0; window < tp->w_saved; window++) {
398 put_user((char *)tp->rwbuf_stkptrs[window],
399 &sc->sigc_spbuf[window]);
400 err |= __copy_to_user(&sc->sigc_wbuf[window],
401 &tp->reg_window[window],
402 sizeof(struct reg_window));
405 err |= __copy_to_user(sframep, (char *) regs->u_regs[UREG_FP],
406 sizeof(struct reg_window));
408 tp->w_saved = 0; /* So process is allowed to execute. */
410 err |= __put_user(signr, &sframep->sig_num);
413 if (SI_FROMKERNEL (info) && (info->si_code & __SI_MASK) == __SI_FAULT) {
414 sig_address = info->si_addr;
417 switch (info->si_code) {
418 case SEGV_MAPERR: sig_code = SUBSIG_NOMAPPING; break;
419 default: sig_code = SUBSIG_PROTECTION; break;
423 switch (info->si_code) {
424 case ILL_ILLOPC: sig_code = SUBSIG_ILLINST; break;
425 case ILL_PRVOPC: sig_code = SUBSIG_PRIVINST; break;
426 case ILL_ILLTRP: sig_code = SUBSIG_BADTRAP(info->si_trapno); break;
427 default: sig_code = SUBSIG_STACK; break;
431 switch (info->si_code) {
432 case FPE_INTDIV: sig_code = SUBSIG_IDIVZERO; break;
433 case FPE_INTOVF: sig_code = SUBSIG_FPINTOVFL; break;
434 case FPE_FLTDIV: sig_code = SUBSIG_FPDIVZERO; break;
435 case FPE_FLTOVF: sig_code = SUBSIG_FPOVFLOW; break;
436 case FPE_FLTUND: sig_code = SUBSIG_FPUNFLOW; break;
437 case FPE_FLTRES: sig_code = SUBSIG_FPINEXACT; break;
438 case FPE_FLTINV: sig_code = SUBSIG_FPOPERROR; break;
439 default: sig_code = SUBSIG_FPERROR; break;
443 switch (info->si_code) {
444 case BUS_ADRALN: sig_code = SUBSIG_ALIGNMENT; break;
445 case BUS_ADRERR: sig_code = SUBSIG_MISCERROR; break;
446 default: sig_code = SUBSIG_BUSTIMEOUT; break;
450 switch (info->si_code) {
451 case EMT_TAGOVF: sig_code = SUBSIG_TAG; break;
455 if (info->si_code == (__SI_FAULT|0x100)) {
456 sig_code = info->si_trapno;
463 err |= __put_user((unsigned long)sig_address, &sframep->sig_address);
464 err |= __put_user(sig_code, &sframep->sig_code);
465 err |= __put_user(sc, &sframep->sig_scptr);
469 regs->u_regs[UREG_FP] = (unsigned long) sframep;
470 regs->pc = (unsigned long) sa->sa_handler;
471 regs->npc = (regs->pc + 4);
477 force_sigsegv(signr, current);
482 save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
486 if (test_tsk_thread_flag(current, TIF_USEDFPU)) {
487 put_psr(get_psr() | PSR_EF);
488 fpsave(¤t->thread.float_regs[0], ¤t->thread.fsr,
489 ¤t->thread.fpqueue[0], ¤t->thread.fpqdepth);
490 regs->psr &= ~(PSR_EF);
491 clear_tsk_thread_flag(current, TIF_USEDFPU);
494 if (current == last_task_used_math) {
495 put_psr(get_psr() | PSR_EF);
496 fpsave(¤t->thread.float_regs[0], ¤t->thread.fsr,
497 ¤t->thread.fpqueue[0], ¤t->thread.fpqdepth);
498 last_task_used_math = NULL;
499 regs->psr &= ~(PSR_EF);
502 err |= __copy_to_user(&fpu->si_float_regs[0],
503 ¤t->thread.float_regs[0],
504 (sizeof(unsigned long) * 32));
505 err |= __put_user(current->thread.fsr, &fpu->si_fsr);
506 err |= __put_user(current->thread.fpqdepth, &fpu->si_fpqdepth);
507 if (current->thread.fpqdepth != 0)
508 err |= __copy_to_user(&fpu->si_fpqueue[0],
509 ¤t->thread.fpqueue[0],
510 ((sizeof(unsigned long) +
511 (sizeof(unsigned long *)))*16));
517 new_setup_frame(struct k_sigaction *ka, struct pt_regs *regs,
518 int signo, sigset_t *oldset)
520 struct new_signal_frame __user *sf;
521 int sigframe_size, err;
523 /* 1. Make sure everything is clean */
524 synchronize_user_stack();
526 sigframe_size = NF_ALIGNEDSZ;
528 sigframe_size -= sizeof(__siginfo_fpu_t);
530 sf = (struct new_signal_frame __user *)
531 get_sigframe(&ka->sa, regs, sigframe_size);
533 if (invalid_frame_pointer(sf, sigframe_size))
534 goto sigill_and_return;
536 if (current_thread_info()->w_saved != 0)
537 goto sigill_and_return;
539 /* 2. Save the current process state */
540 err = __copy_to_user(&sf->info.si_regs, regs, sizeof(struct pt_regs));
542 err |= __put_user(0, &sf->extra_size);
545 err |= save_fpu_state(regs, &sf->fpu_state);
546 err |= __put_user(&sf->fpu_state, &sf->fpu_save);
548 err |= __put_user(0, &sf->fpu_save);
551 err |= __put_user(oldset->sig[0], &sf->info.si_mask);
552 err |= __copy_to_user(sf->extramask, &oldset->sig[1],
553 (_NSIG_WORDS - 1) * sizeof(unsigned int));
554 err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP],
555 sizeof(struct reg_window));
559 /* 3. signal handler back-trampoline and parameters */
560 regs->u_regs[UREG_FP] = (unsigned long) sf;
561 regs->u_regs[UREG_I0] = signo;
562 regs->u_regs[UREG_I1] = (unsigned long) &sf->info;
563 regs->u_regs[UREG_I2] = (unsigned long) &sf->info;
565 /* 4. signal handler */
566 regs->pc = (unsigned long) ka->sa.sa_handler;
567 regs->npc = (regs->pc + 4);
569 /* 5. return to kernel instructions */
571 regs->u_regs[UREG_I7] = (unsigned long)ka->ka_restorer;
573 regs->u_regs[UREG_I7] = (unsigned long)(&(sf->insns[0]) - 2);
575 /* mov __NR_sigreturn, %g1 */
576 err |= __put_user(0x821020d8, &sf->insns[0]);
579 err |= __put_user(0x91d02010, &sf->insns[1]);
583 /* Flush instruction space. */
584 flush_sig_insns(current->mm, (unsigned long) &(sf->insns[0]));
591 force_sigsegv(signo, current);
595 new_setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
596 int signo, sigset_t *oldset, siginfo_t *info)
598 struct rt_signal_frame __user *sf;
603 synchronize_user_stack();
604 sigframe_size = RT_ALIGNEDSZ;
606 sigframe_size -= sizeof(__siginfo_fpu_t);
607 sf = (struct rt_signal_frame __user *)
608 get_sigframe(&ka->sa, regs, sigframe_size);
609 if (invalid_frame_pointer(sf, sigframe_size))
611 if (current_thread_info()->w_saved != 0)
614 err = __put_user(regs->pc, &sf->regs.pc);
615 err |= __put_user(regs->npc, &sf->regs.npc);
616 err |= __put_user(regs->y, &sf->regs.y);
620 err |= __put_user(psr, &sf->regs.psr);
621 err |= __copy_to_user(&sf->regs.u_regs, regs->u_regs, sizeof(regs->u_regs));
622 err |= __put_user(0, &sf->extra_size);
625 err |= save_fpu_state(regs, &sf->fpu_state);
626 err |= __put_user(&sf->fpu_state, &sf->fpu_save);
628 err |= __put_user(0, &sf->fpu_save);
630 err |= __copy_to_user(&sf->mask, &oldset->sig[0], sizeof(sigset_t));
632 /* Setup sigaltstack */
633 err |= __put_user(current->sas_ss_sp, &sf->stack.ss_sp);
634 err |= __put_user(sas_ss_flags(regs->u_regs[UREG_FP]), &sf->stack.ss_flags);
635 err |= __put_user(current->sas_ss_size, &sf->stack.ss_size);
637 err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP],
638 sizeof(struct reg_window));
640 err |= copy_siginfo_to_user(&sf->info, info);
645 regs->u_regs[UREG_FP] = (unsigned long) sf;
646 regs->u_regs[UREG_I0] = signo;
647 regs->u_regs[UREG_I1] = (unsigned long) &sf->info;
648 regs->u_regs[UREG_I2] = (unsigned long) &sf->regs;
650 regs->pc = (unsigned long) ka->sa.sa_handler;
651 regs->npc = (regs->pc + 4);
654 regs->u_regs[UREG_I7] = (unsigned long)ka->ka_restorer;
656 regs->u_regs[UREG_I7] = (unsigned long)(&(sf->insns[0]) - 2);
658 /* mov __NR_sigreturn, %g1 */
659 err |= __put_user(0x821020d8, &sf->insns[0]);
662 err |= __put_user(0x91d02010, &sf->insns[1]);
666 /* Flush instruction space. */
667 flush_sig_insns(current->mm, (unsigned long) &(sf->insns[0]));
674 force_sigsegv(signo, current);
678 handle_signal(unsigned long signr, struct k_sigaction *ka,
679 siginfo_t *info, sigset_t *oldset, struct pt_regs *regs)
681 if (ka->sa.sa_flags & SA_SIGINFO)
682 new_setup_rt_frame(ka, regs, signr, oldset, info);
683 else if (current->thread.new_signal)
684 new_setup_frame(ka, regs, signr, oldset);
686 setup_frame(&ka->sa, regs, signr, oldset, info);
688 spin_lock_irq(¤t->sighand->siglock);
689 sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask);
690 if (!(ka->sa.sa_flags & SA_NOMASK))
691 sigaddset(¤t->blocked, signr);
693 spin_unlock_irq(¤t->sighand->siglock);
696 static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs,
697 struct sigaction *sa)
699 switch(regs->u_regs[UREG_I0]) {
700 case ERESTART_RESTARTBLOCK:
702 no_system_call_restart:
703 regs->u_regs[UREG_I0] = EINTR;
707 if (!(sa->sa_flags & SA_RESTART))
708 goto no_system_call_restart;
711 regs->u_regs[UREG_I0] = orig_i0;
717 /* Note that 'init' is a special process: it doesn't get signals it doesn't
718 * want to handle. Thus you cannot kill init even with a SIGKILL even by
721 asmlinkage void do_signal(struct pt_regs * regs, unsigned long orig_i0, int restart_syscall)
724 struct sparc_deliver_cookie cookie;
725 struct k_sigaction ka;
729 cookie.restart_syscall = restart_syscall;
730 cookie.orig_i0 = orig_i0;
732 if (test_thread_flag(TIF_RESTORE_SIGMASK))
733 oldset = ¤t->saved_sigmask;
735 oldset = ¤t->blocked;
737 signr = get_signal_to_deliver(&info, &ka, regs, &cookie);
739 if (cookie.restart_syscall)
740 syscall_restart(cookie.orig_i0, regs, &ka.sa);
741 handle_signal(signr, &ka, &info, oldset, regs);
743 /* a signal was successfully delivered; the saved
744 * sigmask will have been stored in the signal frame,
745 * and will be restored by sigreturn, so we can simply
746 * clear the TIF_RESTORE_SIGMASK flag.
748 if (test_thread_flag(TIF_RESTORE_SIGMASK))
749 clear_thread_flag(TIF_RESTORE_SIGMASK);
752 if (cookie.restart_syscall &&
753 (regs->u_regs[UREG_I0] == ERESTARTNOHAND ||
754 regs->u_regs[UREG_I0] == ERESTARTSYS ||
755 regs->u_regs[UREG_I0] == ERESTARTNOINTR)) {
756 /* replay the system call when we are done */
757 regs->u_regs[UREG_I0] = cookie.orig_i0;
761 if (cookie.restart_syscall &&
762 regs->u_regs[UREG_I0] == ERESTART_RESTARTBLOCK) {
763 regs->u_regs[UREG_G1] = __NR_restart_syscall;
768 /* if there's no signal to deliver, we just put the saved sigmask
771 if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
772 clear_thread_flag(TIF_RESTORE_SIGMASK);
773 sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL);
778 do_sys_sigstack(struct sigstack __user *ssptr, struct sigstack __user *ossptr,
783 /* First see if old state is wanted. */
785 if (put_user(current->sas_ss_sp + current->sas_ss_size,
786 &ossptr->the_stack) ||
787 __put_user(on_sig_stack(sp), &ossptr->cur_status))
791 /* Now see if we want to update the new state. */
795 if (get_user(ss_sp, &ssptr->the_stack))
797 /* If the current stack was set with sigaltstack, don't
798 swap stacks while we are on it. */
800 if (current->sas_ss_sp && on_sig_stack(sp))
803 /* Since we don't know the extent of the stack, and we don't
804 track onstack-ness, but rather calculate it, we must
805 presume a size. Ho hum this interface is lossy. */
806 current->sas_ss_sp = (unsigned long)ss_sp - SIGSTKSZ;
807 current->sas_ss_size = SIGSTKSZ;
814 void ptrace_signal_deliver(struct pt_regs *regs, void *cookie)
816 struct sparc_deliver_cookie *cp = cookie;
818 if (cp->restart_syscall &&
819 (regs->u_regs[UREG_I0] == ERESTARTNOHAND ||
820 regs->u_regs[UREG_I0] == ERESTARTSYS ||
821 regs->u_regs[UREG_I0] == ERESTARTNOINTR)) {
822 /* replay the system call when we are done */
823 regs->u_regs[UREG_I0] = cp->orig_i0;
826 cp->restart_syscall = 0;
829 if (cp->restart_syscall &&
830 regs->u_regs[UREG_I0] == ERESTART_RESTARTBLOCK) {
831 regs->u_regs[UREG_G1] = __NR_restart_syscall;
834 cp->restart_syscall = 0;