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 if (current_thread_info()->flags & TIF_SYSCALL_TRACE)
501 do_syscall_trace(®s, 1);
502 __asm__ __volatile__(
510 force_sig(SIGSEGV, current);
513 save_static_function(sys32_rt_sigreturn);
514 __attribute_used__ noinline static void
515 _sys32_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
517 struct rt_sigframe32 *frame;
523 frame = (struct rt_sigframe32 *) regs.regs[29];
524 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
526 if (__copy_from_user(&set, &frame->rs_uc.uc_sigmask, sizeof(set)))
529 sigdelsetmask(&set, ~_BLOCKABLE);
530 spin_lock_irq(¤t->sighand->siglock);
531 current->blocked = set;
533 spin_unlock_irq(¤t->sighand->siglock);
535 if (restore_sigcontext32(®s, &frame->rs_uc.uc_mcontext))
538 /* The ucontext contains a stack32_t, so we must convert! */
539 if (__get_user(sp, &frame->rs_uc.uc_stack.ss_sp))
541 st.ss_size = (long) sp;
542 if (__get_user(st.ss_size, &frame->rs_uc.uc_stack.ss_size))
544 if (__get_user(st.ss_flags, &frame->rs_uc.uc_stack.ss_flags))
547 /* It is more difficult to avoid calling this function than to
548 call it and ignore errors. */
551 do_sigaltstack(&st, NULL, regs.regs[29]);
555 * Don't let your children do this ...
557 __asm__ __volatile__(
565 force_sig(SIGSEGV, current);
568 static inline int setup_sigcontext32(struct pt_regs *regs,
569 struct sigcontext32 *sc)
573 err |= __put_user(regs->cp0_epc, &sc->sc_pc);
574 err |= __put_user(regs->cp0_status, &sc->sc_status);
576 #define save_gp_reg(i) { \
577 err |= __put_user(regs->regs[i], &sc->sc_regs[i]); \
579 __put_user(0, &sc->sc_regs[0]); save_gp_reg(1); save_gp_reg(2);
580 save_gp_reg(3); save_gp_reg(4); save_gp_reg(5); save_gp_reg(6);
581 save_gp_reg(7); save_gp_reg(8); save_gp_reg(9); save_gp_reg(10);
582 save_gp_reg(11); save_gp_reg(12); save_gp_reg(13); save_gp_reg(14);
583 save_gp_reg(15); save_gp_reg(16); save_gp_reg(17); save_gp_reg(18);
584 save_gp_reg(19); save_gp_reg(20); save_gp_reg(21); save_gp_reg(22);
585 save_gp_reg(23); save_gp_reg(24); save_gp_reg(25); save_gp_reg(26);
586 save_gp_reg(27); save_gp_reg(28); save_gp_reg(29); save_gp_reg(30);
590 err |= __put_user(regs->hi, &sc->sc_mdhi);
591 err |= __put_user(regs->lo, &sc->sc_mdlo);
593 err |= __put_user(rddsp(DSP_MASK), &sc->sc_hi1);
594 err |= __put_user(mfhi1(), &sc->sc_hi1);
595 err |= __put_user(mflo1(), &sc->sc_lo1);
596 err |= __put_user(mfhi2(), &sc->sc_hi2);
597 err |= __put_user(mflo2(), &sc->sc_lo2);
598 err |= __put_user(mfhi3(), &sc->sc_hi3);
599 err |= __put_user(mflo3(), &sc->sc_lo3);
602 err |= __put_user(!!used_math(), &sc->sc_used_math);
608 * Save FPU state to signal context. Signal handler will "inherit"
613 if (!is_fpu_owner()) {
617 err |= save_fp_context32(sc);
626 * Determine which stack to use..
628 static inline void *get_sigframe(struct k_sigaction *ka, 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 *)((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 *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 *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 *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*)(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 *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 ? &new_set : NULL,
915 oset ? &old_set : NULL, sigsetsize);
918 if (!ret && oset && put_sigset(&old_set, oset))
924 asmlinkage int sys32_rt_sigpending(compat_sigset_t *uset,
925 unsigned int sigsetsize)
929 mm_segment_t old_fs = get_fs();
932 ret = sys_rt_sigpending(&set, sigsetsize);
935 if (!ret && put_sigset(&set, uset))
941 asmlinkage int sys32_rt_sigqueueinfo(int pid, int sig, compat_siginfo_t *uinfo)
945 mm_segment_t old_fs = get_fs();
947 if (copy_from_user (&info, uinfo, 3*sizeof(int)) ||
948 copy_from_user (info._sifields._pad, uinfo->_sifields._pad, SI_PAD_SIZE))
951 ret = sys_rt_sigqueueinfo(pid, sig, &info);
957 sys32_waitid(int which, compat_pid_t pid,
958 compat_siginfo_t __user *uinfo, int options,
959 struct compat_rusage __user *uru)
964 mm_segment_t old_fs = get_fs();
968 ret = sys_waitid(which, pid, (siginfo_t __user *) &info, options,
969 uru ? (struct rusage __user *) &ru : NULL);
972 if (ret < 0 || info.si_signo == 0)
975 if (uru && (ret = put_compat_rusage(&ru, uru)))
978 BUG_ON(info.si_code & __SI_MASK);
979 info.si_code |= __SI_CHLD;
980 return copy_siginfo_to_user32(uinfo, &info);