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 #include <linux/sched.h>
12 #include <linux/smp.h>
13 #include <linux/kernel.h>
14 #include <linux/signal.h>
15 #include <linux/errno.h>
16 #include <linux/wait.h>
17 #include <linux/ptrace.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>
24 #include <asm/processor.h>
25 #include <asm/ucontext.h>
30 #include <asm/proto.h>
31 #include <asm/ia32_unistd.h>
33 #endif /* CONFIG_X86_64 */
35 #include <asm/syscall.h>
36 #include <asm/syscalls.h>
38 #include <asm/sigframe.h>
40 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
42 #define __FIX_EFLAGS (X86_EFLAGS_AC | X86_EFLAGS_OF | \
43 X86_EFLAGS_DF | X86_EFLAGS_TF | X86_EFLAGS_SF | \
44 X86_EFLAGS_ZF | X86_EFLAGS_AF | X86_EFLAGS_PF | \
48 # define FIX_EFLAGS (__FIX_EFLAGS | X86_EFLAGS_RF)
50 # define FIX_EFLAGS __FIX_EFLAGS
54 get_user_ex(regs->x, &sc->x); \
57 #define COPY_SEG(seg) { \
59 get_user_ex(tmp, &sc->seg); \
63 #define COPY_SEG_CPL3(seg) { \
65 get_user_ex(tmp, &sc->seg); \
66 regs->seg = tmp | 3; \
69 #define GET_SEG(seg) { \
71 get_user_ex(tmp, &sc->seg); \
72 loadsegment(seg, tmp); \
76 restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc,
80 unsigned int tmpflags;
83 /* Always make any pending restarted system calls return -EINTR */
84 current_thread_info()->restart_block.fn = do_no_restart_syscall;
93 #endif /* CONFIG_X86_32 */
95 COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx);
96 COPY(dx); COPY(cx); COPY(ip);
107 #endif /* CONFIG_X86_64 */
112 #else /* !CONFIG_X86_32 */
113 /* Kernel saves and restores only the CS segment register on signals,
114 * which is the bare minimum needed to allow mixed 32/64-bit code.
115 * App's signal handler can save/restore other segments if needed. */
117 #endif /* CONFIG_X86_32 */
119 get_user_ex(tmpflags, &sc->flags);
120 regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
121 regs->orig_ax = -1; /* disable syscall checks */
123 get_user_ex(buf, &sc->fpstate);
124 err |= restore_i387_xstate(buf);
126 get_user_ex(*pax, &sc->ax);
127 } get_user_catch(err);
133 setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
134 struct pt_regs *regs, unsigned long mask)
144 savesegment(gs, tmp);
145 put_user_ex(tmp, (unsigned int __user *)&sc->gs);
147 put_user_ex(regs->fs, (unsigned int __user *)&sc->fs);
148 put_user_ex(regs->es, (unsigned int __user *)&sc->es);
149 put_user_ex(regs->ds, (unsigned int __user *)&sc->ds);
150 #endif /* CONFIG_X86_32 */
152 put_user_ex(regs->di, &sc->di);
153 put_user_ex(regs->si, &sc->si);
154 put_user_ex(regs->bp, &sc->bp);
155 put_user_ex(regs->sp, &sc->sp);
156 put_user_ex(regs->bx, &sc->bx);
157 put_user_ex(regs->dx, &sc->dx);
158 put_user_ex(regs->cx, &sc->cx);
159 put_user_ex(regs->ax, &sc->ax);
161 put_user_ex(regs->r8, &sc->r8);
162 put_user_ex(regs->r9, &sc->r9);
163 put_user_ex(regs->r10, &sc->r10);
164 put_user_ex(regs->r11, &sc->r11);
165 put_user_ex(regs->r12, &sc->r12);
166 put_user_ex(regs->r13, &sc->r13);
167 put_user_ex(regs->r14, &sc->r14);
168 put_user_ex(regs->r15, &sc->r15);
169 #endif /* CONFIG_X86_64 */
171 put_user_ex(current->thread.trap_no, &sc->trapno);
172 put_user_ex(current->thread.error_code, &sc->err);
173 put_user_ex(regs->ip, &sc->ip);
175 put_user_ex(regs->cs, (unsigned int __user *)&sc->cs);
176 put_user_ex(regs->flags, &sc->flags);
177 put_user_ex(regs->sp, &sc->sp_at_signal);
178 put_user_ex(regs->ss, (unsigned int __user *)&sc->ss);
179 #else /* !CONFIG_X86_32 */
180 put_user_ex(regs->flags, &sc->flags);
181 put_user_ex(regs->cs, &sc->cs);
182 put_user_ex(0, &sc->gs);
183 put_user_ex(0, &sc->fs);
184 #endif /* CONFIG_X86_32 */
186 put_user_ex(fpstate, &sc->fpstate);
188 /* non-iBCS2 extensions.. */
189 put_user_ex(mask, &sc->oldmask);
190 put_user_ex(current->thread.cr2, &sc->cr2);
191 } put_user_catch(err);
197 * Set up a signal frame.
200 static const struct {
204 } __attribute__((packed)) retcode = {
205 0xb858, /* popl %eax; movl $..., %eax */
207 0x80cd, /* int $0x80 */
210 static const struct {
215 } __attribute__((packed)) rt_retcode = {
216 0xb8, /* movl $..., %eax */
218 0x80cd, /* int $0x80 */
223 * Determine which stack to use..
225 static inline void __user *
226 get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size,
231 /* Default to using normal stack */
235 * If we are on the alternate signal stack and would overflow it, don't.
236 * Return an always-bogus address instead so we will die with SIGSEGV.
238 if (on_sig_stack(sp) && !likely(on_sig_stack(sp - frame_size)))
239 return (void __user *) -1L;
241 /* This is the X/Open sanctioned signal stack switching. */
242 if (ka->sa.sa_flags & SA_ONSTACK) {
243 if (sas_ss_flags(sp) == 0)
244 sp = current->sas_ss_sp + current->sas_ss_size;
246 /* This is the legacy signal stack switching. */
247 if ((regs->ss & 0xffff) != __USER_DS &&
248 !(ka->sa.sa_flags & SA_RESTORER) &&
250 sp = (unsigned long) ka->sa.sa_restorer;
254 sp = sp - sig_xstate_size;
255 *fpstate = (struct _fpstate *) sp;
256 if (save_i387_xstate(*fpstate) < 0)
257 return (void __user *)-1L;
262 * Align the stack pointer according to the i386 ABI,
263 * i.e. so that on function entry ((sp + 4) & 15) == 0.
265 sp = ((sp + 4) & -16ul) - 4;
267 return (void __user *) sp;
271 __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
272 struct pt_regs *regs)
274 struct sigframe __user *frame;
275 void __user *restorer;
277 void __user *fpstate = NULL;
279 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
281 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
284 if (__put_user(sig, &frame->sig))
287 if (setup_sigcontext(&frame->sc, fpstate, regs, set->sig[0]))
290 if (_NSIG_WORDS > 1) {
291 if (__copy_to_user(&frame->extramask, &set->sig[1],
292 sizeof(frame->extramask)))
296 if (current->mm->context.vdso)
297 restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
299 restorer = &frame->retcode;
300 if (ka->sa.sa_flags & SA_RESTORER)
301 restorer = ka->sa.sa_restorer;
303 /* Set up to return from userspace. */
304 err |= __put_user(restorer, &frame->pretcode);
307 * This is popl %eax ; movl $__NR_sigreturn, %eax ; int $0x80
309 * WE DO NOT USE IT ANY MORE! It's only left here for historical
310 * reasons and because gdb uses it as a signature to notice
311 * signal handler stack frames.
313 err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
318 /* Set up registers for signal handler */
319 regs->sp = (unsigned long)frame;
320 regs->ip = (unsigned long)ka->sa.sa_handler;
321 regs->ax = (unsigned long)sig;
325 regs->ds = __USER_DS;
326 regs->es = __USER_DS;
327 regs->ss = __USER_DS;
328 regs->cs = __USER_CS;
333 static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
334 sigset_t *set, struct pt_regs *regs)
336 struct rt_sigframe __user *frame;
337 void __user *restorer;
339 void __user *fpstate = NULL;
341 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
343 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
347 put_user_ex(sig, &frame->sig);
348 put_user_ex(&frame->info, &frame->pinfo);
349 put_user_ex(&frame->uc, &frame->puc);
350 err |= copy_siginfo_to_user(&frame->info, info);
352 /* Create the ucontext. */
354 put_user_ex(UC_FP_XSTATE, &frame->uc.uc_flags);
356 put_user_ex(0, &frame->uc.uc_flags);
357 put_user_ex(0, &frame->uc.uc_link);
358 put_user_ex(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
359 put_user_ex(sas_ss_flags(regs->sp),
360 &frame->uc.uc_stack.ss_flags);
361 put_user_ex(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
362 err |= setup_sigcontext(&frame->uc.uc_mcontext, fpstate,
364 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
366 /* Set up to return from userspace. */
367 restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
368 if (ka->sa.sa_flags & SA_RESTORER)
369 restorer = ka->sa.sa_restorer;
370 put_user_ex(restorer, &frame->pretcode);
373 * This is movl $__NR_rt_sigreturn, %ax ; int $0x80
375 * WE DO NOT USE IT ANY MORE! It's only left here for historical
376 * reasons and because gdb uses it as a signature to notice
377 * signal handler stack frames.
379 put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
380 } put_user_catch(err);
385 /* Set up registers for signal handler */
386 regs->sp = (unsigned long)frame;
387 regs->ip = (unsigned long)ka->sa.sa_handler;
388 regs->ax = (unsigned long)sig;
389 regs->dx = (unsigned long)&frame->info;
390 regs->cx = (unsigned long)&frame->uc;
392 regs->ds = __USER_DS;
393 regs->es = __USER_DS;
394 regs->ss = __USER_DS;
395 regs->cs = __USER_CS;
399 #else /* !CONFIG_X86_32 */
401 * Determine which stack to use..
404 get_stack(struct k_sigaction *ka, unsigned long sp, unsigned long size)
406 /* Default to using normal stack - redzone*/
409 /* This is the X/Open sanctioned signal stack switching. */
410 if (ka->sa.sa_flags & SA_ONSTACK) {
411 if (sas_ss_flags(sp) == 0)
412 sp = current->sas_ss_sp + current->sas_ss_size;
415 return (void __user *)round_down(sp - size, 64);
418 static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
419 sigset_t *set, struct pt_regs *regs)
421 struct rt_sigframe __user *frame;
422 void __user *fp = NULL;
424 struct task_struct *me = current;
427 fp = get_stack(ka, regs->sp, sig_xstate_size);
428 frame = (void __user *)round_down(
429 (unsigned long)fp - sizeof(struct rt_sigframe), 16) - 8;
431 if (save_i387_xstate(fp) < 0)
434 frame = get_stack(ka, regs->sp, sizeof(struct rt_sigframe)) - 8;
436 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
439 if (ka->sa.sa_flags & SA_SIGINFO) {
440 if (copy_siginfo_to_user(&frame->info, info))
445 /* Create the ucontext. */
447 put_user_ex(UC_FP_XSTATE, &frame->uc.uc_flags);
449 put_user_ex(0, &frame->uc.uc_flags);
450 put_user_ex(0, &frame->uc.uc_link);
451 put_user_ex(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
452 put_user_ex(sas_ss_flags(regs->sp),
453 &frame->uc.uc_stack.ss_flags);
454 put_user_ex(me->sas_ss_size, &frame->uc.uc_stack.ss_size);
455 err |= setup_sigcontext(&frame->uc.uc_mcontext, fp, regs, set->sig[0]);
456 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
458 /* Set up to return from userspace. If provided, use a stub
459 already in userspace. */
460 /* x86-64 should always use SA_RESTORER. */
461 if (ka->sa.sa_flags & SA_RESTORER) {
462 put_user_ex(ka->sa.sa_restorer, &frame->pretcode);
464 /* could use a vstub here */
467 } put_user_catch(err);
472 /* Set up registers for signal handler */
474 /* In case the signal handler was declared without prototypes */
477 /* This also works for non SA_SIGINFO handlers because they expect the
478 next argument after the signal number on the stack. */
479 regs->si = (unsigned long)&frame->info;
480 regs->dx = (unsigned long)&frame->uc;
481 regs->ip = (unsigned long) ka->sa.sa_handler;
483 regs->sp = (unsigned long)frame;
485 /* Set up the CS register to run signal handlers in 64-bit mode,
486 even if the handler happens to be interrupting 32-bit code. */
487 regs->cs = __USER_CS;
491 #endif /* CONFIG_X86_32 */
495 * Atomically swap in the new signal mask, and wait for a signal.
498 sys_sigsuspend(int history0, int history1, old_sigset_t mask)
501 spin_lock_irq(¤t->sighand->siglock);
502 current->saved_sigmask = current->blocked;
503 siginitset(¤t->blocked, mask);
505 spin_unlock_irq(¤t->sighand->siglock);
507 current->state = TASK_INTERRUPTIBLE;
509 set_restore_sigmask();
511 return -ERESTARTNOHAND;
515 sys_sigaction(int sig, const struct old_sigaction __user *act,
516 struct old_sigaction __user *oact)
518 struct k_sigaction new_ka, old_ka;
524 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
528 get_user_ex(new_ka.sa.sa_handler, &act->sa_handler);
529 get_user_ex(new_ka.sa.sa_flags, &act->sa_flags);
530 get_user_ex(mask, &act->sa_mask);
531 get_user_ex(new_ka.sa.sa_restorer, &act->sa_restorer);
532 } get_user_catch(ret);
536 siginitset(&new_ka.sa.sa_mask, mask);
539 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
542 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
546 put_user_ex(old_ka.sa.sa_handler, &oact->sa_handler);
547 put_user_ex(old_ka.sa.sa_flags, &oact->sa_flags);
548 put_user_ex(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
549 put_user_ex(old_ka.sa.sa_restorer, &oact->sa_restorer);
550 } put_user_catch(ret);
558 #endif /* CONFIG_X86_32 */
561 asmlinkage int sys_sigaltstack(unsigned long bx)
564 * This is needed to make gcc realize it doesn't own the
567 struct pt_regs *regs = (struct pt_regs *)&bx;
568 const stack_t __user *uss = (const stack_t __user *)bx;
569 stack_t __user *uoss = (stack_t __user *)regs->cx;
571 return do_sigaltstack(uss, uoss, regs->sp);
573 #else /* !CONFIG_X86_32 */
575 sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
576 struct pt_regs *regs)
578 return do_sigaltstack(uss, uoss, regs->sp);
580 #endif /* CONFIG_X86_32 */
583 * Do a signal return; undo the signal stack.
586 asmlinkage unsigned long sys_sigreturn(unsigned long __unused)
588 struct sigframe __user *frame;
589 struct pt_regs *regs;
593 regs = (struct pt_regs *) &__unused;
594 frame = (struct sigframe __user *)(regs->sp - 8);
596 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
598 if (__get_user(set.sig[0], &frame->sc.oldmask) || (_NSIG_WORDS > 1
599 && __copy_from_user(&set.sig[1], &frame->extramask,
600 sizeof(frame->extramask))))
603 sigdelsetmask(&set, ~_BLOCKABLE);
604 spin_lock_irq(¤t->sighand->siglock);
605 current->blocked = set;
607 spin_unlock_irq(¤t->sighand->siglock);
609 if (restore_sigcontext(regs, &frame->sc, &ax))
614 signal_fault(regs, frame, "sigreturn");
618 #endif /* CONFIG_X86_32 */
620 static long do_rt_sigreturn(struct pt_regs *regs)
622 struct rt_sigframe __user *frame;
626 frame = (struct rt_sigframe __user *)(regs->sp - sizeof(long));
627 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
629 if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
632 sigdelsetmask(&set, ~_BLOCKABLE);
633 spin_lock_irq(¤t->sighand->siglock);
634 current->blocked = set;
636 spin_unlock_irq(¤t->sighand->siglock);
638 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ax))
641 if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->sp) == -EFAULT)
647 signal_fault(regs, frame, "rt_sigreturn");
653 * Note: do not pass in pt_regs directly as with tail-call optimization
654 * GCC will incorrectly stomp on the caller's frame and corrupt user-space
657 asmlinkage int sys_rt_sigreturn(unsigned long __unused)
659 struct pt_regs *regs = (struct pt_regs *)&__unused;
661 return do_rt_sigreturn(regs);
663 #else /* !CONFIG_X86_32 */
664 asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)
666 return do_rt_sigreturn(regs);
668 #endif /* CONFIG_X86_32 */
671 * OK, we're invoking a handler:
673 static int signr_convert(int sig)
676 struct thread_info *info = current_thread_info();
678 if (info->exec_domain && info->exec_domain->signal_invmap && sig < 32)
679 return info->exec_domain->signal_invmap[sig];
680 #endif /* CONFIG_X86_32 */
687 #define ia32_setup_frame __setup_frame
688 #define ia32_setup_rt_frame __setup_rt_frame
690 #else /* !CONFIG_X86_32 */
692 #ifdef CONFIG_IA32_EMULATION
693 #define is_ia32 test_thread_flag(TIF_IA32)
694 #else /* !CONFIG_IA32_EMULATION */
696 #endif /* CONFIG_IA32_EMULATION */
698 int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
699 sigset_t *set, struct pt_regs *regs);
700 int ia32_setup_frame(int sig, struct k_sigaction *ka,
701 sigset_t *set, struct pt_regs *regs);
703 #endif /* CONFIG_X86_32 */
706 setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
707 sigset_t *set, struct pt_regs *regs)
709 int usig = signr_convert(sig);
712 /* Set up the stack frame */
714 if (ka->sa.sa_flags & SA_SIGINFO)
715 ret = ia32_setup_rt_frame(usig, ka, info, set, regs);
717 ret = ia32_setup_frame(usig, ka, set, regs);
719 ret = __setup_rt_frame(sig, ka, info, set, regs);
722 force_sigsegv(sig, current);
730 handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
731 sigset_t *oldset, struct pt_regs *regs)
735 /* Are we from a system call? */
736 if (syscall_get_nr(current, regs) >= 0) {
737 /* If so, check system call restarting.. */
738 switch (syscall_get_error(current, regs)) {
739 case -ERESTART_RESTARTBLOCK:
740 case -ERESTARTNOHAND:
745 if (!(ka->sa.sa_flags & SA_RESTART)) {
750 case -ERESTARTNOINTR:
751 regs->ax = regs->orig_ax;
758 * If TF is set due to a debugger (TIF_FORCED_TF), clear the TF
759 * flag so that register information in the sigcontext is correct.
761 if (unlikely(regs->flags & X86_EFLAGS_TF) &&
762 likely(test_and_clear_thread_flag(TIF_FORCED_TF)))
763 regs->flags &= ~X86_EFLAGS_TF;
765 ret = setup_rt_frame(sig, ka, info, oldset, regs);
772 * This has nothing to do with segment registers,
773 * despite the name. This magic affects uaccess.h
774 * macros' behavior. Reset it to the normal setting.
780 * Clear the direction flag as per the ABI for function entry.
782 regs->flags &= ~X86_EFLAGS_DF;
785 * Clear TF when entering the signal handler, but
786 * notify any tracer that was single-stepping it.
787 * The tracer may want to single-step inside the
790 regs->flags &= ~X86_EFLAGS_TF;
792 spin_lock_irq(¤t->sighand->siglock);
793 sigorsets(¤t->blocked, ¤t->blocked, &ka->sa.sa_mask);
794 if (!(ka->sa.sa_flags & SA_NODEFER))
795 sigaddset(¤t->blocked, sig);
797 spin_unlock_irq(¤t->sighand->siglock);
799 tracehook_signal_handler(sig, info, ka, regs,
800 test_thread_flag(TIF_SINGLESTEP));
806 #define NR_restart_syscall __NR_restart_syscall
807 #else /* !CONFIG_X86_32 */
808 #define NR_restart_syscall \
809 test_thread_flag(TIF_IA32) ? __NR_ia32_restart_syscall : __NR_restart_syscall
810 #endif /* CONFIG_X86_32 */
813 * Note that 'init' is a special process: it doesn't get signals it doesn't
814 * want to handle. Thus you cannot kill init even with a SIGKILL even by
817 static void do_signal(struct pt_regs *regs)
819 struct k_sigaction ka;
825 * We want the common case to go fast, which is why we may in certain
826 * cases get here from kernel mode. Just return without doing anything
828 * X86_32: vm86 regs switched out by assembly code before reaching
829 * here, so testing against kernel CS suffices.
831 if (!user_mode(regs))
834 if (current_thread_info()->status & TS_RESTORE_SIGMASK)
835 oldset = ¤t->saved_sigmask;
837 oldset = ¤t->blocked;
839 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
842 * Re-enable any watchpoints before delivering the
843 * signal to user space. The processor register will
844 * have been cleared if the watchpoint triggered
847 if (current->thread.debugreg7)
848 set_debugreg(current->thread.debugreg7, 7);
850 /* Whee! Actually deliver the signal. */
851 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
853 * A signal was successfully delivered; the saved
854 * sigmask will have been stored in the signal frame,
855 * and will be restored by sigreturn, so we can simply
856 * clear the TS_RESTORE_SIGMASK flag.
858 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
863 /* Did we come from a system call? */
864 if (syscall_get_nr(current, regs) >= 0) {
865 /* Restart the system call - no handlers present */
866 switch (syscall_get_error(current, regs)) {
867 case -ERESTARTNOHAND:
869 case -ERESTARTNOINTR:
870 regs->ax = regs->orig_ax;
874 case -ERESTART_RESTARTBLOCK:
875 regs->ax = NR_restart_syscall;
882 * If there's no signal to deliver, we just put the saved sigmask
885 if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
886 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
887 sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL);
892 * notification of userspace execution resumption
893 * - triggered by the TIF_WORK_MASK flags
896 do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags)
898 #if defined(CONFIG_X86_64) && defined(CONFIG_X86_MCE)
899 /* notify userspace of pending MCEs */
900 if (thread_info_flags & _TIF_MCE_NOTIFY)
902 #endif /* CONFIG_X86_64 && CONFIG_X86_MCE */
904 /* deal with pending signal delivery */
905 if (thread_info_flags & _TIF_SIGPENDING)
908 if (thread_info_flags & _TIF_NOTIFY_RESUME) {
909 clear_thread_flag(TIF_NOTIFY_RESUME);
910 tracehook_notify_resume(regs);
914 clear_thread_flag(TIF_IRET);
915 #endif /* CONFIG_X86_32 */
918 void signal_fault(struct pt_regs *regs, void __user *frame, char *where)
920 struct task_struct *me = current;
922 if (show_unhandled_signals && printk_ratelimit()) {
924 "%s[%d] bad frame in %s frame:%p ip:%lx sp:%lx orax:%lx",
925 task_pid_nr(current) > 1 ? KERN_INFO : KERN_EMERG,
926 me->comm, me->pid, where, frame,
927 regs->ip, regs->sp, regs->orig_ax);
928 print_vma_addr(" in ", regs->ip);
929 printk(KERN_CONT "\n");
932 force_sig(SIGSEGV, me);