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>
25 #include <linux/context_tracking.h>
27 #include <asm/processor.h>
28 #include <asm/ucontext.h>
30 #include <asm/fpu-internal.h>
33 #include <asm/sighandling.h>
36 #include <asm/proto.h>
37 #include <asm/ia32_unistd.h>
38 #include <asm/sys_ia32.h>
39 #endif /* CONFIG_X86_64 */
41 #include <asm/syscall.h>
42 #include <asm/syscalls.h>
44 #include <asm/sigframe.h>
47 # define FIX_EFLAGS (__FIX_EFLAGS | X86_EFLAGS_RF)
49 # define FIX_EFLAGS __FIX_EFLAGS
52 #define COPY(x) do { \
53 get_user_ex(regs->x, &sc->x); \
56 #define GET_SEG(seg) ({ \
58 get_user_ex(tmp, &sc->seg); \
62 #define COPY_SEG(seg) do { \
63 regs->seg = GET_SEG(seg); \
66 #define COPY_SEG_CPL3(seg) do { \
67 regs->seg = GET_SEG(seg) | 3; \
70 int restore_sigcontext(struct pt_regs
*regs
, struct sigcontext __user
*sc
,
74 unsigned int tmpflags
;
77 /* Always make any pending restarted system calls return -EINTR */
78 current_thread_info()->restart_block
.fn
= do_no_restart_syscall
;
83 set_user_gs(regs
, GET_SEG(gs
));
87 #endif /* CONFIG_X86_32 */
89 COPY(di
); COPY(si
); COPY(bp
); COPY(sp
); COPY(bx
);
90 COPY(dx
); COPY(cx
); COPY(ip
);
101 #endif /* CONFIG_X86_64 */
106 #else /* !CONFIG_X86_32 */
107 /* Kernel saves and restores only the CS segment register on signals,
108 * which is the bare minimum needed to allow mixed 32/64-bit code.
109 * App's signal handler can save/restore other segments if needed. */
111 #endif /* CONFIG_X86_32 */
113 get_user_ex(tmpflags
, &sc
->flags
);
114 regs
->flags
= (regs
->flags
& ~FIX_EFLAGS
) | (tmpflags
& FIX_EFLAGS
);
115 regs
->orig_ax
= -1; /* disable syscall checks */
117 get_user_ex(buf
, &sc
->fpstate
);
119 get_user_ex(*pax
, &sc
->ax
);
120 } get_user_catch(err
);
122 err
|= restore_xstate_sig(buf
, config_enabled(CONFIG_X86_32
));
127 int setup_sigcontext(struct sigcontext __user
*sc
, void __user
*fpstate
,
128 struct pt_regs
*regs
, unsigned long mask
)
135 put_user_ex(get_user_gs(regs
), (unsigned int __user
*)&sc
->gs
);
136 put_user_ex(regs
->fs
, (unsigned int __user
*)&sc
->fs
);
137 put_user_ex(regs
->es
, (unsigned int __user
*)&sc
->es
);
138 put_user_ex(regs
->ds
, (unsigned int __user
*)&sc
->ds
);
139 #endif /* CONFIG_X86_32 */
141 put_user_ex(regs
->di
, &sc
->di
);
142 put_user_ex(regs
->si
, &sc
->si
);
143 put_user_ex(regs
->bp
, &sc
->bp
);
144 put_user_ex(regs
->sp
, &sc
->sp
);
145 put_user_ex(regs
->bx
, &sc
->bx
);
146 put_user_ex(regs
->dx
, &sc
->dx
);
147 put_user_ex(regs
->cx
, &sc
->cx
);
148 put_user_ex(regs
->ax
, &sc
->ax
);
150 put_user_ex(regs
->r8
, &sc
->r8
);
151 put_user_ex(regs
->r9
, &sc
->r9
);
152 put_user_ex(regs
->r10
, &sc
->r10
);
153 put_user_ex(regs
->r11
, &sc
->r11
);
154 put_user_ex(regs
->r12
, &sc
->r12
);
155 put_user_ex(regs
->r13
, &sc
->r13
);
156 put_user_ex(regs
->r14
, &sc
->r14
);
157 put_user_ex(regs
->r15
, &sc
->r15
);
158 #endif /* CONFIG_X86_64 */
160 put_user_ex(current
->thread
.trap_nr
, &sc
->trapno
);
161 put_user_ex(current
->thread
.error_code
, &sc
->err
);
162 put_user_ex(regs
->ip
, &sc
->ip
);
164 put_user_ex(regs
->cs
, (unsigned int __user
*)&sc
->cs
);
165 put_user_ex(regs
->flags
, &sc
->flags
);
166 put_user_ex(regs
->sp
, &sc
->sp_at_signal
);
167 put_user_ex(regs
->ss
, (unsigned int __user
*)&sc
->ss
);
168 #else /* !CONFIG_X86_32 */
169 put_user_ex(regs
->flags
, &sc
->flags
);
170 put_user_ex(regs
->cs
, &sc
->cs
);
171 put_user_ex(0, &sc
->gs
);
172 put_user_ex(0, &sc
->fs
);
173 #endif /* CONFIG_X86_32 */
175 put_user_ex(fpstate
, &sc
->fpstate
);
177 /* non-iBCS2 extensions.. */
178 put_user_ex(mask
, &sc
->oldmask
);
179 put_user_ex(current
->thread
.cr2
, &sc
->cr2
);
180 } put_user_catch(err
);
186 * Set up a signal frame.
190 * Determine which stack to use..
192 static unsigned long align_sigframe(unsigned long sp
)
196 * Align the stack pointer according to the i386 ABI,
197 * i.e. so that on function entry ((sp + 4) & 15) == 0.
199 sp
= ((sp
+ 4) & -16ul) - 4;
200 #else /* !CONFIG_X86_32 */
201 sp
= round_down(sp
, 16) - 8;
206 static inline void __user
*
207 get_sigframe(struct k_sigaction
*ka
, struct pt_regs
*regs
, size_t frame_size
,
208 void __user
**fpstate
)
210 /* Default to using normal stack */
211 unsigned long math_size
= 0;
212 unsigned long sp
= regs
->sp
;
213 unsigned long buf_fx
= 0;
214 int onsigstack
= on_sig_stack(sp
);
217 if (config_enabled(CONFIG_X86_64
))
221 /* This is the X/Open sanctioned signal stack switching. */
222 if (ka
->sa
.sa_flags
& SA_ONSTACK
) {
223 if (current
->sas_ss_size
)
224 sp
= current
->sas_ss_sp
+ current
->sas_ss_size
;
225 } else if (config_enabled(CONFIG_X86_32
) &&
226 (regs
->ss
& 0xffff) != __USER_DS
&&
227 !(ka
->sa
.sa_flags
& SA_RESTORER
) &&
228 ka
->sa
.sa_restorer
) {
229 /* This is the legacy signal stack switching. */
230 sp
= (unsigned long) ka
->sa
.sa_restorer
;
235 sp
= alloc_mathframe(sp
, config_enabled(CONFIG_X86_32
),
236 &buf_fx
, &math_size
);
237 *fpstate
= (void __user
*)sp
;
240 sp
= align_sigframe(sp
- frame_size
);
243 * If we are on the alternate signal stack and would overflow it, don't.
244 * Return an always-bogus address instead so we will die with SIGSEGV.
246 if (onsigstack
&& !likely(on_sig_stack(sp
)))
247 return (void __user
*)-1L;
249 /* save i387 and extended state */
251 save_xstate_sig(*fpstate
, (void __user
*)buf_fx
, math_size
) < 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
);
361 /* Create the ucontext. */
363 put_user_ex(UC_FP_XSTATE
, &frame
->uc
.uc_flags
);
365 put_user_ex(0, &frame
->uc
.uc_flags
);
366 put_user_ex(0, &frame
->uc
.uc_link
);
367 err
|= __save_altstack(&frame
->uc
.uc_stack
, regs
->sp
);
369 /* Set up to return from userspace. */
370 restorer
= VDSO32_SYMBOL(current
->mm
->context
.vdso
, rt_sigreturn
);
371 if (ka
->sa
.sa_flags
& SA_RESTORER
)
372 restorer
= ka
->sa
.sa_restorer
;
373 put_user_ex(restorer
, &frame
->pretcode
);
376 * This is movl $__NR_rt_sigreturn, %ax ; int $0x80
378 * WE DO NOT USE IT ANY MORE! It's only left here for historical
379 * reasons and because gdb uses it as a signature to notice
380 * signal handler stack frames.
382 put_user_ex(*((u64
*)&rt_retcode
), (u64
*)frame
->retcode
);
383 } put_user_catch(err
);
385 err
|= copy_siginfo_to_user(&frame
->info
, info
);
386 err
|= setup_sigcontext(&frame
->uc
.uc_mcontext
, fpstate
,
388 err
|= __copy_to_user(&frame
->uc
.uc_sigmask
, set
, sizeof(*set
));
393 /* Set up registers for signal handler */
394 regs
->sp
= (unsigned long)frame
;
395 regs
->ip
= (unsigned long)ka
->sa
.sa_handler
;
396 regs
->ax
= (unsigned long)sig
;
397 regs
->dx
= (unsigned long)&frame
->info
;
398 regs
->cx
= (unsigned long)&frame
->uc
;
400 regs
->ds
= __USER_DS
;
401 regs
->es
= __USER_DS
;
402 regs
->ss
= __USER_DS
;
403 regs
->cs
= __USER_CS
;
407 #else /* !CONFIG_X86_32 */
408 static int __setup_rt_frame(int sig
, struct k_sigaction
*ka
, siginfo_t
*info
,
409 sigset_t
*set
, struct pt_regs
*regs
)
411 struct rt_sigframe __user
*frame
;
412 void __user
*fp
= NULL
;
415 frame
= get_sigframe(ka
, regs
, sizeof(struct rt_sigframe
), &fp
);
417 if (!access_ok(VERIFY_WRITE
, frame
, sizeof(*frame
)))
420 if (ka
->sa
.sa_flags
& SA_SIGINFO
) {
421 if (copy_siginfo_to_user(&frame
->info
, info
))
426 /* Create the ucontext. */
428 put_user_ex(UC_FP_XSTATE
, &frame
->uc
.uc_flags
);
430 put_user_ex(0, &frame
->uc
.uc_flags
);
431 put_user_ex(0, &frame
->uc
.uc_link
);
432 err
|= __save_altstack(&frame
->uc
.uc_stack
, regs
->sp
);
434 /* Set up to return from userspace. If provided, use a stub
435 already in userspace. */
436 /* x86-64 should always use SA_RESTORER. */
437 if (ka
->sa
.sa_flags
& SA_RESTORER
) {
438 put_user_ex(ka
->sa
.sa_restorer
, &frame
->pretcode
);
440 /* could use a vstub here */
443 } put_user_catch(err
);
445 err
|= setup_sigcontext(&frame
->uc
.uc_mcontext
, fp
, regs
, set
->sig
[0]);
446 err
|= __copy_to_user(&frame
->uc
.uc_sigmask
, set
, sizeof(*set
));
451 /* Set up registers for signal handler */
453 /* In case the signal handler was declared without prototypes */
456 /* This also works for non SA_SIGINFO handlers because they expect the
457 next argument after the signal number on the stack. */
458 regs
->si
= (unsigned long)&frame
->info
;
459 regs
->dx
= (unsigned long)&frame
->uc
;
460 regs
->ip
= (unsigned long) ka
->sa
.sa_handler
;
462 regs
->sp
= (unsigned long)frame
;
464 /* Set up the CS register to run signal handlers in 64-bit mode,
465 even if the handler happens to be interrupting 32-bit code. */
466 regs
->cs
= __USER_CS
;
470 #endif /* CONFIG_X86_32 */
472 static int x32_setup_rt_frame(int sig
, struct k_sigaction
*ka
,
473 siginfo_t
*info
, compat_sigset_t
*set
,
474 struct pt_regs
*regs
)
476 #ifdef CONFIG_X86_X32_ABI
477 struct rt_sigframe_x32 __user
*frame
;
478 void __user
*restorer
;
480 void __user
*fpstate
= NULL
;
482 frame
= get_sigframe(ka
, regs
, sizeof(*frame
), &fpstate
);
484 if (!access_ok(VERIFY_WRITE
, frame
, sizeof(*frame
)))
487 if (ka
->sa
.sa_flags
& SA_SIGINFO
) {
488 if (copy_siginfo_to_user32(&frame
->info
, info
))
493 /* Create the ucontext. */
495 put_user_ex(UC_FP_XSTATE
, &frame
->uc
.uc_flags
);
497 put_user_ex(0, &frame
->uc
.uc_flags
);
498 put_user_ex(0, &frame
->uc
.uc_link
);
499 err
|= __compat_save_altstack(&frame
->uc
.uc_stack
, regs
->sp
);
500 put_user_ex(0, &frame
->uc
.uc__pad0
);
502 if (ka
->sa
.sa_flags
& SA_RESTORER
) {
503 restorer
= ka
->sa
.sa_restorer
;
505 /* could use a vstub here */
509 put_user_ex(restorer
, &frame
->pretcode
);
510 } put_user_catch(err
);
512 err
|= setup_sigcontext(&frame
->uc
.uc_mcontext
, fpstate
,
514 err
|= __copy_to_user(&frame
->uc
.uc_sigmask
, set
, sizeof(*set
));
519 /* Set up registers for signal handler */
520 regs
->sp
= (unsigned long) frame
;
521 regs
->ip
= (unsigned long) ka
->sa
.sa_handler
;
523 /* We use the x32 calling convention here... */
525 regs
->si
= (unsigned long) &frame
->info
;
526 regs
->dx
= (unsigned long) &frame
->uc
;
528 loadsegment(ds
, __USER_DS
);
529 loadsegment(es
, __USER_DS
);
531 regs
->cs
= __USER_CS
;
532 regs
->ss
= __USER_DS
;
533 #endif /* CONFIG_X86_X32_ABI */
540 * Atomically swap in the new signal mask, and wait for a signal.
543 sys_sigsuspend(int history0
, int history1
, old_sigset_t mask
)
546 siginitset(&blocked
, mask
);
547 return sigsuspend(&blocked
);
551 sys_sigaction(int sig
, const struct old_sigaction __user
*act
,
552 struct old_sigaction __user
*oact
)
554 struct k_sigaction new_ka
, old_ka
;
560 if (!access_ok(VERIFY_READ
, act
, sizeof(*act
)))
564 get_user_ex(new_ka
.sa
.sa_handler
, &act
->sa_handler
);
565 get_user_ex(new_ka
.sa
.sa_flags
, &act
->sa_flags
);
566 get_user_ex(mask
, &act
->sa_mask
);
567 get_user_ex(new_ka
.sa
.sa_restorer
, &act
->sa_restorer
);
568 } get_user_catch(ret
);
572 siginitset(&new_ka
.sa
.sa_mask
, mask
);
575 ret
= do_sigaction(sig
, act
? &new_ka
: NULL
, oact
? &old_ka
: NULL
);
578 if (!access_ok(VERIFY_WRITE
, oact
, sizeof(*oact
)))
582 put_user_ex(old_ka
.sa
.sa_handler
, &oact
->sa_handler
);
583 put_user_ex(old_ka
.sa
.sa_flags
, &oact
->sa_flags
);
584 put_user_ex(old_ka
.sa
.sa_mask
.sig
[0], &oact
->sa_mask
);
585 put_user_ex(old_ka
.sa
.sa_restorer
, &oact
->sa_restorer
);
586 } put_user_catch(ret
);
594 #endif /* CONFIG_X86_32 */
597 * Do a signal return; undo the signal stack.
600 unsigned long sys_sigreturn(struct pt_regs
*regs
)
602 struct sigframe __user
*frame
;
606 frame
= (struct sigframe __user
*)(regs
->sp
- 8);
608 if (!access_ok(VERIFY_READ
, frame
, sizeof(*frame
)))
610 if (__get_user(set
.sig
[0], &frame
->sc
.oldmask
) || (_NSIG_WORDS
> 1
611 && __copy_from_user(&set
.sig
[1], &frame
->extramask
,
612 sizeof(frame
->extramask
))))
615 set_current_blocked(&set
);
617 if (restore_sigcontext(regs
, &frame
->sc
, &ax
))
622 signal_fault(regs
, frame
, "sigreturn");
626 #endif /* CONFIG_X86_32 */
628 long sys_rt_sigreturn(struct pt_regs
*regs
)
630 struct rt_sigframe __user
*frame
;
634 frame
= (struct rt_sigframe __user
*)(regs
->sp
- sizeof(long));
635 if (!access_ok(VERIFY_READ
, frame
, sizeof(*frame
)))
637 if (__copy_from_user(&set
, &frame
->uc
.uc_sigmask
, sizeof(set
)))
640 set_current_blocked(&set
);
642 if (restore_sigcontext(regs
, &frame
->uc
.uc_mcontext
, &ax
))
645 if (restore_altstack(&frame
->uc
.uc_stack
))
651 signal_fault(regs
, frame
, "rt_sigreturn");
656 * OK, we're invoking a handler:
658 static int signr_convert(int sig
)
661 struct thread_info
*info
= current_thread_info();
663 if (info
->exec_domain
&& info
->exec_domain
->signal_invmap
&& sig
< 32)
664 return info
->exec_domain
->signal_invmap
[sig
];
665 #endif /* CONFIG_X86_32 */
670 setup_rt_frame(int sig
, struct k_sigaction
*ka
, siginfo_t
*info
,
671 struct pt_regs
*regs
)
673 int usig
= signr_convert(sig
);
674 sigset_t
*set
= sigmask_to_save();
675 compat_sigset_t
*cset
= (compat_sigset_t
*) set
;
677 /* Set up the stack frame */
678 if (is_ia32_frame()) {
679 if (ka
->sa
.sa_flags
& SA_SIGINFO
)
680 return ia32_setup_rt_frame(usig
, ka
, info
, cset
, regs
);
682 return ia32_setup_frame(usig
, ka
, cset
, regs
);
683 } else if (is_x32_frame()) {
684 return x32_setup_rt_frame(usig
, ka
, info
, cset
, regs
);
686 return __setup_rt_frame(sig
, ka
, info
, set
, regs
);
691 handle_signal(unsigned long sig
, siginfo_t
*info
, struct k_sigaction
*ka
,
692 struct pt_regs
*regs
)
694 /* Are we from a system call? */
695 if (syscall_get_nr(current
, regs
) >= 0) {
696 /* If so, check system call restarting.. */
697 switch (syscall_get_error(current
, regs
)) {
698 case -ERESTART_RESTARTBLOCK
:
699 case -ERESTARTNOHAND
:
704 if (!(ka
->sa
.sa_flags
& SA_RESTART
)) {
709 case -ERESTARTNOINTR
:
710 regs
->ax
= regs
->orig_ax
;
717 * If TF is set due to a debugger (TIF_FORCED_TF), clear the TF
718 * flag so that register information in the sigcontext is correct.
720 if (unlikely(regs
->flags
& X86_EFLAGS_TF
) &&
721 likely(test_and_clear_thread_flag(TIF_FORCED_TF
)))
722 regs
->flags
&= ~X86_EFLAGS_TF
;
724 if (setup_rt_frame(sig
, ka
, info
, regs
) < 0) {
725 force_sigsegv(sig
, current
);
730 * Clear the direction flag as per the ABI for function entry.
732 regs
->flags
&= ~X86_EFLAGS_DF
;
735 * Clear TF when entering the signal handler, but
736 * notify any tracer that was single-stepping it.
737 * The tracer may want to single-step inside the
740 regs
->flags
&= ~X86_EFLAGS_TF
;
742 signal_delivered(sig
, info
, ka
, regs
,
743 test_thread_flag(TIF_SINGLESTEP
));
747 #define NR_restart_syscall __NR_restart_syscall
748 #else /* !CONFIG_X86_32 */
749 #define NR_restart_syscall \
750 test_thread_flag(TIF_IA32) ? __NR_ia32_restart_syscall : __NR_restart_syscall
751 #endif /* CONFIG_X86_32 */
754 * Note that 'init' is a special process: it doesn't get signals it doesn't
755 * want to handle. Thus you cannot kill init even with a SIGKILL even by
758 static void do_signal(struct pt_regs
*regs
)
760 struct k_sigaction ka
;
764 signr
= get_signal_to_deliver(&info
, &ka
, regs
, NULL
);
766 /* Whee! Actually deliver the signal. */
767 handle_signal(signr
, &info
, &ka
, regs
);
771 /* Did we come from a system call? */
772 if (syscall_get_nr(current
, regs
) >= 0) {
773 /* Restart the system call - no handlers present */
774 switch (syscall_get_error(current
, regs
)) {
775 case -ERESTARTNOHAND
:
777 case -ERESTARTNOINTR
:
778 regs
->ax
= regs
->orig_ax
;
782 case -ERESTART_RESTARTBLOCK
:
783 regs
->ax
= NR_restart_syscall
;
790 * If there's no signal to deliver, we just put the saved sigmask
793 restore_saved_sigmask();
797 * notification of userspace execution resumption
798 * - triggered by the TIF_WORK_MASK flags
801 do_notify_resume(struct pt_regs
*regs
, void *unused
, __u32 thread_info_flags
)
805 #ifdef CONFIG_X86_MCE
806 /* notify userspace of pending MCEs */
807 if (thread_info_flags
& _TIF_MCE_NOTIFY
)
808 mce_notify_process();
809 #endif /* CONFIG_X86_64 && CONFIG_X86_MCE */
811 if (thread_info_flags
& _TIF_UPROBE
)
812 uprobe_notify_resume(regs
);
814 /* deal with pending signal delivery */
815 if (thread_info_flags
& _TIF_SIGPENDING
)
818 if (thread_info_flags
& _TIF_NOTIFY_RESUME
) {
819 clear_thread_flag(TIF_NOTIFY_RESUME
);
820 tracehook_notify_resume(regs
);
822 if (thread_info_flags
& _TIF_USER_RETURN_NOTIFY
)
823 fire_user_return_notifiers();
828 void signal_fault(struct pt_regs
*regs
, void __user
*frame
, char *where
)
830 struct task_struct
*me
= current
;
832 if (show_unhandled_signals
&& printk_ratelimit()) {
834 "%s[%d] bad frame in %s frame:%p ip:%lx sp:%lx orax:%lx",
835 task_pid_nr(current
) > 1 ? KERN_INFO
: KERN_EMERG
,
836 me
->comm
, me
->pid
, where
, frame
,
837 regs
->ip
, regs
->sp
, regs
->orig_ax
);
838 print_vma_addr(" in ", regs
->ip
);
842 force_sig(SIGSEGV
, me
);
845 #ifdef CONFIG_X86_X32_ABI
846 asmlinkage
long sys32_x32_rt_sigreturn(struct pt_regs
*regs
)
848 struct rt_sigframe_x32 __user
*frame
;
852 frame
= (struct rt_sigframe_x32 __user
*)(regs
->sp
- 8);
854 if (!access_ok(VERIFY_READ
, frame
, sizeof(*frame
)))
856 if (__copy_from_user(&set
, &frame
->uc
.uc_sigmask
, sizeof(set
)))
859 set_current_blocked(&set
);
861 if (restore_sigcontext(regs
, &frame
->uc
.uc_mcontext
, &ax
))
864 if (compat_restore_altstack(&frame
->uc
.uc_stack
))
870 signal_fault(regs
, frame
, "x32 rt_sigreturn");