12 #include <linux/sched.h>
15 #include <linux/kernel.h>
16 #include <linux/signal.h>
18 #include <linux/errno.h>
19 #include <linux/wait.h>
20 #include <linux/ptrace.h>
22 #include <linux/compiler.h>
28 #include <linux/bitops.h>
29 #include <asm/cacheflush.h>
31 #include <asm/ucontext.h>
51 #define __NR_O32_restart_syscall 4253
96 static int protected_save_fp_context32(
struct sigcontext32 __user *
sc)
102 err = save_fp_context32(sc);
116 static int protected_restore_fp_context32(
struct sigcontext32 __user *sc)
122 err = restore_fp_context32(sc);
136 static int setup_sigcontext32(
struct pt_regs *
regs,
146 for (i = 1; i < 32; i++)
162 err |=
__put_user(used_math, &sc->sc_used_math);
169 err |= protected_save_fp_context32(sc);
175 check_and_restore_fp_context32(
struct sigcontext32 __user *sc)
182 err |= protected_restore_fp_context32(sc);
186 static int restore_sigcontext32(
struct pt_regs *regs,
210 for (i = 1; i < 32; i++)
213 err |=
__get_user(used_math, &sc->sc_used_math);
219 err = check_and_restore_fp_context32(sc);
234 static inline int put_sigset(
const sigset_t *kbuf, compat_sigset_t __user *ubuf)
255 static inline int get_sigset(
sigset_t *kbuf,
const compat_sigset_t __user *ubuf)
258 unsigned long sig[4];
269 kbuf->
sig[1] = sig[2] | (sig[3] << 32);
273 kbuf->
sig[0] = sig[0] | (sig[1] << 32);
285 compat_sigset_t
__user *uset;
288 uset = (compat_sigset_t
__user *) regs.regs[4];
289 if (get_sigset(&newset, uset))
296 compat_sigset_t
__user *uset;
301 sigsetsize = regs.regs[5];
302 if (sigsetsize !=
sizeof(compat_sigset_t))
305 uset = (compat_sigset_t
__user *) regs.regs[4];
306 if (get_sigset(&newset, uset))
325 new_ka.
sa.sa_handler = (
void __user *)(
s64)handler;
327 err |=
__get_user(mask, &act->sa_mask.sig[0]);
331 siginitset(&new_ka.
sa.sa_mask, mask);
342 err |=
__put_user(old_ka.
sa.sa_mask.sig[0], oact->sa_mask.sig);
357 unsigned long usp = regs.regs[29];
382 sp = (
int) (
unsigned long) koss.
ss_sp;
415 err |=
__put_user(from->si_overrun, &to->si_overrun);
419 err |=
__put_user(from->si_utime, &to->si_utime);
420 err |=
__put_user(from->si_stime, &to->si_stime);
421 err |=
__put_user(from->si_status, &to->si_status);
427 err |=
__put_user((
unsigned long)from->si_addr, &to->si_addr);
430 err |=
__put_user(from->si_band, &to->si_band);
446 memset(to, 0,
sizeof *to);
462 frame = (
struct sigframe32 __user *) regs.regs[29];
465 if (__copy_conv_sigset_from_user(&blocked, &frame->
sf_mask))
470 sig = restore_sigcontext32(®s, &frame->
sf_sc);
502 if (__copy_conv_sigset_from_user(&
set, &frame->
rs_uc.uc_sigmask))
507 sig = restore_sigcontext32(®s, &frame->
rs_uc.uc_mcontext);
516 st.
ss_sp = (
void __user *)(
long)
sp;
543 static int setup_frame_32(
void *sig_return,
struct k_sigaction *ka,
553 err |= setup_sigcontext32(regs, &frame->
sf_sc);
554 err |= __copy_conv_sigset_to_user(&frame->
sf_mask,
set);
569 regs->
regs[ 4] = signr;
573 regs->
regs[31] = (
unsigned long) sig_return;
576 DEBUGP(
"SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n",
587 static int setup_rt_frame_32(
void *sig_return,
struct k_sigaction *ka,
607 &frame->
rs_uc.uc_stack.ss_sp);
609 &frame->
rs_uc.uc_stack.ss_flags);
611 &frame->
rs_uc.uc_stack.ss_size);
612 err |= setup_sigcontext32(regs, &frame->
rs_uc.uc_mcontext);
613 err |= __copy_conv_sigset_to_user(&frame->
rs_uc.uc_sigmask,
set);
628 regs->
regs[ 4] = signr;
630 regs->
regs[ 6] = (
unsigned long) &frame->
rs_uc;
631 regs->
regs[29] = (
unsigned long) frame;
632 regs->
regs[31] = (
unsigned long) sig_return;
635 DEBUGP(
"SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n",
650 .setup_frame = setup_frame_32,
651 .signal_return_offset =
653 .setup_rt_frame = setup_rt_frame_32,
654 .rt_signal_return_offset =
661 struct sigaction32 __user *, oact,
unsigned int, sigsetsize)
677 new_sa.
sa.sa_handler = (
void __user *)(
s64)handler;
679 err |= get_sigset(&new_sa.
sa.sa_mask, &act->sa_mask);
695 err |= put_sigset(&old_sa.
sa.sa_mask, &oact->sa_mask);
704 compat_sigset_t __user *, oset,
unsigned int, sigsetsize)
710 if (
set && get_sigset(&new_set,
set))
715 oset ? (
sigset_t __user *)&old_set : NULL,
719 if (!ret && oset && put_sigset(&old_set, oset))
726 unsigned int, sigsetsize)
736 if (!ret && put_sigset(&
set, uset))
760 struct compat_rusage __user *, uru)
784 static int signal32_init(
void)