182269b752dabcb43fa45a27fba6dd322309ea93
[sfrench/cifs-2.6.git] / arch / x86 / kernel / signal_32.c
1 /*
2  *  Copyright (C) 1991, 1992  Linus Torvalds
3  *
4  *  1997-11-28  Modified for POSIX.1b signals by Richard Henderson
5  *  2000-06-20  Pentium III FXSR, SSE support by Gareth Hughes
6  */
7
8 #include <linux/sched.h>
9 #include <linux/mm.h>
10 #include <linux/smp.h>
11 #include <linux/kernel.h>
12 #include <linux/signal.h>
13 #include <linux/errno.h>
14 #include <linux/wait.h>
15 #include <linux/unistd.h>
16 #include <linux/stddef.h>
17 #include <linux/personality.h>
18 #include <linux/suspend.h>
19 #include <linux/ptrace.h>
20 #include <linux/elf.h>
21 #include <linux/binfmts.h>
22 #include <asm/processor.h>
23 #include <asm/ucontext.h>
24 #include <asm/uaccess.h>
25 #include <asm/i387.h>
26 #include <asm/vdso.h>
27 #include "sigframe_32.h"
28
29 #define DEBUG_SIG 0
30
31 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
32
33 /*
34  * Atomically swap in the new signal mask, and wait for a signal.
35  */
36 asmlinkage int
37 sys_sigsuspend(int history0, int history1, old_sigset_t mask)
38 {
39         mask &= _BLOCKABLE;
40         spin_lock_irq(&current->sighand->siglock);
41         current->saved_sigmask = current->blocked;
42         siginitset(&current->blocked, mask);
43         recalc_sigpending();
44         spin_unlock_irq(&current->sighand->siglock);
45
46         current->state = TASK_INTERRUPTIBLE;
47         schedule();
48         set_thread_flag(TIF_RESTORE_SIGMASK);
49         return -ERESTARTNOHAND;
50 }
51
52 asmlinkage int 
53 sys_sigaction(int sig, const struct old_sigaction __user *act,
54               struct old_sigaction __user *oact)
55 {
56         struct k_sigaction new_ka, old_ka;
57         int ret;
58
59         if (act) {
60                 old_sigset_t mask;
61                 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
62                     __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
63                     __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
64                         return -EFAULT;
65                 __get_user(new_ka.sa.sa_flags, &act->sa_flags);
66                 __get_user(mask, &act->sa_mask);
67                 siginitset(&new_ka.sa.sa_mask, mask);
68         }
69
70         ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
71
72         if (!ret && oact) {
73                 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
74                     __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
75                     __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
76                         return -EFAULT;
77                 __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
78                 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
79         }
80
81         return ret;
82 }
83
84 asmlinkage int
85 sys_sigaltstack(unsigned long bx)
86 {
87         /* This is needed to make gcc realize it doesn't own the "struct pt_regs" */
88         struct pt_regs *regs = (struct pt_regs *)&bx;
89         const stack_t __user *uss = (const stack_t __user *)bx;
90         stack_t __user *uoss = (stack_t __user *)regs->cx;
91
92         return do_sigaltstack(uss, uoss, regs->sp);
93 }
94
95
96 /*
97  * Do a signal return; undo the signal stack.
98  */
99
100 static int
101 restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *peax)
102 {
103         unsigned int err = 0;
104
105         /* Always make any pending restarted system calls return -EINTR */
106         current_thread_info()->restart_block.fn = do_no_restart_syscall;
107
108 #define COPY(x)         err |= __get_user(regs->x, &sc->x)
109
110 #define COPY_SEG(seg)                                                   \
111         { unsigned short tmp;                                           \
112           err |= __get_user(tmp, &sc->seg);                             \
113           regs->seg = tmp; }
114
115 #define COPY_SEG_STRICT(seg)                                            \
116         { unsigned short tmp;                                           \
117           err |= __get_user(tmp, &sc->seg);                             \
118           regs->seg = tmp|3; }
119
120 #define GET_SEG(seg)                                                    \
121         { unsigned short tmp;                                           \
122           err |= __get_user(tmp, &sc->seg);                             \
123           loadsegment(seg,tmp); }
124
125 #define FIX_EFLAGS      (X86_EFLAGS_AC | X86_EFLAGS_RF |                 \
126                          X86_EFLAGS_OF | X86_EFLAGS_DF |                 \
127                          X86_EFLAGS_TF | X86_EFLAGS_SF | X86_EFLAGS_ZF | \
128                          X86_EFLAGS_AF | X86_EFLAGS_PF | X86_EFLAGS_CF)
129
130         GET_SEG(gs);
131         COPY_SEG(fs);
132         COPY_SEG(es);
133         COPY_SEG(ds);
134         COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx);
135         COPY(dx); COPY(cx); COPY(ip);
136         COPY_SEG_STRICT(cs);
137         COPY_SEG_STRICT(ss);
138         
139         {
140                 unsigned int tmpflags;
141                 err |= __get_user(tmpflags, &sc->flags);
142                 regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
143                 regs->orig_ax = -1;             /* disable syscall checks */
144         }
145
146         {
147                 struct _fpstate __user * buf;
148                 err |= __get_user(buf, &sc->fpstate);
149                 if (buf) {
150                         if (!access_ok(VERIFY_READ, buf, sizeof(*buf)))
151                                 goto badframe;
152                         err |= restore_i387(buf);
153                 } else {
154                         struct task_struct *me = current;
155                         if (used_math()) {
156                                 clear_fpu(me);
157                                 clear_used_math();
158                         }
159                 }
160         }
161
162         err |= __get_user(*peax, &sc->ax);
163         return err;
164
165 badframe:
166         return 1;
167 }
168
169 asmlinkage int sys_sigreturn(unsigned long __unused)
170 {
171         struct pt_regs *regs = (struct pt_regs *) &__unused;
172         struct sigframe __user *frame = (struct sigframe __user *)(regs->sp - 8);
173         sigset_t set;
174         int ax;
175
176         if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
177                 goto badframe;
178         if (__get_user(set.sig[0], &frame->sc.oldmask)
179             || (_NSIG_WORDS > 1
180                 && __copy_from_user(&set.sig[1], &frame->extramask,
181                                     sizeof(frame->extramask))))
182                 goto badframe;
183
184         sigdelsetmask(&set, ~_BLOCKABLE);
185         spin_lock_irq(&current->sighand->siglock);
186         current->blocked = set;
187         recalc_sigpending();
188         spin_unlock_irq(&current->sighand->siglock);
189         
190         if (restore_sigcontext(regs, &frame->sc, &ax))
191                 goto badframe;
192         return ax;
193
194 badframe:
195         if (show_unhandled_signals && printk_ratelimit()) {
196                 printk("%s%s[%d] bad frame in sigreturn frame:%p ip:%lx"
197                        " sp:%lx oeax:%lx",
198                     task_pid_nr(current) > 1 ? KERN_INFO : KERN_EMERG,
199                     current->comm, task_pid_nr(current), frame, regs->ip,
200                     regs->sp, regs->orig_ax);
201                 print_vma_addr(" in ", regs->ip);
202                 printk("\n");
203         }
204
205         force_sig(SIGSEGV, current);
206         return 0;
207 }       
208
209 asmlinkage int sys_rt_sigreturn(unsigned long __unused)
210 {
211         struct pt_regs *regs = (struct pt_regs *) &__unused;
212         struct rt_sigframe __user *frame = (struct rt_sigframe __user *)(regs->sp - 4);
213         sigset_t set;
214         int ax;
215
216         if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
217                 goto badframe;
218         if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
219                 goto badframe;
220
221         sigdelsetmask(&set, ~_BLOCKABLE);
222         spin_lock_irq(&current->sighand->siglock);
223         current->blocked = set;
224         recalc_sigpending();
225         spin_unlock_irq(&current->sighand->siglock);
226         
227         if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ax))
228                 goto badframe;
229
230         if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->sp) == -EFAULT)
231                 goto badframe;
232
233         return ax;
234
235 badframe:
236         force_sig(SIGSEGV, current);
237         return 0;
238 }       
239
240 /*
241  * Set up a signal frame.
242  */
243
244 static int
245 setup_sigcontext(struct sigcontext __user *sc, struct _fpstate __user *fpstate,
246                  struct pt_regs *regs, unsigned long mask)
247 {
248         int tmp, err = 0;
249
250         err |= __put_user(regs->fs, (unsigned int __user *)&sc->fs);
251         savesegment(gs, tmp);
252         err |= __put_user(tmp, (unsigned int __user *)&sc->gs);
253
254         err |= __put_user(regs->es, (unsigned int __user *)&sc->es);
255         err |= __put_user(regs->ds, (unsigned int __user *)&sc->ds);
256         err |= __put_user(regs->di, &sc->di);
257         err |= __put_user(regs->si, &sc->si);
258         err |= __put_user(regs->bp, &sc->bp);
259         err |= __put_user(regs->sp, &sc->sp);
260         err |= __put_user(regs->bx, &sc->bx);
261         err |= __put_user(regs->dx, &sc->dx);
262         err |= __put_user(regs->cx, &sc->cx);
263         err |= __put_user(regs->ax, &sc->ax);
264         err |= __put_user(current->thread.trap_no, &sc->trapno);
265         err |= __put_user(current->thread.error_code, &sc->err);
266         err |= __put_user(regs->ip, &sc->ip);
267         err |= __put_user(regs->cs, (unsigned int __user *)&sc->cs);
268         err |= __put_user(regs->flags, &sc->flags);
269         err |= __put_user(regs->sp, &sc->sp_at_signal);
270         err |= __put_user(regs->ss, (unsigned int __user *)&sc->ss);
271
272         tmp = save_i387(fpstate);
273         if (tmp < 0)
274           err = 1;
275         else
276           err |= __put_user(tmp ? fpstate : NULL, &sc->fpstate);
277
278         /* non-iBCS2 extensions.. */
279         err |= __put_user(mask, &sc->oldmask);
280         err |= __put_user(current->thread.cr2, &sc->cr2);
281
282         return err;
283 }
284
285 /*
286  * Determine which stack to use..
287  */
288 static inline void __user *
289 get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size)
290 {
291         unsigned long sp;
292
293         /* Default to using normal stack */
294         sp = regs->sp;
295
296         /*
297          * If we are on the alternate signal stack and would overflow it, don't.
298          * Return an always-bogus address instead so we will die with SIGSEGV.
299          */
300         if (on_sig_stack(sp) && !likely(on_sig_stack(sp - frame_size)))
301                 return (void __user *) -1L;
302
303         /* This is the X/Open sanctioned signal stack switching.  */
304         if (ka->sa.sa_flags & SA_ONSTACK) {
305                 if (sas_ss_flags(sp) == 0)
306                         sp = current->sas_ss_sp + current->sas_ss_size;
307         }
308
309         /* This is the legacy signal stack switching. */
310         else if ((regs->ss & 0xffff) != __USER_DS &&
311                  !(ka->sa.sa_flags & SA_RESTORER) &&
312                  ka->sa.sa_restorer) {
313                 sp = (unsigned long) ka->sa.sa_restorer;
314         }
315
316         sp -= frame_size;
317         /* Align the stack pointer according to the i386 ABI,
318          * i.e. so that on function entry ((sp + 4) & 15) == 0. */
319         sp = ((sp + 4) & -16ul) - 4;
320         return (void __user *) sp;
321 }
322
323 /* These symbols are defined with the addresses in the vsyscall page.
324    See vsyscall-sigreturn.S.  */
325 extern void __user __kernel_sigreturn;
326 extern void __user __kernel_rt_sigreturn;
327
328 static int setup_frame(int sig, struct k_sigaction *ka,
329                        sigset_t *set, struct pt_regs * regs)
330 {
331         void __user *restorer;
332         struct sigframe __user *frame;
333         int err = 0;
334         int usig;
335
336         frame = get_sigframe(ka, regs, sizeof(*frame));
337
338         if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
339                 goto give_sigsegv;
340
341         usig = current_thread_info()->exec_domain
342                 && current_thread_info()->exec_domain->signal_invmap
343                 && sig < 32
344                 ? current_thread_info()->exec_domain->signal_invmap[sig]
345                 : sig;
346
347         err = __put_user(usig, &frame->sig);
348         if (err)
349                 goto give_sigsegv;
350
351         err = setup_sigcontext(&frame->sc, &frame->fpstate, regs, set->sig[0]);
352         if (err)
353                 goto give_sigsegv;
354
355         if (_NSIG_WORDS > 1) {
356                 err = __copy_to_user(&frame->extramask, &set->sig[1],
357                                       sizeof(frame->extramask));
358                 if (err)
359                         goto give_sigsegv;
360         }
361
362         if (current->mm->context.vdso)
363                 restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
364         else
365                 restorer = &frame->retcode;
366         if (ka->sa.sa_flags & SA_RESTORER)
367                 restorer = ka->sa.sa_restorer;
368
369         /* Set up to return from userspace.  */
370         err |= __put_user(restorer, &frame->pretcode);
371          
372         /*
373          * This is popl %eax ; movl $,%eax ; int $0x80
374          *
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.
378          */
379         err |= __put_user(0xb858, (short __user *)(frame->retcode+0));
380         err |= __put_user(__NR_sigreturn, (int __user *)(frame->retcode+2));
381         err |= __put_user(0x80cd, (short __user *)(frame->retcode+6));
382
383         if (err)
384                 goto give_sigsegv;
385
386         /* Set up registers for signal handler */
387         regs->sp = (unsigned long) frame;
388         regs->ip = (unsigned long) ka->sa.sa_handler;
389         regs->ax = (unsigned long) sig;
390         regs->dx = 0;
391         regs->cx = 0;
392
393         regs->ds = __USER_DS;
394         regs->es = __USER_DS;
395         regs->ss = __USER_DS;
396         regs->cs = __USER_CS;
397
398         /*
399          * Clear TF when entering the signal handler, but
400          * notify any tracer that was single-stepping it.
401          * The tracer may want to single-step inside the
402          * handler too.
403          */
404         regs->flags &= ~(TF_MASK | X86_EFLAGS_DF);
405         if (test_thread_flag(TIF_SINGLESTEP))
406                 ptrace_notify(SIGTRAP);
407
408 #if DEBUG_SIG
409         printk("SIG deliver (%s:%d): sp=%p pc=%lx ra=%p\n",
410                 current->comm, current->pid, frame, regs->ip, frame->pretcode);
411 #endif
412
413         return 0;
414
415 give_sigsegv:
416         force_sigsegv(sig, current);
417         return -EFAULT;
418 }
419
420 static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
421                            sigset_t *set, struct pt_regs * regs)
422 {
423         void __user *restorer;
424         struct rt_sigframe __user *frame;
425         int err = 0;
426         int usig;
427
428         frame = get_sigframe(ka, regs, sizeof(*frame));
429
430         if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
431                 goto give_sigsegv;
432
433         usig = current_thread_info()->exec_domain
434                 && current_thread_info()->exec_domain->signal_invmap
435                 && sig < 32
436                 ? current_thread_info()->exec_domain->signal_invmap[sig]
437                 : sig;
438
439         err |= __put_user(usig, &frame->sig);
440         err |= __put_user(&frame->info, &frame->pinfo);
441         err |= __put_user(&frame->uc, &frame->puc);
442         err |= copy_siginfo_to_user(&frame->info, info);
443         if (err)
444                 goto give_sigsegv;
445
446         /* Create the ucontext.  */
447         err |= __put_user(0, &frame->uc.uc_flags);
448         err |= __put_user(0, &frame->uc.uc_link);
449         err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
450         err |= __put_user(sas_ss_flags(regs->sp),
451                           &frame->uc.uc_stack.ss_flags);
452         err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
453         err |= setup_sigcontext(&frame->uc.uc_mcontext, &frame->fpstate,
454                                 regs, set->sig[0]);
455         err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
456         if (err)
457                 goto give_sigsegv;
458
459         /* Set up to return from userspace.  */
460         restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
461         if (ka->sa.sa_flags & SA_RESTORER)
462                 restorer = ka->sa.sa_restorer;
463         err |= __put_user(restorer, &frame->pretcode);
464          
465         /*
466          * This is movl $,%ax ; int $0x80
467          *
468          * WE DO NOT USE IT ANY MORE! It's only left here for historical
469          * reasons and because gdb uses it as a signature to notice
470          * signal handler stack frames.
471          */
472         err |= __put_user(0xb8, (char __user *)(frame->retcode+0));
473         err |= __put_user(__NR_rt_sigreturn, (int __user *)(frame->retcode+1));
474         err |= __put_user(0x80cd, (short __user *)(frame->retcode+5));
475
476         if (err)
477                 goto give_sigsegv;
478
479         /* Set up registers for signal handler */
480         regs->sp = (unsigned long) frame;
481         regs->ip = (unsigned long) ka->sa.sa_handler;
482         regs->ax = (unsigned long) usig;
483         regs->dx = (unsigned long) &frame->info;
484         regs->cx = (unsigned long) &frame->uc;
485
486         regs->ds = __USER_DS;
487         regs->es = __USER_DS;
488         regs->ss = __USER_DS;
489         regs->cs = __USER_CS;
490
491         /*
492          * Clear TF when entering the signal handler, but
493          * notify any tracer that was single-stepping it.
494          * The tracer may want to single-step inside the
495          * handler too.
496          */
497         regs->flags &= ~(TF_MASK | X86_EFLAGS_DF);
498         if (test_thread_flag(TIF_SINGLESTEP))
499                 ptrace_notify(SIGTRAP);
500
501 #if DEBUG_SIG
502         printk("SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n",
503                 current->comm, current->pid, frame, regs->ip, frame->pretcode);
504 #endif
505
506         return 0;
507
508 give_sigsegv:
509         force_sigsegv(sig, current);
510         return -EFAULT;
511 }
512
513 /*
514  * OK, we're invoking a handler
515  */     
516
517 static int
518 handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
519               sigset_t *oldset, struct pt_regs *regs)
520 {
521         int ret;
522
523         /* Are we from a system call? */
524         if ((long)regs->orig_ax >= 0) {
525                 /* If so, check system call restarting.. */
526                 switch (regs->ax) {
527                 case -ERESTART_RESTARTBLOCK:
528                 case -ERESTARTNOHAND:
529                         regs->ax = -EINTR;
530                         break;
531
532                 case -ERESTARTSYS:
533                         if (!(ka->sa.sa_flags & SA_RESTART)) {
534                                 regs->ax = -EINTR;
535                                 break;
536                         }
537                 /* fallthrough */
538                 case -ERESTARTNOINTR:
539                         regs->ax = regs->orig_ax;
540                         regs->ip -= 2;
541                         break;
542                 }
543         }
544
545         /*
546          * If TF is set due to a debugger (TIF_FORCED_TF), clear the TF
547          * flag so that register information in the sigcontext is correct.
548          */
549         if (unlikely(regs->flags & X86_EFLAGS_TF) &&
550             likely(test_and_clear_thread_flag(TIF_FORCED_TF)))
551                 regs->flags &= ~X86_EFLAGS_TF;
552
553         /* Set up the stack frame */
554         if (ka->sa.sa_flags & SA_SIGINFO)
555                 ret = setup_rt_frame(sig, ka, info, oldset, regs);
556         else
557                 ret = setup_frame(sig, ka, oldset, regs);
558
559         if (ret == 0) {
560                 spin_lock_irq(&current->sighand->siglock);
561                 sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
562                 if (!(ka->sa.sa_flags & SA_NODEFER))
563                         sigaddset(&current->blocked,sig);
564                 recalc_sigpending();
565                 spin_unlock_irq(&current->sighand->siglock);
566         }
567
568         return ret;
569 }
570
571 /*
572  * Note that 'init' is a special process: it doesn't get signals it doesn't
573  * want to handle. Thus you cannot kill init even with a SIGKILL even by
574  * mistake.
575  */
576 static void do_signal(struct pt_regs *regs)
577 {
578         struct k_sigaction ka;
579         siginfo_t info;
580         int signr;
581         sigset_t *oldset;
582
583         /*
584          * We want the common case to go fast, which is why we may in certain
585          * cases get here from kernel mode. Just return without doing anything
586          * if so.
587          * X86_32: vm86 regs switched out by assembly code before reaching
588          * here, so testing against kernel CS suffices.
589          */
590         if (!user_mode(regs))
591                 return;
592
593         if (test_thread_flag(TIF_RESTORE_SIGMASK))
594                 oldset = &current->saved_sigmask;
595         else
596                 oldset = &current->blocked;
597
598         signr = get_signal_to_deliver(&info, &ka, regs, NULL);
599         if (signr > 0) {
600                 /* Re-enable any watchpoints before delivering the
601                  * signal to user space. The processor register will
602                  * have been cleared if the watchpoint triggered
603                  * inside the kernel.
604                  */
605                 if (current->thread.debugreg7)
606                         set_debugreg(current->thread.debugreg7, 7);
607
608                 /* Whee!  Actually deliver the signal.  */
609                 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
610                         /* a signal was successfully delivered; the saved
611                          * sigmask will have been stored in the signal frame,
612                          * and will be restored by sigreturn, so we can simply
613                          * clear the TIF_RESTORE_SIGMASK flag */
614                         if (test_thread_flag(TIF_RESTORE_SIGMASK))
615                                 clear_thread_flag(TIF_RESTORE_SIGMASK);
616                 }
617
618                 return;
619         }
620
621         /* Did we come from a system call? */
622         if ((long)regs->orig_ax >= 0) {
623                 /* Restart the system call - no handlers present */
624                 switch (regs->ax) {
625                 case -ERESTARTNOHAND:
626                 case -ERESTARTSYS:
627                 case -ERESTARTNOINTR:
628                         regs->ax = regs->orig_ax;
629                         regs->ip -= 2;
630                         break;
631
632                 case -ERESTART_RESTARTBLOCK:
633                         regs->ax = __NR_restart_syscall;
634                         regs->ip -= 2;
635                         break;
636                 }
637         }
638
639         /*
640          * If there's no signal to deliver, we just put the saved sigmask
641          * back.
642          */
643         if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
644                 clear_thread_flag(TIF_RESTORE_SIGMASK);
645                 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
646         }
647 }
648
649 /*
650  * notification of userspace execution resumption
651  * - triggered by the TIF_WORK_MASK flags
652  */
653 void do_notify_resume(struct pt_regs *regs, void *unused,
654                       __u32 thread_info_flags)
655 {
656         /* Pending single-step? */
657         if (thread_info_flags & _TIF_SINGLESTEP) {
658                 regs->flags |= X86_EFLAGS_TF;
659                 clear_thread_flag(TIF_SINGLESTEP);
660         }
661
662         /* deal with pending signal delivery */
663         if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK))
664                 do_signal(regs);
665
666         if (thread_info_flags & _TIF_HRTICK_RESCHED)
667                 hrtick_resched();
668         
669         clear_thread_flag(TIF_IRET);
670 }