2 * Copyright (C) 1991, 1992 Linus Torvalds
3 * Copyright (C) 2000, 2001, 2002 Andi Kleen SuSE Labs
5 * 1997-11-28 Modified for POSIX.1b signals by Richard Henderson
6 * 2000-06-20 Pentium III FXSR, SSE support by Gareth Hughes
7 * 2000-2002 x86-64 support by Andi Kleen
10 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
12 #include <linux/sched.h>
14 #include <linux/smp.h>
15 #include <linux/kernel.h>
16 #include <linux/errno.h>
17 #include <linux/wait.h>
18 #include <linux/tracehook.h>
19 #include <linux/unistd.h>
20 #include <linux/stddef.h>
21 #include <linux/personality.h>
22 #include <linux/uaccess.h>
23 #include <linux/user-return-notifier.h>
24 #include <linux/uprobes.h>
26 #include <asm/processor.h>
27 #include <asm/ucontext.h>
29 #include <asm/fpu-internal.h>
32 #include <asm/sighandling.h>
35 #include <asm/proto.h>
36 #include <asm/ia32_unistd.h>
37 #include <asm/sys_ia32.h>
38 #endif /* CONFIG_X86_64 */
40 #include <asm/syscall.h>
41 #include <asm/syscalls.h>
43 #include <asm/sigframe.h>
46 # define FIX_EFLAGS (__FIX_EFLAGS | X86_EFLAGS_RF)
48 # define FIX_EFLAGS __FIX_EFLAGS
51 #define COPY(x) do { \
52 get_user_ex(regs->x, &sc->x); \
55 #define GET_SEG(seg) ({ \
57 get_user_ex(tmp, &sc->seg); \
61 #define COPY_SEG(seg) do { \
62 regs->seg = GET_SEG(seg); \
65 #define COPY_SEG_CPL3(seg) do { \
66 regs->seg = GET_SEG(seg) | 3; \
69 int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc,
73 unsigned int tmpflags;
76 /* Always make any pending restarted system calls return -EINTR */
77 current_thread_info()->restart_block.fn = do_no_restart_syscall;
82 set_user_gs(regs, GET_SEG(gs));
86 #endif /* CONFIG_X86_32 */
88 COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx);
89 COPY(dx); COPY(cx); COPY(ip);
100 #endif /* CONFIG_X86_64 */
105 #else /* !CONFIG_X86_32 */
106 /* Kernel saves and restores only the CS segment register on signals,
107 * which is the bare minimum needed to allow mixed 32/64-bit code.
108 * App's signal handler can save/restore other segments if needed. */
110 #endif /* CONFIG_X86_32 */
112 get_user_ex(tmpflags, &sc->flags);
113 regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
114 regs->orig_ax = -1; /* disable syscall checks */
116 get_user_ex(buf, &sc->fpstate);
117 err |= restore_i387_xstate(buf);
119 get_user_ex(*pax, &sc->ax);
120 } get_user_catch(err);
125 int setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
126 struct pt_regs *regs, unsigned long mask)
133 put_user_ex(get_user_gs(regs), (unsigned int __user *)&sc->gs);
134 put_user_ex(regs->fs, (unsigned int __user *)&sc->fs);
135 put_user_ex(regs->es, (unsigned int __user *)&sc->es);
136 put_user_ex(regs->ds, (unsigned int __user *)&sc->ds);
137 #endif /* CONFIG_X86_32 */
139 put_user_ex(regs->di, &sc->di);
140 put_user_ex(regs->si, &sc->si);
141 put_user_ex(regs->bp, &sc->bp);
142 put_user_ex(regs->sp, &sc->sp);
143 put_user_ex(regs->bx, &sc->bx);
144 put_user_ex(regs->dx, &sc->dx);
145 put_user_ex(regs->cx, &sc->cx);
146 put_user_ex(regs->ax, &sc->ax);
148 put_user_ex(regs->r8, &sc->r8);
149 put_user_ex(regs->r9, &sc->r9);
150 put_user_ex(regs->r10, &sc->r10);
151 put_user_ex(regs->r11, &sc->r11);
152 put_user_ex(regs->r12, &sc->r12);
153 put_user_ex(regs->r13, &sc->r13);
154 put_user_ex(regs->r14, &sc->r14);
155 put_user_ex(regs->r15, &sc->r15);
156 #endif /* CONFIG_X86_64 */
158 put_user_ex(current->thread.trap_nr, &sc->trapno);
159 put_user_ex(current->thread.error_code, &sc->err);
160 put_user_ex(regs->ip, &sc->ip);
162 put_user_ex(regs->cs, (unsigned int __user *)&sc->cs);
163 put_user_ex(regs->flags, &sc->flags);
164 put_user_ex(regs->sp, &sc->sp_at_signal);
165 put_user_ex(regs->ss, (unsigned int __user *)&sc->ss);
166 #else /* !CONFIG_X86_32 */
167 put_user_ex(regs->flags, &sc->flags);
168 put_user_ex(regs->cs, &sc->cs);
169 put_user_ex(0, &sc->gs);
170 put_user_ex(0, &sc->fs);
171 #endif /* CONFIG_X86_32 */
173 put_user_ex(fpstate, &sc->fpstate);
175 /* non-iBCS2 extensions.. */
176 put_user_ex(mask, &sc->oldmask);
177 put_user_ex(current->thread.cr2, &sc->cr2);
178 } put_user_catch(err);
184 * Set up a signal frame.
188 * Determine which stack to use..
190 static unsigned long align_sigframe(unsigned long sp)
194 * Align the stack pointer according to the i386 ABI,
195 * i.e. so that on function entry ((sp + 4) & 15) == 0.
197 sp = ((sp + 4) & -16ul) - 4;
198 #else /* !CONFIG_X86_32 */
199 sp = round_down(sp, 16) - 8;
204 static inline void __user *
205 get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size,
206 void __user **fpstate)
208 /* Default to using normal stack */
209 unsigned long sp = regs->sp;
210 int onsigstack = on_sig_stack(sp);
215 #endif /* CONFIG_X86_64 */
218 /* This is the X/Open sanctioned signal stack switching. */
219 if (ka->sa.sa_flags & SA_ONSTACK) {
220 if (current->sas_ss_size)
221 sp = current->sas_ss_sp + current->sas_ss_size;
224 /* This is the legacy signal stack switching. */
225 if ((regs->ss & 0xffff) != __USER_DS &&
226 !(ka->sa.sa_flags & SA_RESTORER) &&
228 sp = (unsigned long) ka->sa.sa_restorer;
229 #endif /* CONFIG_X86_32 */
234 sp -= sig_xstate_size;
236 sp = round_down(sp, 64);
237 #endif /* CONFIG_X86_64 */
238 *fpstate = (void __user *)sp;
241 sp = align_sigframe(sp - frame_size);
244 * If we are on the alternate signal stack and would overflow it, don't.
245 * Return an always-bogus address instead so we will die with SIGSEGV.
247 if (onsigstack && !likely(on_sig_stack(sp)))
248 return (void __user *)-1L;
250 /* save i387 state */
251 if (used_math() && save_i387_xstate(*fpstate) < 0)
252 return (void __user *)-1L;
254 return (void __user *)sp;
258 static const struct {
262 } __attribute__((packed)) retcode = {
263 0xb858, /* popl %eax; movl $..., %eax */
265 0x80cd, /* int $0x80 */
268 static const struct {
273 } __attribute__((packed)) rt_retcode = {
274 0xb8, /* movl $..., %eax */
276 0x80cd, /* int $0x80 */
281 __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
282 struct pt_regs *regs)
284 struct sigframe __user *frame;
285 void __user *restorer;
287 void __user *fpstate = NULL;
289 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
291 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
294 if (__put_user(sig, &frame->sig))
297 if (setup_sigcontext(&frame->sc, fpstate, regs, set->sig[0]))
300 if (_NSIG_WORDS > 1) {
301 if (__copy_to_user(&frame->extramask, &set->sig[1],
302 sizeof(frame->extramask)))
306 if (current->mm->context.vdso)
307 restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
309 restorer = &frame->retcode;
310 if (ka->sa.sa_flags & SA_RESTORER)
311 restorer = ka->sa.sa_restorer;
313 /* Set up to return from userspace. */
314 err |= __put_user(restorer, &frame->pretcode);
317 * This is popl %eax ; movl $__NR_sigreturn, %eax ; int $0x80
319 * WE DO NOT USE IT ANY MORE! It's only left here for historical
320 * reasons and because gdb uses it as a signature to notice
321 * signal handler stack frames.
323 err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
328 /* Set up registers for signal handler */
329 regs->sp = (unsigned long)frame;
330 regs->ip = (unsigned long)ka->sa.sa_handler;
331 regs->ax = (unsigned long)sig;
335 regs->ds = __USER_DS;
336 regs->es = __USER_DS;
337 regs->ss = __USER_DS;
338 regs->cs = __USER_CS;
343 static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
344 sigset_t *set, struct pt_regs *regs)
346 struct rt_sigframe __user *frame;
347 void __user *restorer;
349 void __user *fpstate = NULL;
351 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
353 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
357 put_user_ex(sig, &frame->sig);
358 put_user_ex(&frame->info, &frame->pinfo);
359 put_user_ex(&frame->uc, &frame->puc);
360 err |= copy_siginfo_to_user(&frame->info, info);
362 /* Create the ucontext. */
364 put_user_ex(UC_FP_XSTATE, &frame->uc.uc_flags);
366 put_user_ex(0, &frame->uc.uc_flags);
367 put_user_ex(0, &frame->uc.uc_link);
368 put_user_ex(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
369 put_user_ex(sas_ss_flags(regs->sp),
370 &frame->uc.uc_stack.ss_flags);
371 put_user_ex(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
372 err |= setup_sigcontext(&frame->uc.uc_mcontext, fpstate,
374 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
376 /* Set up to return from userspace. */
377 restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
378 if (ka->sa.sa_flags & SA_RESTORER)
379 restorer = ka->sa.sa_restorer;
380 put_user_ex(restorer, &frame->pretcode);
383 * This is movl $__NR_rt_sigreturn, %ax ; int $0x80
385 * WE DO NOT USE IT ANY MORE! It's only left here for historical
386 * reasons and because gdb uses it as a signature to notice
387 * signal handler stack frames.
389 put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
390 } put_user_catch(err);
395 /* Set up registers for signal handler */
396 regs->sp = (unsigned long)frame;
397 regs->ip = (unsigned long)ka->sa.sa_handler;
398 regs->ax = (unsigned long)sig;
399 regs->dx = (unsigned long)&frame->info;
400 regs->cx = (unsigned long)&frame->uc;
402 regs->ds = __USER_DS;
403 regs->es = __USER_DS;
404 regs->ss = __USER_DS;
405 regs->cs = __USER_CS;
409 #else /* !CONFIG_X86_32 */
410 static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
411 sigset_t *set, struct pt_regs *regs)
413 struct rt_sigframe __user *frame;
414 void __user *fp = NULL;
416 struct task_struct *me = current;
418 frame = get_sigframe(ka, regs, sizeof(struct rt_sigframe), &fp);
420 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
423 if (ka->sa.sa_flags & SA_SIGINFO) {
424 if (copy_siginfo_to_user(&frame->info, info))
429 /* Create the ucontext. */
431 put_user_ex(UC_FP_XSTATE, &frame->uc.uc_flags);
433 put_user_ex(0, &frame->uc.uc_flags);
434 put_user_ex(0, &frame->uc.uc_link);
435 put_user_ex(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
436 put_user_ex(sas_ss_flags(regs->sp),
437 &frame->uc.uc_stack.ss_flags);
438 put_user_ex(me->sas_ss_size, &frame->uc.uc_stack.ss_size);
439 err |= setup_sigcontext(&frame->uc.uc_mcontext, fp, regs, set->sig[0]);
440 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
442 /* Set up to return from userspace. If provided, use a stub
443 already in userspace. */
444 /* x86-64 should always use SA_RESTORER. */
445 if (ka->sa.sa_flags & SA_RESTORER) {
446 put_user_ex(ka->sa.sa_restorer, &frame->pretcode);
448 /* could use a vstub here */
451 } put_user_catch(err);
456 /* Set up registers for signal handler */
458 /* In case the signal handler was declared without prototypes */
461 /* This also works for non SA_SIGINFO handlers because they expect the
462 next argument after the signal number on the stack. */
463 regs->si = (unsigned long)&frame->info;
464 regs->dx = (unsigned long)&frame->uc;
465 regs->ip = (unsigned long) ka->sa.sa_handler;
467 regs->sp = (unsigned long)frame;
469 /* Set up the CS register to run signal handlers in 64-bit mode,
470 even if the handler happens to be interrupting 32-bit code. */
471 regs->cs = __USER_CS;
475 #endif /* CONFIG_X86_32 */
479 * Atomically swap in the new signal mask, and wait for a signal.
482 sys_sigsuspend(int history0, int history1, old_sigset_t mask)
485 siginitset(&blocked, mask);
486 return sigsuspend(&blocked);
490 sys_sigaction(int sig, const struct old_sigaction __user *act,
491 struct old_sigaction __user *oact)
493 struct k_sigaction new_ka, old_ka;
499 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
503 get_user_ex(new_ka.sa.sa_handler, &act->sa_handler);
504 get_user_ex(new_ka.sa.sa_flags, &act->sa_flags);
505 get_user_ex(mask, &act->sa_mask);
506 get_user_ex(new_ka.sa.sa_restorer, &act->sa_restorer);
507 } get_user_catch(ret);
511 siginitset(&new_ka.sa.sa_mask, mask);
514 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
517 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
521 put_user_ex(old_ka.sa.sa_handler, &oact->sa_handler);
522 put_user_ex(old_ka.sa.sa_flags, &oact->sa_flags);
523 put_user_ex(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
524 put_user_ex(old_ka.sa.sa_restorer, &oact->sa_restorer);
525 } put_user_catch(ret);
533 #endif /* CONFIG_X86_32 */
536 sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
537 struct pt_regs *regs)
539 return do_sigaltstack(uss, uoss, regs->sp);
543 * Do a signal return; undo the signal stack.
546 unsigned long sys_sigreturn(struct pt_regs *regs)
548 struct sigframe __user *frame;
552 frame = (struct sigframe __user *)(regs->sp - 8);
554 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
556 if (__get_user(set.sig[0], &frame->sc.oldmask) || (_NSIG_WORDS > 1
557 && __copy_from_user(&set.sig[1], &frame->extramask,
558 sizeof(frame->extramask))))
561 set_current_blocked(&set);
563 if (restore_sigcontext(regs, &frame->sc, &ax))
568 signal_fault(regs, frame, "sigreturn");
572 #endif /* CONFIG_X86_32 */
574 long sys_rt_sigreturn(struct pt_regs *regs)
576 struct rt_sigframe __user *frame;
580 frame = (struct rt_sigframe __user *)(regs->sp - sizeof(long));
581 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
583 if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
586 set_current_blocked(&set);
588 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ax))
591 if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->sp) == -EFAULT)
597 signal_fault(regs, frame, "rt_sigreturn");
602 * OK, we're invoking a handler:
604 static int signr_convert(int sig)
607 struct thread_info *info = current_thread_info();
609 if (info->exec_domain && info->exec_domain->signal_invmap && sig < 32)
610 return info->exec_domain->signal_invmap[sig];
611 #endif /* CONFIG_X86_32 */
618 #define ia32_setup_frame __setup_frame
619 #define ia32_setup_rt_frame __setup_rt_frame
621 #else /* !CONFIG_X86_32 */
623 #ifdef CONFIG_IA32_EMULATION
624 #define is_ia32 test_thread_flag(TIF_IA32)
625 #else /* !CONFIG_IA32_EMULATION */
627 #endif /* CONFIG_IA32_EMULATION */
629 #ifdef CONFIG_X86_X32_ABI
630 #define is_x32 test_thread_flag(TIF_X32)
632 static int x32_setup_rt_frame(int sig, struct k_sigaction *ka,
633 siginfo_t *info, compat_sigset_t *set,
634 struct pt_regs *regs);
635 #else /* !CONFIG_X86_X32_ABI */
637 #endif /* CONFIG_X86_X32_ABI */
639 int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
640 sigset_t *set, struct pt_regs *regs);
641 int ia32_setup_frame(int sig, struct k_sigaction *ka,
642 sigset_t *set, struct pt_regs *regs);
644 #endif /* CONFIG_X86_32 */
647 setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
648 struct pt_regs *regs)
650 int usig = signr_convert(sig);
651 sigset_t *set = sigmask_to_save();
653 /* Set up the stack frame */
655 if (ka->sa.sa_flags & SA_SIGINFO)
656 return ia32_setup_rt_frame(usig, ka, info, set, regs);
658 return ia32_setup_frame(usig, ka, set, regs);
659 #ifdef CONFIG_X86_X32_ABI
661 return x32_setup_rt_frame(usig, ka, info,
662 (compat_sigset_t *)set, regs);
665 return __setup_rt_frame(sig, ka, info, set, regs);
670 handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
671 struct pt_regs *regs)
673 /* Are we from a system call? */
674 if (syscall_get_nr(current, regs) >= 0) {
675 /* If so, check system call restarting.. */
676 switch (syscall_get_error(current, regs)) {
677 case -ERESTART_RESTARTBLOCK:
678 case -ERESTARTNOHAND:
683 if (!(ka->sa.sa_flags & SA_RESTART)) {
688 case -ERESTARTNOINTR:
689 regs->ax = regs->orig_ax;
696 * If TF is set due to a debugger (TIF_FORCED_TF), clear the TF
697 * flag so that register information in the sigcontext is correct.
699 if (unlikely(regs->flags & X86_EFLAGS_TF) &&
700 likely(test_and_clear_thread_flag(TIF_FORCED_TF)))
701 regs->flags &= ~X86_EFLAGS_TF;
703 if (setup_rt_frame(sig, ka, info, regs) < 0) {
704 force_sigsegv(sig, current);
709 * Clear the direction flag as per the ABI for function entry.
711 regs->flags &= ~X86_EFLAGS_DF;
714 * Clear TF when entering the signal handler, but
715 * notify any tracer that was single-stepping it.
716 * The tracer may want to single-step inside the
719 regs->flags &= ~X86_EFLAGS_TF;
721 signal_delivered(sig, info, ka, regs,
722 test_thread_flag(TIF_SINGLESTEP));
726 #define NR_restart_syscall __NR_restart_syscall
727 #else /* !CONFIG_X86_32 */
728 #define NR_restart_syscall \
729 test_thread_flag(TIF_IA32) ? __NR_ia32_restart_syscall : __NR_restart_syscall
730 #endif /* CONFIG_X86_32 */
733 * Note that 'init' is a special process: it doesn't get signals it doesn't
734 * want to handle. Thus you cannot kill init even with a SIGKILL even by
737 static void do_signal(struct pt_regs *regs)
739 struct k_sigaction ka;
743 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
745 /* Whee! Actually deliver the signal. */
746 handle_signal(signr, &info, &ka, regs);
750 /* Did we come from a system call? */
751 if (syscall_get_nr(current, regs) >= 0) {
752 /* Restart the system call - no handlers present */
753 switch (syscall_get_error(current, regs)) {
754 case -ERESTARTNOHAND:
756 case -ERESTARTNOINTR:
757 regs->ax = regs->orig_ax;
761 case -ERESTART_RESTARTBLOCK:
762 regs->ax = NR_restart_syscall;
769 * If there's no signal to deliver, we just put the saved sigmask
772 restore_saved_sigmask();
776 * notification of userspace execution resumption
777 * - triggered by the TIF_WORK_MASK flags
780 do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags)
782 #ifdef CONFIG_X86_MCE
783 /* notify userspace of pending MCEs */
784 if (thread_info_flags & _TIF_MCE_NOTIFY)
785 mce_notify_process();
786 #endif /* CONFIG_X86_64 && CONFIG_X86_MCE */
788 if (thread_info_flags & _TIF_UPROBE) {
789 clear_thread_flag(TIF_UPROBE);
790 uprobe_notify_resume(regs);
793 /* deal with pending signal delivery */
794 if (thread_info_flags & _TIF_SIGPENDING)
797 if (thread_info_flags & _TIF_NOTIFY_RESUME) {
798 clear_thread_flag(TIF_NOTIFY_RESUME);
799 tracehook_notify_resume(regs);
801 if (thread_info_flags & _TIF_USER_RETURN_NOTIFY)
802 fire_user_return_notifiers();
805 clear_thread_flag(TIF_IRET);
806 #endif /* CONFIG_X86_32 */
809 void signal_fault(struct pt_regs *regs, void __user *frame, char *where)
811 struct task_struct *me = current;
813 if (show_unhandled_signals && printk_ratelimit()) {
815 "%s[%d] bad frame in %s frame:%p ip:%lx sp:%lx orax:%lx",
816 task_pid_nr(current) > 1 ? KERN_INFO : KERN_EMERG,
817 me->comm, me->pid, where, frame,
818 regs->ip, regs->sp, regs->orig_ax);
819 print_vma_addr(" in ", regs->ip);
823 force_sig(SIGSEGV, me);
826 #ifdef CONFIG_X86_X32_ABI
827 static int x32_setup_rt_frame(int sig, struct k_sigaction *ka,
828 siginfo_t *info, compat_sigset_t *set,
829 struct pt_regs *regs)
831 struct rt_sigframe_x32 __user *frame;
832 void __user *restorer;
834 void __user *fpstate = NULL;
836 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
838 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
841 if (ka->sa.sa_flags & SA_SIGINFO) {
842 if (copy_siginfo_to_user32(&frame->info, info))
847 /* Create the ucontext. */
849 put_user_ex(UC_FP_XSTATE, &frame->uc.uc_flags);
851 put_user_ex(0, &frame->uc.uc_flags);
852 put_user_ex(0, &frame->uc.uc_link);
853 put_user_ex(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
854 put_user_ex(sas_ss_flags(regs->sp),
855 &frame->uc.uc_stack.ss_flags);
856 put_user_ex(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
857 put_user_ex(0, &frame->uc.uc__pad0);
858 err |= setup_sigcontext(&frame->uc.uc_mcontext, fpstate,
860 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
862 if (ka->sa.sa_flags & SA_RESTORER) {
863 restorer = ka->sa.sa_restorer;
865 /* could use a vstub here */
869 put_user_ex(restorer, &frame->pretcode);
870 } put_user_catch(err);
875 /* Set up registers for signal handler */
876 regs->sp = (unsigned long) frame;
877 regs->ip = (unsigned long) ka->sa.sa_handler;
879 /* We use the x32 calling convention here... */
881 regs->si = (unsigned long) &frame->info;
882 regs->dx = (unsigned long) &frame->uc;
884 loadsegment(ds, __USER_DS);
885 loadsegment(es, __USER_DS);
887 regs->cs = __USER_CS;
888 regs->ss = __USER_DS;
893 asmlinkage long sys32_x32_rt_sigreturn(struct pt_regs *regs)
895 struct rt_sigframe_x32 __user *frame;
898 struct pt_regs tregs;
900 frame = (struct rt_sigframe_x32 __user *)(regs->sp - 8);
902 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
904 if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
907 set_current_blocked(&set);
909 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ax))
913 if (sys32_sigaltstack(&frame->uc.uc_stack, NULL, &tregs) == -EFAULT)
919 signal_fault(regs, frame, "x32 rt_sigreturn");