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 __user *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 __user *)(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 __user *uss = (const stack32_t __user *) regs.regs[4];
303 stack32_t __user *uoss = (stack32_t __user *) 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 ? (stack_t __user *)&kss : NULL,
323 uoss ? (stack_t __user *)&koss : NULL, usp);
327 if (!access_ok(VERIFY_WRITE, uoss, sizeof(*uoss)))
329 sp = (int) (long) koss.ss_sp;
330 err |= __put_user(sp, &uoss->ss_sp);
331 err |= __put_user(koss.ss_size, &uoss->ss_size);
332 err |= __put_user(koss.ss_flags, &uoss->ss_flags);
339 static int restore_sigcontext32(struct pt_regs *regs, struct sigcontext32 __user *sc)
345 /* Always make any pending restarted system calls return -EINTR */
346 current_thread_info()->restart_block.fn = do_no_restart_syscall;
348 err |= __get_user(regs->cp0_epc, &sc->sc_pc);
349 err |= __get_user(regs->hi, &sc->sc_mdhi);
350 err |= __get_user(regs->lo, &sc->sc_mdlo);
352 err |= __get_user(treg, &sc->sc_hi1); mthi1(treg);
353 err |= __get_user(treg, &sc->sc_lo1); mtlo1(treg);
354 err |= __get_user(treg, &sc->sc_hi2); mthi2(treg);
355 err |= __get_user(treg, &sc->sc_lo2); mtlo2(treg);
356 err |= __get_user(treg, &sc->sc_hi3); mthi3(treg);
357 err |= __get_user(treg, &sc->sc_lo3); mtlo3(treg);
358 err |= __get_user(treg, &sc->sc_dsp); wrdsp(treg, DSP_MASK);
361 #define restore_gp_reg(i) do { \
362 err |= __get_user(regs->regs[i], &sc->sc_regs[i]); \
364 restore_gp_reg( 1); restore_gp_reg( 2); restore_gp_reg( 3);
365 restore_gp_reg( 4); restore_gp_reg( 5); restore_gp_reg( 6);
366 restore_gp_reg( 7); restore_gp_reg( 8); restore_gp_reg( 9);
367 restore_gp_reg(10); restore_gp_reg(11); restore_gp_reg(12);
368 restore_gp_reg(13); restore_gp_reg(14); restore_gp_reg(15);
369 restore_gp_reg(16); restore_gp_reg(17); restore_gp_reg(18);
370 restore_gp_reg(19); restore_gp_reg(20); restore_gp_reg(21);
371 restore_gp_reg(22); restore_gp_reg(23); restore_gp_reg(24);
372 restore_gp_reg(25); restore_gp_reg(26); restore_gp_reg(27);
373 restore_gp_reg(28); restore_gp_reg(29); restore_gp_reg(30);
375 #undef restore_gp_reg
377 err |= __get_user(used_math, &sc->sc_used_math);
378 conditional_used_math(used_math);
383 /* restore fpu context if we have used it before */
385 err |= restore_fp_context32(sc);
387 /* signal handler may have used FPU. Give it up. */
397 u32 sf_ass[4]; /* argument save space for o32 */
398 #if ICACHE_REFILLS_WORKAROUND_WAR
401 u32 sf_code[2]; /* signal trampoline */
403 struct sigcontext32 sf_sc;
405 #if ICACHE_REFILLS_WORKAROUND_WAR
406 u32 sf_code[8] ____cacheline_aligned; /* signal trampoline */
410 struct rt_sigframe32 {
411 u32 rs_ass[4]; /* argument save space for o32 */
412 #if ICACHE_REFILLS_WORKAROUND_WAR
415 u32 rs_code[2]; /* signal trampoline */
417 compat_siginfo_t rs_info;
418 struct ucontext32 rs_uc;
419 #if ICACHE_REFILLS_WORKAROUND_WAR
420 u32 rs_code[8] __attribute__((aligned(32))); /* signal trampoline */
424 int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from)
428 if (!access_ok (VERIFY_WRITE, to, sizeof(compat_siginfo_t)))
431 /* If you change siginfo_t structure, please be sure
432 this code is fixed accordingly.
433 It should never copy any pad contained in the structure
434 to avoid security leaks, but must copy the generic
435 3 ints plus the relevant union member.
436 This routine must convert siginfo from 64bit to 32bit as well
438 err = __put_user(from->si_signo, &to->si_signo);
439 err |= __put_user(from->si_errno, &to->si_errno);
440 err |= __put_user((short)from->si_code, &to->si_code);
441 if (from->si_code < 0)
442 err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
444 switch (from->si_code >> 16) {
445 case __SI_TIMER >> 16:
446 err |= __put_user(from->si_tid, &to->si_tid);
447 err |= __put_user(from->si_overrun, &to->si_overrun);
448 err |= __put_user(from->si_int, &to->si_int);
450 case __SI_CHLD >> 16:
451 err |= __put_user(from->si_utime, &to->si_utime);
452 err |= __put_user(from->si_stime, &to->si_stime);
453 err |= __put_user(from->si_status, &to->si_status);
455 err |= __put_user(from->si_pid, &to->si_pid);
456 err |= __put_user(from->si_uid, &to->si_uid);
458 case __SI_FAULT >> 16:
459 err |= __put_user((unsigned long)from->si_addr, &to->si_addr);
461 case __SI_POLL >> 16:
462 err |= __put_user(from->si_band, &to->si_band);
463 err |= __put_user(from->si_fd, &to->si_fd);
465 case __SI_RT >> 16: /* This is not generated by the kernel as of now. */
466 case __SI_MESGQ >> 16:
467 err |= __put_user(from->si_pid, &to->si_pid);
468 err |= __put_user(from->si_uid, &to->si_uid);
469 err |= __put_user(from->si_int, &to->si_int);
476 save_static_function(sys32_sigreturn);
477 __attribute_used__ noinline static void
478 _sys32_sigreturn(nabi_no_regargs struct pt_regs regs)
480 struct sigframe __user *frame;
483 frame = (struct sigframe __user *) regs.regs[29];
484 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
486 if (__copy_from_user(&blocked, &frame->sf_mask, sizeof(blocked)))
489 sigdelsetmask(&blocked, ~_BLOCKABLE);
490 spin_lock_irq(¤t->sighand->siglock);
491 current->blocked = blocked;
493 spin_unlock_irq(¤t->sighand->siglock);
495 if (restore_sigcontext32(®s, &frame->sf_sc))
499 * Don't let your children do this ...
501 __asm__ __volatile__(
509 force_sig(SIGSEGV, current);
512 save_static_function(sys32_rt_sigreturn);
513 __attribute_used__ noinline static void
514 _sys32_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
516 struct rt_sigframe32 __user *frame;
522 frame = (struct rt_sigframe32 __user *) regs.regs[29];
523 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
525 if (__copy_from_user(&set, &frame->rs_uc.uc_sigmask, sizeof(set)))
528 sigdelsetmask(&set, ~_BLOCKABLE);
529 spin_lock_irq(¤t->sighand->siglock);
530 current->blocked = set;
532 spin_unlock_irq(¤t->sighand->siglock);
534 if (restore_sigcontext32(®s, &frame->rs_uc.uc_mcontext))
537 /* The ucontext contains a stack32_t, so we must convert! */
538 if (__get_user(sp, &frame->rs_uc.uc_stack.ss_sp))
540 st.ss_size = (long) sp;
541 if (__get_user(st.ss_size, &frame->rs_uc.uc_stack.ss_size))
543 if (__get_user(st.ss_flags, &frame->rs_uc.uc_stack.ss_flags))
546 /* It is more difficult to avoid calling this function than to
547 call it and ignore errors. */
550 do_sigaltstack((stack_t __user *)&st, NULL, regs.regs[29]);
554 * Don't let your children do this ...
556 __asm__ __volatile__(
564 force_sig(SIGSEGV, current);
567 static inline int setup_sigcontext32(struct pt_regs *regs,
568 struct sigcontext32 __user *sc)
572 err |= __put_user(regs->cp0_epc, &sc->sc_pc);
573 err |= __put_user(regs->cp0_status, &sc->sc_status);
575 #define save_gp_reg(i) { \
576 err |= __put_user(regs->regs[i], &sc->sc_regs[i]); \
578 __put_user(0, &sc->sc_regs[0]); save_gp_reg(1); save_gp_reg(2);
579 save_gp_reg(3); save_gp_reg(4); save_gp_reg(5); save_gp_reg(6);
580 save_gp_reg(7); save_gp_reg(8); save_gp_reg(9); save_gp_reg(10);
581 save_gp_reg(11); save_gp_reg(12); save_gp_reg(13); save_gp_reg(14);
582 save_gp_reg(15); save_gp_reg(16); save_gp_reg(17); save_gp_reg(18);
583 save_gp_reg(19); save_gp_reg(20); save_gp_reg(21); save_gp_reg(22);
584 save_gp_reg(23); save_gp_reg(24); save_gp_reg(25); save_gp_reg(26);
585 save_gp_reg(27); save_gp_reg(28); save_gp_reg(29); save_gp_reg(30);
589 err |= __put_user(regs->hi, &sc->sc_mdhi);
590 err |= __put_user(regs->lo, &sc->sc_mdlo);
592 err |= __put_user(rddsp(DSP_MASK), &sc->sc_dsp);
593 err |= __put_user(mfhi1(), &sc->sc_hi1);
594 err |= __put_user(mflo1(), &sc->sc_lo1);
595 err |= __put_user(mfhi2(), &sc->sc_hi2);
596 err |= __put_user(mflo2(), &sc->sc_lo2);
597 err |= __put_user(mfhi3(), &sc->sc_hi3);
598 err |= __put_user(mflo3(), &sc->sc_lo3);
601 err |= __put_user(!!used_math(), &sc->sc_used_math);
607 * Save FPU state to signal context. Signal handler will "inherit"
612 if (!is_fpu_owner()) {
616 err |= save_fp_context32(sc);
625 * Determine which stack to use..
627 static inline void __user *get_sigframe(struct k_sigaction *ka,
628 struct pt_regs *regs,
633 /* Default to using normal stack */
637 * FPU emulator may have it's own trampoline active just
638 * above the user stack, 16-bytes before the next lowest
639 * 16 byte boundary. Try to avoid trashing it.
643 /* This is the X/Open sanctioned signal stack switching. */
644 if ((ka->sa.sa_flags & SA_ONSTACK) && (sas_ss_flags (sp) == 0))
645 sp = current->sas_ss_sp + current->sas_ss_size;
647 return (void __user *)((sp - frame_size) & ALMASK);
650 int setup_frame_32(struct k_sigaction * ka, struct pt_regs *regs,
651 int signr, sigset_t *set)
653 struct sigframe __user *frame;
656 frame = get_sigframe(ka, regs, sizeof(*frame));
657 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
661 * Set up the return code ...
663 * li v0, __NR_O32_sigreturn
666 err |= __put_user(0x24020000 + __NR_O32_sigreturn, frame->sf_code + 0);
667 err |= __put_user(0x0000000c , frame->sf_code + 1);
668 flush_cache_sigtramp((unsigned long) frame->sf_code);
670 err |= setup_sigcontext32(regs, &frame->sf_sc);
671 err |= __copy_to_user(&frame->sf_mask, set, sizeof(*set));
676 * Arguments to signal handler:
679 * a1 = 0 (should be cause)
680 * a2 = pointer to struct sigcontext
682 * $25 and c0_epc point to the signal handler, $29 points to the
685 regs->regs[ 4] = signr;
687 regs->regs[ 6] = (unsigned long) &frame->sf_sc;
688 regs->regs[29] = (unsigned long) frame;
689 regs->regs[31] = (unsigned long) frame->sf_code;
690 regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler;
693 printk("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%p\n",
694 current->comm, current->pid,
695 frame, regs->cp0_epc, frame->sf_code);
700 force_sigsegv(signr, current);
704 int setup_rt_frame_32(struct k_sigaction * ka, struct pt_regs *regs,
705 int signr, sigset_t *set, siginfo_t *info)
707 struct rt_sigframe32 __user *frame;
711 frame = get_sigframe(ka, regs, sizeof(*frame));
712 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
715 /* Set up to return from userspace. If provided, use a stub already
718 * Set up the return code ...
720 * li v0, __NR_O32_rt_sigreturn
723 err |= __put_user(0x24020000 + __NR_O32_rt_sigreturn, frame->rs_code + 0);
724 err |= __put_user(0x0000000c , frame->rs_code + 1);
725 flush_cache_sigtramp((unsigned long) frame->rs_code);
727 /* Convert (siginfo_t -> compat_siginfo_t) and copy to user. */
728 err |= copy_siginfo_to_user32(&frame->rs_info, info);
730 /* Create the ucontext. */
731 err |= __put_user(0, &frame->rs_uc.uc_flags);
732 err |= __put_user(0, &frame->rs_uc.uc_link);
733 sp = (int) (long) current->sas_ss_sp;
734 err |= __put_user(sp,
735 &frame->rs_uc.uc_stack.ss_sp);
736 err |= __put_user(sas_ss_flags(regs->regs[29]),
737 &frame->rs_uc.uc_stack.ss_flags);
738 err |= __put_user(current->sas_ss_size,
739 &frame->rs_uc.uc_stack.ss_size);
740 err |= setup_sigcontext32(regs, &frame->rs_uc.uc_mcontext);
741 err |= __copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set));
747 * Arguments to signal handler:
750 * a1 = 0 (should be cause)
751 * a2 = pointer to ucontext
753 * $25 and c0_epc point to the signal handler, $29 points to
754 * the struct rt_sigframe32.
756 regs->regs[ 4] = signr;
757 regs->regs[ 5] = (unsigned long) &frame->rs_info;
758 regs->regs[ 6] = (unsigned long) &frame->rs_uc;
759 regs->regs[29] = (unsigned long) frame;
760 regs->regs[31] = (unsigned long) frame->rs_code;
761 regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler;
764 printk("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%p\n",
765 current->comm, current->pid,
766 frame, regs->cp0_epc, frame->rs_code);
771 force_sigsegv(signr, current);
775 static inline int handle_signal(unsigned long sig, siginfo_t *info,
776 struct k_sigaction *ka, sigset_t *oldset, struct pt_regs * regs)
780 switch (regs->regs[0]) {
781 case ERESTART_RESTARTBLOCK:
783 regs->regs[2] = EINTR;
786 if(!(ka->sa.sa_flags & SA_RESTART)) {
787 regs->regs[2] = EINTR;
791 case ERESTARTNOINTR: /* Userland will reload $v0. */
792 regs->regs[7] = regs->regs[26];
796 regs->regs[0] = 0; /* Don't deal with this again. */
798 if (ka->sa.sa_flags & SA_SIGINFO)
799 ret = current->thread.abi->setup_rt_frame(ka, regs, sig, oldset, info);
801 ret = current->thread.abi->setup_frame(ka, regs, sig, oldset);
803 spin_lock_irq(¤t->sighand->siglock);
804 sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask);
805 if (!(ka->sa.sa_flags & SA_NODEFER))
806 sigaddset(¤t->blocked,sig);
808 spin_unlock_irq(¤t->sighand->siglock);
813 int do_signal32(sigset_t *oldset, struct pt_regs *regs)
815 struct k_sigaction ka;
820 * We want the common case to go fast, which is why we may in certain
821 * cases get here from kernel mode. Just return without doing anything
824 if (!user_mode(regs))
831 oldset = ¤t->blocked;
833 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
835 return handle_signal(signr, &info, &ka, oldset, regs);
839 * Who's code doesn't conform to the restartable syscall convention
840 * dies here!!! The li instruction, a single machine instruction,
841 * must directly be followed by the syscall instruction.
844 if (regs->regs[2] == ERESTARTNOHAND ||
845 regs->regs[2] == ERESTARTSYS ||
846 regs->regs[2] == ERESTARTNOINTR) {
847 regs->regs[7] = regs->regs[26];
850 if (regs->regs[2] == ERESTART_RESTARTBLOCK) {
851 regs->regs[2] = __NR_O32_restart_syscall;
852 regs->regs[7] = regs->regs[26];
859 asmlinkage int sys32_rt_sigaction(int sig, const struct sigaction32 *act,
860 struct sigaction32 __user *oact,
861 unsigned int sigsetsize)
863 struct k_sigaction new_sa, old_sa;
866 /* XXX: Don't preclude handling different sized sigset_t's. */
867 if (sigsetsize != sizeof(sigset_t))
874 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
876 err |= __get_user(handler, &act->sa_handler);
877 new_sa.sa.sa_handler = (void __user *)(s64)handler;
878 err |= __get_user(new_sa.sa.sa_flags, &act->sa_flags);
879 err |= get_sigset(&new_sa.sa.sa_mask, &act->sa_mask);
884 ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa : NULL);
889 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
892 err |= __put_user((u32)(u64)old_sa.sa.sa_handler,
894 err |= __put_user(old_sa.sa.sa_flags, &oact->sa_flags);
895 err |= put_sigset(&old_sa.sa.sa_mask, &oact->sa_mask);
903 asmlinkage int sys32_rt_sigprocmask(int how, compat_sigset_t *set,
904 compat_sigset_t __user *oset, unsigned int sigsetsize)
906 sigset_t old_set, new_set;
908 mm_segment_t old_fs = get_fs();
910 if (set && get_sigset(&new_set, set))
914 ret = sys_rt_sigprocmask(how, set ? (sigset_t __user *)&new_set : NULL,
915 oset ? (sigset_t __user *)&old_set : NULL,
919 if (!ret && oset && put_sigset(&old_set, oset))
925 asmlinkage int sys32_rt_sigpending(compat_sigset_t __user *uset,
926 unsigned int sigsetsize)
930 mm_segment_t old_fs = get_fs();
933 ret = sys_rt_sigpending((sigset_t __user *)&set, sigsetsize);
936 if (!ret && put_sigset(&set, uset))
942 asmlinkage int sys32_rt_sigqueueinfo(int pid, int sig, compat_siginfo_t __user *uinfo)
946 mm_segment_t old_fs = get_fs();
948 if (copy_from_user (&info, uinfo, 3*sizeof(int)) ||
949 copy_from_user (info._sifields._pad, uinfo->_sifields._pad, SI_PAD_SIZE))
952 ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
958 sys32_waitid(int which, compat_pid_t pid,
959 compat_siginfo_t __user *uinfo, int options,
960 struct compat_rusage __user *uru)
965 mm_segment_t old_fs = get_fs();
969 ret = sys_waitid(which, pid, (siginfo_t __user *) &info, options,
970 uru ? (struct rusage __user *) &ru : NULL);
973 if (ret < 0 || info.si_signo == 0)
976 if (uru && (ret = put_compat_rusage(&ru, uru)))
979 BUG_ON(info.si_code & __SI_MASK);
980 info.si_code |= __SI_CHLD;
981 return copy_siginfo_to_user32(uinfo, &info);