2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 1991, 1992 Linus Torvalds
7 * Copyright (C) 1994 - 2000 Ralf Baechle
8 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
10 #include <linux/cache.h>
11 #include <linux/sched.h>
13 #include <linux/smp.h>
14 #include <linux/smp_lock.h>
15 #include <linux/kernel.h>
16 #include <linux/signal.h>
17 #include <linux/syscalls.h>
18 #include <linux/errno.h>
19 #include <linux/wait.h>
20 #include <linux/ptrace.h>
21 #include <linux/compat.h>
22 #include <linux/suspend.h>
23 #include <linux/compiler.h>
27 #include <linux/bitops.h>
28 #include <asm/cacheflush.h>
30 #include <asm/uaccess.h>
31 #include <asm/ucontext.h>
32 #include <asm/system.h>
36 #define SI_PAD_SIZE32 ((SI_MAX_SIZE/sizeof(int)) - 3)
38 typedef struct compat_siginfo {
44 int _pad[SI_PAD_SIZE32];
48 compat_pid_t _pid; /* sender's pid */
49 compat_uid_t _uid; /* sender's uid */
54 compat_pid_t _pid; /* which child */
55 compat_uid_t _uid; /* sender's uid */
56 int _status; /* exit code */
57 compat_clock_t _utime;
58 compat_clock_t _stime;
63 compat_pid_t _pid; /* which child */
64 compat_clock_t _utime;
65 int _status; /* exit code */
66 compat_clock_t _stime;
69 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
71 s32 _addr; /* faulting insn/memory ref. */
74 /* SIGPOLL, SIGXFSZ (To do ...) */
76 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
82 timer_t _tid; /* timer id */
83 int _overrun; /* overrun count */
84 compat_sigval_t _sigval;/* same as below */
85 int _sys_private; /* not to be passed to user */
88 /* POSIX.1b signals */
90 compat_pid_t _pid; /* sender's pid */
91 compat_uid_t _uid; /* sender's uid */
92 compat_sigval_t _sigval;
99 * Including <asm/unistd.h> would give use the 64-bit syscall numbers ...
101 #define __NR_O32_sigreturn 4119
102 #define __NR_O32_rt_sigreturn 4193
103 #define __NR_O32_restart_syscall 4253
107 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
109 extern int do_signal32(sigset_t *oldset, struct pt_regs *regs);
111 /* 32-bit compatibility types */
113 #define _NSIG_BPW32 32
114 #define _NSIG_WORDS32 (_NSIG / _NSIG_BPW32)
117 unsigned int sig[_NSIG_WORDS32];
120 typedef unsigned int __sighandler32_t;
121 typedef void (*vfptr_t)(void);
124 unsigned int sa_flags;
125 __sighandler32_t sa_handler;
126 compat_sigset_t sa_mask;
129 /* IRIX compatible stack_t */
130 typedef struct sigaltstack32 {
132 compat_size_t ss_size;
140 struct sigcontext32 uc_mcontext;
141 sigset_t32 uc_sigmask; /* mask last for extensibility */
144 extern void __put_sigset_unknown_nsig(void);
145 extern void __get_sigset_unknown_nsig(void);
147 static inline int put_sigset(const sigset_t *kbuf, compat_sigset_t *ubuf)
151 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(*ubuf)))
154 switch (_NSIG_WORDS) {
156 __put_sigset_unknown_nsig();
158 err |= __put_user (kbuf->sig[1] >> 32, &ubuf->sig[3]);
159 err |= __put_user (kbuf->sig[1] & 0xffffffff, &ubuf->sig[2]);
161 err |= __put_user (kbuf->sig[0] >> 32, &ubuf->sig[1]);
162 err |= __put_user (kbuf->sig[0] & 0xffffffff, &ubuf->sig[0]);
168 static inline int get_sigset(sigset_t *kbuf, const compat_sigset_t *ubuf)
171 unsigned long sig[4];
173 if (!access_ok(VERIFY_READ, ubuf, sizeof(*ubuf)))
176 switch (_NSIG_WORDS) {
178 __get_sigset_unknown_nsig();
180 err |= __get_user (sig[3], &ubuf->sig[3]);
181 err |= __get_user (sig[2], &ubuf->sig[2]);
182 kbuf->sig[1] = sig[2] | (sig[3] << 32);
184 err |= __get_user (sig[1], &ubuf->sig[1]);
185 err |= __get_user (sig[0], &ubuf->sig[0]);
186 kbuf->sig[0] = sig[0] | (sig[1] << 32);
193 * Atomically swap in the new signal mask, and wait for a signal.
196 save_static_function(sys32_sigsuspend);
197 __attribute_used__ noinline static int
198 _sys32_sigsuspend(nabi_no_regargs struct pt_regs regs)
200 compat_sigset_t *uset;
201 sigset_t newset, saveset;
203 uset = (compat_sigset_t *) regs.regs[4];
204 if (get_sigset(&newset, uset))
206 sigdelsetmask(&newset, ~_BLOCKABLE);
208 spin_lock_irq(¤t->sighand->siglock);
209 saveset = current->blocked;
210 current->blocked = newset;
212 spin_unlock_irq(¤t->sighand->siglock);
214 regs.regs[2] = EINTR;
217 current->state = TASK_INTERRUPTIBLE;
219 if (do_signal32(&saveset, ®s))
224 save_static_function(sys32_rt_sigsuspend);
225 __attribute_used__ noinline static int
226 _sys32_rt_sigsuspend(nabi_no_regargs struct pt_regs regs)
228 compat_sigset_t *uset;
229 sigset_t newset, saveset;
232 /* XXX Don't preclude handling different sized sigset_t's. */
233 sigsetsize = regs.regs[5];
234 if (sigsetsize != sizeof(compat_sigset_t))
237 uset = (compat_sigset_t *) regs.regs[4];
238 if (get_sigset(&newset, uset))
240 sigdelsetmask(&newset, ~_BLOCKABLE);
242 spin_lock_irq(¤t->sighand->siglock);
243 saveset = current->blocked;
244 current->blocked = newset;
246 spin_unlock_irq(¤t->sighand->siglock);
248 regs.regs[2] = EINTR;
251 current->state = TASK_INTERRUPTIBLE;
253 if (do_signal32(&saveset, ®s))
258 asmlinkage int sys32_sigaction(int sig, const struct sigaction32 *act,
259 struct sigaction32 *oact)
261 struct k_sigaction new_ka, old_ka;
269 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
271 err |= __get_user(handler, &act->sa_handler);
272 new_ka.sa.sa_handler = (void*)(s64)handler;
273 err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
274 err |= __get_user(mask, &act->sa_mask.sig[0]);
278 siginitset(&new_ka.sa.sa_mask, mask);
281 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
284 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
286 err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
287 err |= __put_user((u32)(u64)old_ka.sa.sa_handler,
289 err |= __put_user(old_ka.sa.sa_mask.sig[0], oact->sa_mask.sig);
290 err |= __put_user(0, &oact->sa_mask.sig[1]);
291 err |= __put_user(0, &oact->sa_mask.sig[2]);
292 err |= __put_user(0, &oact->sa_mask.sig[3]);
300 asmlinkage int sys32_sigaltstack(nabi_no_regargs struct pt_regs regs)
302 const stack32_t *uss = (const stack32_t *) regs.regs[4];
303 stack32_t *uoss = (stack32_t *) regs.regs[5];
304 unsigned long usp = regs.regs[29];
307 mm_segment_t old_fs = get_fs();
311 if (!access_ok(VERIFY_READ, uss, sizeof(*uss)))
313 err |= __get_user(sp, &uss->ss_sp);
314 kss.ss_sp = (void *) (long) sp;
315 err |= __get_user(kss.ss_size, &uss->ss_size);
316 err |= __get_user(kss.ss_flags, &uss->ss_flags);
322 ret = do_sigaltstack(uss ? &kss : NULL , uoss ? &koss : NULL, usp);
326 if (!access_ok(VERIFY_WRITE, uoss, sizeof(*uoss)))
328 sp = (int) (long) koss.ss_sp;
329 err |= __put_user(sp, &uoss->ss_sp);
330 err |= __put_user(koss.ss_size, &uoss->ss_size);
331 err |= __put_user(koss.ss_flags, &uoss->ss_flags);
338 static int restore_sigcontext32(struct pt_regs *regs, struct sigcontext32 *sc)
344 /* Always make any pending restarted system calls return -EINTR */
345 current_thread_info()->restart_block.fn = do_no_restart_syscall;
347 err |= __get_user(regs->cp0_epc, &sc->sc_pc);
348 err |= __get_user(regs->hi, &sc->sc_mdhi);
349 err |= __get_user(regs->lo, &sc->sc_mdlo);
351 err |= __get_user(treg, &sc->sc_hi1); mthi1(treg);
352 err |= __get_user(treg, &sc->sc_lo1); mtlo1(treg);
353 err |= __get_user(treg, &sc->sc_hi2); mthi2(treg);
354 err |= __get_user(treg, &sc->sc_lo2); mtlo2(treg);
355 err |= __get_user(treg, &sc->sc_hi3); mthi3(treg);
356 err |= __get_user(treg, &sc->sc_lo3); mtlo3(treg);
357 err |= __get_user(treg, &sc->sc_dsp); wrdsp(treg, DSP_MASK);
360 #define restore_gp_reg(i) do { \
361 err |= __get_user(regs->regs[i], &sc->sc_regs[i]); \
363 restore_gp_reg( 1); restore_gp_reg( 2); restore_gp_reg( 3);
364 restore_gp_reg( 4); restore_gp_reg( 5); restore_gp_reg( 6);
365 restore_gp_reg( 7); restore_gp_reg( 8); restore_gp_reg( 9);
366 restore_gp_reg(10); restore_gp_reg(11); restore_gp_reg(12);
367 restore_gp_reg(13); restore_gp_reg(14); restore_gp_reg(15);
368 restore_gp_reg(16); restore_gp_reg(17); restore_gp_reg(18);
369 restore_gp_reg(19); restore_gp_reg(20); restore_gp_reg(21);
370 restore_gp_reg(22); restore_gp_reg(23); restore_gp_reg(24);
371 restore_gp_reg(25); restore_gp_reg(26); restore_gp_reg(27);
372 restore_gp_reg(28); restore_gp_reg(29); restore_gp_reg(30);
374 #undef restore_gp_reg
376 err |= __get_user(used_math, &sc->sc_used_math);
377 conditional_used_math(used_math);
382 /* restore fpu context if we have used it before */
384 err |= restore_fp_context32(sc);
386 /* signal handler may have used FPU. Give it up. */
396 u32 sf_ass[4]; /* argument save space for o32 */
397 #if ICACHE_REFILLS_WORKAROUND_WAR
400 u32 sf_code[2]; /* signal trampoline */
402 struct sigcontext32 sf_sc;
404 #if ICACHE_REFILLS_WORKAROUND_WAR
405 u32 sf_code[8] ____cacheline_aligned; /* signal trampoline */
409 struct rt_sigframe32 {
410 u32 rs_ass[4]; /* argument save space for o32 */
411 #if ICACHE_REFILLS_WORKAROUND_WAR
414 u32 rs_code[2]; /* signal trampoline */
416 compat_siginfo_t rs_info;
417 struct ucontext32 rs_uc;
418 #if ICACHE_REFILLS_WORKAROUND_WAR
419 u32 rs_code[8] __attribute__((aligned(32))); /* signal trampoline */
423 int copy_siginfo_to_user32(compat_siginfo_t *to, siginfo_t *from)
427 if (!access_ok (VERIFY_WRITE, to, sizeof(compat_siginfo_t)))
430 /* If you change siginfo_t structure, please be sure
431 this code is fixed accordingly.
432 It should never copy any pad contained in the structure
433 to avoid security leaks, but must copy the generic
434 3 ints plus the relevant union member.
435 This routine must convert siginfo from 64bit to 32bit as well
437 err = __put_user(from->si_signo, &to->si_signo);
438 err |= __put_user(from->si_errno, &to->si_errno);
439 err |= __put_user((short)from->si_code, &to->si_code);
440 if (from->si_code < 0)
441 err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
443 switch (from->si_code >> 16) {
444 case __SI_TIMER >> 16:
445 err |= __put_user(from->si_tid, &to->si_tid);
446 err |= __put_user(from->si_overrun, &to->si_overrun);
447 err |= __put_user(from->si_int, &to->si_int);
449 case __SI_CHLD >> 16:
450 err |= __put_user(from->si_utime, &to->si_utime);
451 err |= __put_user(from->si_stime, &to->si_stime);
452 err |= __put_user(from->si_status, &to->si_status);
454 err |= __put_user(from->si_pid, &to->si_pid);
455 err |= __put_user(from->si_uid, &to->si_uid);
457 case __SI_FAULT >> 16:
458 err |= __put_user((long)from->si_addr, &to->si_addr);
460 case __SI_POLL >> 16:
461 err |= __put_user(from->si_band, &to->si_band);
462 err |= __put_user(from->si_fd, &to->si_fd);
464 case __SI_RT >> 16: /* This is not generated by the kernel as of now. */
465 case __SI_MESGQ >> 16:
466 err |= __put_user(from->si_pid, &to->si_pid);
467 err |= __put_user(from->si_uid, &to->si_uid);
468 err |= __put_user(from->si_int, &to->si_int);
475 save_static_function(sys32_sigreturn);
476 __attribute_used__ noinline static void
477 _sys32_sigreturn(nabi_no_regargs struct pt_regs regs)
479 struct sigframe *frame;
482 frame = (struct sigframe *) regs.regs[29];
483 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
485 if (__copy_from_user(&blocked, &frame->sf_mask, sizeof(blocked)))
488 sigdelsetmask(&blocked, ~_BLOCKABLE);
489 spin_lock_irq(¤t->sighand->siglock);
490 current->blocked = blocked;
492 spin_unlock_irq(¤t->sighand->siglock);
494 if (restore_sigcontext32(®s, &frame->sf_sc))
498 * Don't let your children do this ...
500 __asm__ __volatile__(
508 force_sig(SIGSEGV, current);
511 save_static_function(sys32_rt_sigreturn);
512 __attribute_used__ noinline static void
513 _sys32_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
515 struct rt_sigframe32 *frame;
521 frame = (struct rt_sigframe32 *) regs.regs[29];
522 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
524 if (__copy_from_user(&set, &frame->rs_uc.uc_sigmask, sizeof(set)))
527 sigdelsetmask(&set, ~_BLOCKABLE);
528 spin_lock_irq(¤t->sighand->siglock);
529 current->blocked = set;
531 spin_unlock_irq(¤t->sighand->siglock);
533 if (restore_sigcontext32(®s, &frame->rs_uc.uc_mcontext))
536 /* The ucontext contains a stack32_t, so we must convert! */
537 if (__get_user(sp, &frame->rs_uc.uc_stack.ss_sp))
539 st.ss_size = (long) sp;
540 if (__get_user(st.ss_size, &frame->rs_uc.uc_stack.ss_size))
542 if (__get_user(st.ss_flags, &frame->rs_uc.uc_stack.ss_flags))
545 /* It is more difficult to avoid calling this function than to
546 call it and ignore errors. */
549 do_sigaltstack(&st, NULL, regs.regs[29]);
553 * Don't let your children do this ...
555 __asm__ __volatile__(
563 force_sig(SIGSEGV, current);
566 static inline int setup_sigcontext32(struct pt_regs *regs,
567 struct sigcontext32 *sc)
571 err |= __put_user(regs->cp0_epc, &sc->sc_pc);
572 err |= __put_user(regs->cp0_status, &sc->sc_status);
574 #define save_gp_reg(i) { \
575 err |= __put_user(regs->regs[i], &sc->sc_regs[i]); \
577 __put_user(0, &sc->sc_regs[0]); save_gp_reg(1); save_gp_reg(2);
578 save_gp_reg(3); save_gp_reg(4); save_gp_reg(5); save_gp_reg(6);
579 save_gp_reg(7); save_gp_reg(8); save_gp_reg(9); save_gp_reg(10);
580 save_gp_reg(11); save_gp_reg(12); save_gp_reg(13); save_gp_reg(14);
581 save_gp_reg(15); save_gp_reg(16); save_gp_reg(17); save_gp_reg(18);
582 save_gp_reg(19); save_gp_reg(20); save_gp_reg(21); save_gp_reg(22);
583 save_gp_reg(23); save_gp_reg(24); save_gp_reg(25); save_gp_reg(26);
584 save_gp_reg(27); save_gp_reg(28); save_gp_reg(29); save_gp_reg(30);
588 err |= __put_user(regs->hi, &sc->sc_mdhi);
589 err |= __put_user(regs->lo, &sc->sc_mdlo);
591 err |= __put_user(rddsp(DSP_MASK), &sc->sc_dsp);
592 err |= __put_user(mfhi1(), &sc->sc_hi1);
593 err |= __put_user(mflo1(), &sc->sc_lo1);
594 err |= __put_user(mfhi2(), &sc->sc_hi2);
595 err |= __put_user(mflo2(), &sc->sc_lo2);
596 err |= __put_user(mfhi3(), &sc->sc_hi3);
597 err |= __put_user(mflo3(), &sc->sc_lo3);
600 err |= __put_user(!!used_math(), &sc->sc_used_math);
606 * Save FPU state to signal context. Signal handler will "inherit"
611 if (!is_fpu_owner()) {
615 err |= save_fp_context32(sc);
624 * Determine which stack to use..
626 static inline void *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
631 /* Default to using normal stack */
635 * FPU emulator may have it's own trampoline active just
636 * above the user stack, 16-bytes before the next lowest
637 * 16 byte boundary. Try to avoid trashing it.
641 /* This is the X/Open sanctioned signal stack switching. */
642 if ((ka->sa.sa_flags & SA_ONSTACK) && (sas_ss_flags (sp) == 0))
643 sp = current->sas_ss_sp + current->sas_ss_size;
645 return (void *)((sp - frame_size) & ALMASK);
648 int setup_frame_32(struct k_sigaction * ka, struct pt_regs *regs,
649 int signr, sigset_t *set)
651 struct sigframe *frame;
654 frame = get_sigframe(ka, regs, sizeof(*frame));
655 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
659 * Set up the return code ...
661 * li v0, __NR_O32_sigreturn
664 err |= __put_user(0x24020000 + __NR_O32_sigreturn, frame->sf_code + 0);
665 err |= __put_user(0x0000000c , frame->sf_code + 1);
666 flush_cache_sigtramp((unsigned long) frame->sf_code);
668 err |= setup_sigcontext32(regs, &frame->sf_sc);
669 err |= __copy_to_user(&frame->sf_mask, set, sizeof(*set));
674 * Arguments to signal handler:
677 * a1 = 0 (should be cause)
678 * a2 = pointer to struct sigcontext
680 * $25 and c0_epc point to the signal handler, $29 points to the
683 regs->regs[ 4] = signr;
685 regs->regs[ 6] = (unsigned long) &frame->sf_sc;
686 regs->regs[29] = (unsigned long) frame;
687 regs->regs[31] = (unsigned long) frame->sf_code;
688 regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler;
691 printk("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%p\n",
692 current->comm, current->pid,
693 frame, regs->cp0_epc, frame->sf_code);
698 force_sigsegv(signr, current);
702 int setup_rt_frame_32(struct k_sigaction * ka, struct pt_regs *regs,
703 int signr, sigset_t *set, siginfo_t *info)
705 struct rt_sigframe32 *frame;
709 frame = get_sigframe(ka, regs, sizeof(*frame));
710 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
713 /* Set up to return from userspace. If provided, use a stub already
716 * Set up the return code ...
718 * li v0, __NR_O32_rt_sigreturn
721 err |= __put_user(0x24020000 + __NR_O32_rt_sigreturn, frame->rs_code + 0);
722 err |= __put_user(0x0000000c , frame->rs_code + 1);
723 flush_cache_sigtramp((unsigned long) frame->rs_code);
725 /* Convert (siginfo_t -> compat_siginfo_t) and copy to user. */
726 err |= copy_siginfo_to_user32(&frame->rs_info, info);
728 /* Create the ucontext. */
729 err |= __put_user(0, &frame->rs_uc.uc_flags);
730 err |= __put_user(0, &frame->rs_uc.uc_link);
731 sp = (int) (long) current->sas_ss_sp;
732 err |= __put_user(sp,
733 &frame->rs_uc.uc_stack.ss_sp);
734 err |= __put_user(sas_ss_flags(regs->regs[29]),
735 &frame->rs_uc.uc_stack.ss_flags);
736 err |= __put_user(current->sas_ss_size,
737 &frame->rs_uc.uc_stack.ss_size);
738 err |= setup_sigcontext32(regs, &frame->rs_uc.uc_mcontext);
739 err |= __copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set));
745 * Arguments to signal handler:
748 * a1 = 0 (should be cause)
749 * a2 = pointer to ucontext
751 * $25 and c0_epc point to the signal handler, $29 points to
752 * the struct rt_sigframe32.
754 regs->regs[ 4] = signr;
755 regs->regs[ 5] = (unsigned long) &frame->rs_info;
756 regs->regs[ 6] = (unsigned long) &frame->rs_uc;
757 regs->regs[29] = (unsigned long) frame;
758 regs->regs[31] = (unsigned long) frame->rs_code;
759 regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler;
762 printk("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%p\n",
763 current->comm, current->pid,
764 frame, regs->cp0_epc, frame->rs_code);
769 force_sigsegv(signr, current);
773 static inline int handle_signal(unsigned long sig, siginfo_t *info,
774 struct k_sigaction *ka, sigset_t *oldset, struct pt_regs * regs)
778 switch (regs->regs[0]) {
779 case ERESTART_RESTARTBLOCK:
781 regs->regs[2] = EINTR;
784 if(!(ka->sa.sa_flags & SA_RESTART)) {
785 regs->regs[2] = EINTR;
789 case ERESTARTNOINTR: /* Userland will reload $v0. */
790 regs->regs[7] = regs->regs[26];
794 regs->regs[0] = 0; /* Don't deal with this again. */
796 if (ka->sa.sa_flags & SA_SIGINFO)
797 ret = current->thread.abi->setup_rt_frame(ka, regs, sig, oldset, info);
799 ret = current->thread.abi->setup_frame(ka, regs, sig, oldset);
801 spin_lock_irq(¤t->sighand->siglock);
802 sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask);
803 if (!(ka->sa.sa_flags & SA_NODEFER))
804 sigaddset(¤t->blocked,sig);
806 spin_unlock_irq(¤t->sighand->siglock);
811 int do_signal32(sigset_t *oldset, struct pt_regs *regs)
813 struct k_sigaction ka;
818 * We want the common case to go fast, which is why we may in certain
819 * cases get here from kernel mode. Just return without doing anything
822 if (!user_mode(regs))
829 oldset = ¤t->blocked;
831 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
833 return handle_signal(signr, &info, &ka, oldset, regs);
837 * Who's code doesn't conform to the restartable syscall convention
838 * dies here!!! The li instruction, a single machine instruction,
839 * must directly be followed by the syscall instruction.
842 if (regs->regs[2] == ERESTARTNOHAND ||
843 regs->regs[2] == ERESTARTSYS ||
844 regs->regs[2] == ERESTARTNOINTR) {
845 regs->regs[7] = regs->regs[26];
848 if (regs->regs[2] == ERESTART_RESTARTBLOCK) {
849 regs->regs[2] = __NR_O32_restart_syscall;
850 regs->regs[7] = regs->regs[26];
857 asmlinkage int sys32_rt_sigaction(int sig, const struct sigaction32 *act,
858 struct sigaction32 *oact,
859 unsigned int sigsetsize)
861 struct k_sigaction new_sa, old_sa;
864 /* XXX: Don't preclude handling different sized sigset_t's. */
865 if (sigsetsize != sizeof(sigset_t))
872 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
874 err |= __get_user(handler, &act->sa_handler);
875 new_sa.sa.sa_handler = (void*)(s64)handler;
876 err |= __get_user(new_sa.sa.sa_flags, &act->sa_flags);
877 err |= get_sigset(&new_sa.sa.sa_mask, &act->sa_mask);
882 ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa : NULL);
887 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
890 err |= __put_user((u32)(u64)old_sa.sa.sa_handler,
892 err |= __put_user(old_sa.sa.sa_flags, &oact->sa_flags);
893 err |= put_sigset(&old_sa.sa.sa_mask, &oact->sa_mask);
901 asmlinkage int sys32_rt_sigprocmask(int how, compat_sigset_t *set,
902 compat_sigset_t *oset, unsigned int sigsetsize)
904 sigset_t old_set, new_set;
906 mm_segment_t old_fs = get_fs();
908 if (set && get_sigset(&new_set, set))
912 ret = sys_rt_sigprocmask(how, set ? &new_set : NULL,
913 oset ? &old_set : NULL, sigsetsize);
916 if (!ret && oset && put_sigset(&old_set, oset))
922 asmlinkage int sys32_rt_sigpending(compat_sigset_t *uset,
923 unsigned int sigsetsize)
927 mm_segment_t old_fs = get_fs();
930 ret = sys_rt_sigpending(&set, sigsetsize);
933 if (!ret && put_sigset(&set, uset))
939 asmlinkage int sys32_rt_sigqueueinfo(int pid, int sig, compat_siginfo_t *uinfo)
943 mm_segment_t old_fs = get_fs();
945 if (copy_from_user (&info, uinfo, 3*sizeof(int)) ||
946 copy_from_user (info._sifields._pad, uinfo->_sifields._pad, SI_PAD_SIZE))
949 ret = sys_rt_sigqueueinfo(pid, sig, &info);
955 sys32_waitid(int which, compat_pid_t pid,
956 compat_siginfo_t __user *uinfo, int options,
957 struct compat_rusage __user *uru)
962 mm_segment_t old_fs = get_fs();
966 ret = sys_waitid(which, pid, (siginfo_t __user *) &info, options,
967 uru ? (struct rusage __user *) &ru : NULL);
970 if (ret < 0 || info.si_signo == 0)
973 if (uru && (ret = put_compat_rusage(&ru, uru)))
976 BUG_ON(info.si_code & __SI_MASK);
977 info.si_code |= __SI_CHLD;
978 return copy_siginfo_to_user32(uinfo, &info);