]> bbs.cooldavid.org Git - net-next-2.6.git/blob - arch/arm/kernel/signal.c
[ARM] Gather common sigframe restoration code into restore_sigframe()
[net-next-2.6.git] / arch / arm / kernel / signal.c
1 /*
2  *  linux/arch/arm/kernel/signal.c
3  *
4  *  Copyright (C) 1995-2002 Russell King
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10 #include <linux/config.h>
11 #include <linux/errno.h>
12 #include <linux/signal.h>
13 #include <linux/ptrace.h>
14 #include <linux/personality.h>
15
16 #include <asm/cacheflush.h>
17 #include <asm/ucontext.h>
18 #include <asm/uaccess.h>
19 #include <asm/unistd.h>
20
21 #include "ptrace.h"
22 #include "signal.h"
23
24 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
25
26 /*
27  * For ARM syscalls, we encode the syscall number into the instruction.
28  */
29 #define SWI_SYS_SIGRETURN       (0xef000000|(__NR_sigreturn))
30 #define SWI_SYS_RT_SIGRETURN    (0xef000000|(__NR_rt_sigreturn))
31
32 /*
33  * With EABI, the syscall number has to be loaded into r7.
34  */
35 #define MOV_R7_NR_SIGRETURN     (0xe3a07000 | (__NR_sigreturn - __NR_SYSCALL_BASE))
36 #define MOV_R7_NR_RT_SIGRETURN  (0xe3a07000 | (__NR_rt_sigreturn - __NR_SYSCALL_BASE))
37
38 /*
39  * For Thumb syscalls, we pass the syscall number via r7.  We therefore
40  * need two 16-bit instructions.
41  */
42 #define SWI_THUMB_SIGRETURN     (0xdf00 << 16 | 0x2700 | (__NR_sigreturn - __NR_SYSCALL_BASE))
43 #define SWI_THUMB_RT_SIGRETURN  (0xdf00 << 16 | 0x2700 | (__NR_rt_sigreturn - __NR_SYSCALL_BASE))
44
45 const unsigned long sigreturn_codes[7] = {
46         MOV_R7_NR_SIGRETURN,    SWI_SYS_SIGRETURN,    SWI_THUMB_SIGRETURN,
47         MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
48 };
49
50 static int do_signal(sigset_t *oldset, struct pt_regs * regs, int syscall);
51
52 /*
53  * atomically swap in the new signal mask, and wait for a signal.
54  */
55 asmlinkage int sys_sigsuspend(int restart, unsigned long oldmask, old_sigset_t mask, struct pt_regs *regs)
56 {
57         sigset_t saveset;
58
59         mask &= _BLOCKABLE;
60         spin_lock_irq(&current->sighand->siglock);
61         saveset = current->blocked;
62         siginitset(&current->blocked, mask);
63         recalc_sigpending();
64         spin_unlock_irq(&current->sighand->siglock);
65         regs->ARM_r0 = -EINTR;
66
67         while (1) {
68                 current->state = TASK_INTERRUPTIBLE;
69                 schedule();
70                 if (do_signal(&saveset, regs, 0))
71                         return regs->ARM_r0;
72         }
73 }
74
75 asmlinkage int
76 sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize, struct pt_regs *regs)
77 {
78         sigset_t saveset, newset;
79
80         /* XXX: Don't preclude handling different sized sigset_t's. */
81         if (sigsetsize != sizeof(sigset_t))
82                 return -EINVAL;
83
84         if (copy_from_user(&newset, unewset, sizeof(newset)))
85                 return -EFAULT;
86         sigdelsetmask(&newset, ~_BLOCKABLE);
87
88         spin_lock_irq(&current->sighand->siglock);
89         saveset = current->blocked;
90         current->blocked = newset;
91         recalc_sigpending();
92         spin_unlock_irq(&current->sighand->siglock);
93         regs->ARM_r0 = -EINTR;
94
95         while (1) {
96                 current->state = TASK_INTERRUPTIBLE;
97                 schedule();
98                 if (do_signal(&saveset, regs, 0))
99                         return regs->ARM_r0;
100         }
101 }
102
103 asmlinkage int 
104 sys_sigaction(int sig, const struct old_sigaction __user *act,
105               struct old_sigaction __user *oact)
106 {
107         struct k_sigaction new_ka, old_ka;
108         int ret;
109
110         if (act) {
111                 old_sigset_t mask;
112                 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
113                     __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
114                     __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
115                         return -EFAULT;
116                 __get_user(new_ka.sa.sa_flags, &act->sa_flags);
117                 __get_user(mask, &act->sa_mask);
118                 siginitset(&new_ka.sa.sa_mask, mask);
119         }
120
121         ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
122
123         if (!ret && oact) {
124                 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
125                     __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
126                     __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
127                         return -EFAULT;
128                 __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
129                 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
130         }
131
132         return ret;
133 }
134
135 #ifdef CONFIG_IWMMXT
136
137 /* iwmmxt_area is 0x98 bytes long, preceeded by 8 bytes of signature */
138 #define IWMMXT_STORAGE_SIZE     (0x98 + 8)
139 #define IWMMXT_MAGIC0           0x12ef842a
140 #define IWMMXT_MAGIC1           0x1c07ca71
141
142 struct iwmmxt_sigframe {
143         unsigned long   magic0;
144         unsigned long   magic1;
145         unsigned long   storage[0x98/4];
146 };
147
148 static int preserve_iwmmxt_context(struct iwmmxt_sigframe *frame)
149 {
150         char kbuf[sizeof(*frame) + 8];
151         struct iwmmxt_sigframe *kframe;
152
153         /* the iWMMXt context must be 64 bit aligned */
154         kframe = (struct iwmmxt_sigframe *)((unsigned long)(kbuf + 8) & ~7);
155         kframe->magic0 = IWMMXT_MAGIC0;
156         kframe->magic1 = IWMMXT_MAGIC1;
157         iwmmxt_task_copy(current_thread_info(), &kframe->storage);
158         return __copy_to_user(frame, kframe, sizeof(*frame));
159 }
160
161 static int restore_iwmmxt_context(struct iwmmxt_sigframe *frame)
162 {
163         char kbuf[sizeof(*frame) + 8];
164         struct iwmmxt_sigframe *kframe;
165
166         /* the iWMMXt context must be 64 bit aligned */
167         kframe = (struct iwmmxt_sigframe *)((unsigned long)(kbuf + 8) & ~7);
168         if (__copy_from_user(kframe, frame, sizeof(*frame)))
169                 return -1;
170         if (kframe->magic0 != IWMMXT_MAGIC0 ||
171             kframe->magic1 != IWMMXT_MAGIC1)
172                 return -1;
173         iwmmxt_task_restore(current_thread_info(), &kframe->storage);
174         return 0;
175 }
176
177 #endif
178
179 /*
180  * Auxiliary signal frame.  This saves stuff like FP state.
181  * The layout of this structure is not part of the user ABI.
182  */
183 struct aux_sigframe {
184 #ifdef CONFIG_IWMMXT
185         struct iwmmxt_sigframe  iwmmxt;
186 #endif
187 #ifdef CONFIG_VFP
188         union vfp_state         vfp;
189 #endif
190 };
191
192 /*
193  * Do a signal return; undo the signal stack.  These are aligned to 64-bit.
194  */
195 struct sigframe {
196         struct ucontext uc;
197         unsigned long retcode[2];
198         struct aux_sigframe aux __attribute__((aligned(8)));
199 };
200
201 struct rt_sigframe {
202         struct siginfo info;
203         struct sigframe sig;
204 };
205
206 static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf)
207 {
208         sigset_t set;
209         int err;
210
211         err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set));
212         if (err == 0) {
213                 sigdelsetmask(&set, ~_BLOCKABLE);
214                 spin_lock_irq(&current->sighand->siglock);
215                 current->blocked = set;
216                 recalc_sigpending();
217                 spin_unlock_irq(&current->sighand->siglock);
218         }
219
220         __get_user_error(regs->ARM_r0, &sf->uc.uc_mcontext.arm_r0, err);
221         __get_user_error(regs->ARM_r1, &sf->uc.uc_mcontext.arm_r1, err);
222         __get_user_error(regs->ARM_r2, &sf->uc.uc_mcontext.arm_r2, err);
223         __get_user_error(regs->ARM_r3, &sf->uc.uc_mcontext.arm_r3, err);
224         __get_user_error(regs->ARM_r4, &sf->uc.uc_mcontext.arm_r4, err);
225         __get_user_error(regs->ARM_r5, &sf->uc.uc_mcontext.arm_r5, err);
226         __get_user_error(regs->ARM_r6, &sf->uc.uc_mcontext.arm_r6, err);
227         __get_user_error(regs->ARM_r7, &sf->uc.uc_mcontext.arm_r7, err);
228         __get_user_error(regs->ARM_r8, &sf->uc.uc_mcontext.arm_r8, err);
229         __get_user_error(regs->ARM_r9, &sf->uc.uc_mcontext.arm_r9, err);
230         __get_user_error(regs->ARM_r10, &sf->uc.uc_mcontext.arm_r10, err);
231         __get_user_error(regs->ARM_fp, &sf->uc.uc_mcontext.arm_fp, err);
232         __get_user_error(regs->ARM_ip, &sf->uc.uc_mcontext.arm_ip, err);
233         __get_user_error(regs->ARM_sp, &sf->uc.uc_mcontext.arm_sp, err);
234         __get_user_error(regs->ARM_lr, &sf->uc.uc_mcontext.arm_lr, err);
235         __get_user_error(regs->ARM_pc, &sf->uc.uc_mcontext.arm_pc, err);
236         __get_user_error(regs->ARM_cpsr, &sf->uc.uc_mcontext.arm_cpsr, err);
237
238         err |= !valid_user_regs(regs);
239
240 #ifdef CONFIG_IWMMXT
241         if (err == 0 && test_thread_flag(TIF_USING_IWMMXT))
242                 err |= restore_iwmmxt_context(&sf->aux.iwmmxt);
243 #endif
244 #ifdef CONFIG_VFP
245 //      if (err == 0)
246 //              err |= vfp_restore_state(&sf->aux.vfp);
247 #endif
248
249         return err;
250 }
251
252 asmlinkage int sys_sigreturn(struct pt_regs *regs)
253 {
254         struct sigframe __user *frame;
255
256         /* Always make any pending restarted system calls return -EINTR */
257         current_thread_info()->restart_block.fn = do_no_restart_syscall;
258
259         /*
260          * Since we stacked the signal on a 64-bit boundary,
261          * then 'sp' should be word aligned here.  If it's
262          * not, then the user is trying to mess with us.
263          */
264         if (regs->ARM_sp & 7)
265                 goto badframe;
266
267         frame = (struct sigframe __user *)regs->ARM_sp;
268
269         if (!access_ok(VERIFY_READ, frame, sizeof (*frame)))
270                 goto badframe;
271
272         if (restore_sigframe(regs, frame))
273                 goto badframe;
274
275         /* Send SIGTRAP if we're single-stepping */
276         if (current->ptrace & PT_SINGLESTEP) {
277                 ptrace_cancel_bpt(current);
278                 send_sig(SIGTRAP, current, 1);
279         }
280
281         return regs->ARM_r0;
282
283 badframe:
284         force_sig(SIGSEGV, current);
285         return 0;
286 }
287
288 asmlinkage int sys_rt_sigreturn(struct pt_regs *regs)
289 {
290         struct rt_sigframe __user *frame;
291
292         /* Always make any pending restarted system calls return -EINTR */
293         current_thread_info()->restart_block.fn = do_no_restart_syscall;
294
295         /*
296          * Since we stacked the signal on a 64-bit boundary,
297          * then 'sp' should be word aligned here.  If it's
298          * not, then the user is trying to mess with us.
299          */
300         if (regs->ARM_sp & 7)
301                 goto badframe;
302
303         frame = (struct rt_sigframe __user *)regs->ARM_sp;
304
305         if (!access_ok(VERIFY_READ, frame, sizeof (*frame)))
306                 goto badframe;
307
308         if (restore_sigframe(regs, &frame->sig))
309                 goto badframe;
310
311         if (do_sigaltstack(&frame->sig.uc.uc_stack, NULL, regs->ARM_sp) == -EFAULT)
312                 goto badframe;
313
314         /* Send SIGTRAP if we're single-stepping */
315         if (current->ptrace & PT_SINGLESTEP) {
316                 ptrace_cancel_bpt(current);
317                 send_sig(SIGTRAP, current, 1);
318         }
319
320         return regs->ARM_r0;
321
322 badframe:
323         force_sig(SIGSEGV, current);
324         return 0;
325 }
326
327 static int
328 setup_sigcontext(struct sigcontext __user *sc, struct aux_sigframe __user *aux,
329                  struct pt_regs *regs, unsigned long mask)
330 {
331         int err = 0;
332
333         __put_user_error(regs->ARM_r0, &sc->arm_r0, err);
334         __put_user_error(regs->ARM_r1, &sc->arm_r1, err);
335         __put_user_error(regs->ARM_r2, &sc->arm_r2, err);
336         __put_user_error(regs->ARM_r3, &sc->arm_r3, err);
337         __put_user_error(regs->ARM_r4, &sc->arm_r4, err);
338         __put_user_error(regs->ARM_r5, &sc->arm_r5, err);
339         __put_user_error(regs->ARM_r6, &sc->arm_r6, err);
340         __put_user_error(regs->ARM_r7, &sc->arm_r7, err);
341         __put_user_error(regs->ARM_r8, &sc->arm_r8, err);
342         __put_user_error(regs->ARM_r9, &sc->arm_r9, err);
343         __put_user_error(regs->ARM_r10, &sc->arm_r10, err);
344         __put_user_error(regs->ARM_fp, &sc->arm_fp, err);
345         __put_user_error(regs->ARM_ip, &sc->arm_ip, err);
346         __put_user_error(regs->ARM_sp, &sc->arm_sp, err);
347         __put_user_error(regs->ARM_lr, &sc->arm_lr, err);
348         __put_user_error(regs->ARM_pc, &sc->arm_pc, err);
349         __put_user_error(regs->ARM_cpsr, &sc->arm_cpsr, err);
350
351         __put_user_error(current->thread.trap_no, &sc->trap_no, err);
352         __put_user_error(current->thread.error_code, &sc->error_code, err);
353         __put_user_error(current->thread.address, &sc->fault_address, err);
354         __put_user_error(mask, &sc->oldmask, err);
355
356 #ifdef CONFIG_IWMMXT
357         if (err == 0 && test_thread_flag(TIF_USING_IWMMXT))
358                 err |= preserve_iwmmxt_context(&aux->iwmmxt);
359 #endif
360 #ifdef CONFIG_VFP
361 //      if (err == 0)
362 //              err |= vfp_save_state(&aux->vfp);
363 #endif
364
365         return err;
366 }
367
368 static inline void __user *
369 get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, int framesize)
370 {
371         unsigned long sp = regs->ARM_sp;
372         void __user *frame;
373
374         /*
375          * This is the X/Open sanctioned signal stack switching.
376          */
377         if ((ka->sa.sa_flags & SA_ONSTACK) && !sas_ss_flags(sp))
378                 sp = current->sas_ss_sp + current->sas_ss_size;
379
380         /*
381          * ATPCS B01 mandates 8-byte alignment
382          */
383         frame = (void __user *)((sp - framesize) & ~7);
384
385         /*
386          * Check that we can actually write to the signal frame.
387          */
388         if (!access_ok(VERIFY_WRITE, frame, framesize))
389                 frame = NULL;
390
391         return frame;
392 }
393
394 static int
395 setup_return(struct pt_regs *regs, struct k_sigaction *ka,
396              unsigned long __user *rc, void __user *frame, int usig)
397 {
398         unsigned long handler = (unsigned long)ka->sa.sa_handler;
399         unsigned long retcode;
400         int thumb = 0;
401         unsigned long cpsr = regs->ARM_cpsr & ~PSR_f;
402
403         /*
404          * Maybe we need to deliver a 32-bit signal to a 26-bit task.
405          */
406         if (ka->sa.sa_flags & SA_THIRTYTWO)
407                 cpsr = (cpsr & ~MODE_MASK) | USR_MODE;
408
409 #ifdef CONFIG_ARM_THUMB
410         if (elf_hwcap & HWCAP_THUMB) {
411                 /*
412                  * The LSB of the handler determines if we're going to
413                  * be using THUMB or ARM mode for this signal handler.
414                  */
415                 thumb = handler & 1;
416
417                 if (thumb)
418                         cpsr |= PSR_T_BIT;
419                 else
420                         cpsr &= ~PSR_T_BIT;
421         }
422 #endif
423
424         if (ka->sa.sa_flags & SA_RESTORER) {
425                 retcode = (unsigned long)ka->sa.sa_restorer;
426         } else {
427                 unsigned int idx = thumb << 1;
428
429                 if (ka->sa.sa_flags & SA_SIGINFO)
430                         idx += 3;
431
432                 if (__put_user(sigreturn_codes[idx],   rc) ||
433                     __put_user(sigreturn_codes[idx+1], rc+1))
434                         return 1;
435
436                 if (cpsr & MODE32_BIT) {
437                         /*
438                          * 32-bit code can use the new high-page
439                          * signal return code support.
440                          */
441                         retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
442                 } else {
443                         /*
444                          * Ensure that the instruction cache sees
445                          * the return code written onto the stack.
446                          */
447                         flush_icache_range((unsigned long)rc,
448                                            (unsigned long)(rc + 2));
449
450                         retcode = ((unsigned long)rc) + thumb;
451                 }
452         }
453
454         regs->ARM_r0 = usig;
455         regs->ARM_sp = (unsigned long)frame;
456         regs->ARM_lr = retcode;
457         regs->ARM_pc = handler;
458         regs->ARM_cpsr = cpsr;
459
460         return 0;
461 }
462
463 static int
464 setup_frame(int usig, struct k_sigaction *ka, sigset_t *set, struct pt_regs *regs)
465 {
466         struct sigframe __user *frame = get_sigframe(ka, regs, sizeof(*frame));
467         int err = 0;
468
469         if (!frame)
470                 return 1;
471
472         err |= setup_sigcontext(&frame->uc.uc_mcontext, &frame->aux, regs, set->sig[0]);
473         err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
474
475         if (err == 0)
476                 err = setup_return(regs, ka, frame->retcode, frame, usig);
477
478         return err;
479 }
480
481 static int
482 setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
483                sigset_t *set, struct pt_regs *regs)
484 {
485         struct rt_sigframe __user *frame = get_sigframe(ka, regs, sizeof(*frame));
486         stack_t stack;
487         int err = 0;
488
489         if (!frame)
490                 return 1;
491
492         err |= copy_siginfo_to_user(&frame->info, info);
493
494         __put_user_error(0, &frame->sig.uc.uc_flags, err);
495         __put_user_error(NULL, &frame->sig.uc.uc_link, err);
496
497         memset(&stack, 0, sizeof(stack));
498         stack.ss_sp = (void __user *)current->sas_ss_sp;
499         stack.ss_flags = sas_ss_flags(regs->ARM_sp);
500         stack.ss_size = current->sas_ss_size;
501         err |= __copy_to_user(&frame->sig.uc.uc_stack, &stack, sizeof(stack));
502
503         err |= setup_sigcontext(&frame->sig.uc.uc_mcontext, &frame->sig.aux,
504                                 regs, set->sig[0]);
505         err |= __copy_to_user(&frame->sig.uc.uc_sigmask, set, sizeof(*set));
506
507         if (err == 0)
508                 err = setup_return(regs, ka, frame->sig.retcode, frame, usig);
509
510         if (err == 0) {
511                 /*
512                  * For realtime signals we must also set the second and third
513                  * arguments for the signal handler.
514                  *   -- Peter Maydell <pmaydell@chiark.greenend.org.uk> 2000-12-06
515                  */
516                 regs->ARM_r1 = (unsigned long)&frame->info;
517                 regs->ARM_r2 = (unsigned long)&frame->sig.uc;
518         }
519
520         return err;
521 }
522
523 static inline void restart_syscall(struct pt_regs *regs)
524 {
525         regs->ARM_r0 = regs->ARM_ORIG_r0;
526         regs->ARM_pc -= thumb_mode(regs) ? 2 : 4;
527 }
528
529 /*
530  * OK, we're invoking a handler
531  */     
532 static void
533 handle_signal(unsigned long sig, struct k_sigaction *ka,
534               siginfo_t *info, sigset_t *oldset,
535               struct pt_regs * regs, int syscall)
536 {
537         struct thread_info *thread = current_thread_info();
538         struct task_struct *tsk = current;
539         int usig = sig;
540         int ret;
541
542         /*
543          * If we were from a system call, check for system call restarting...
544          */
545         if (syscall) {
546                 switch (regs->ARM_r0) {
547                 case -ERESTART_RESTARTBLOCK:
548                 case -ERESTARTNOHAND:
549                         regs->ARM_r0 = -EINTR;
550                         break;
551                 case -ERESTARTSYS:
552                         if (!(ka->sa.sa_flags & SA_RESTART)) {
553                                 regs->ARM_r0 = -EINTR;
554                                 break;
555                         }
556                         /* fallthrough */
557                 case -ERESTARTNOINTR:
558                         restart_syscall(regs);
559                 }
560         }
561
562         /*
563          * translate the signal
564          */
565         if (usig < 32 && thread->exec_domain && thread->exec_domain->signal_invmap)
566                 usig = thread->exec_domain->signal_invmap[usig];
567
568         /*
569          * Set up the stack frame
570          */
571         if (ka->sa.sa_flags & SA_SIGINFO)
572                 ret = setup_rt_frame(usig, ka, info, oldset, regs);
573         else
574                 ret = setup_frame(usig, ka, oldset, regs);
575
576         /*
577          * Check that the resulting registers are actually sane.
578          */
579         ret |= !valid_user_regs(regs);
580
581         if (ret != 0) {
582                 force_sigsegv(sig, tsk);
583                 return;
584         }
585
586         /*
587          * Block the signal if we were successful.
588          */
589         spin_lock_irq(&tsk->sighand->siglock);
590         sigorsets(&tsk->blocked, &tsk->blocked,
591                   &ka->sa.sa_mask);
592         if (!(ka->sa.sa_flags & SA_NODEFER))
593                 sigaddset(&tsk->blocked, sig);
594         recalc_sigpending();
595         spin_unlock_irq(&tsk->sighand->siglock);
596
597 }
598
599 /*
600  * Note that 'init' is a special process: it doesn't get signals it doesn't
601  * want to handle. Thus you cannot kill init even with a SIGKILL even by
602  * mistake.
603  *
604  * Note that we go through the signals twice: once to check the signals that
605  * the kernel can handle, and then we build all the user-level signal handling
606  * stack-frames in one go after that.
607  */
608 static int do_signal(sigset_t *oldset, struct pt_regs *regs, int syscall)
609 {
610         struct k_sigaction ka;
611         siginfo_t info;
612         int signr;
613
614         /*
615          * We want the common case to go fast, which
616          * is why we may in certain cases get here from
617          * kernel mode. Just return without doing anything
618          * if so.
619          */
620         if (!user_mode(regs))
621                 return 0;
622
623         if (try_to_freeze())
624                 goto no_signal;
625
626         if (current->ptrace & PT_SINGLESTEP)
627                 ptrace_cancel_bpt(current);
628
629         signr = get_signal_to_deliver(&info, &ka, regs, NULL);
630         if (signr > 0) {
631                 handle_signal(signr, &ka, &info, oldset, regs, syscall);
632                 if (current->ptrace & PT_SINGLESTEP)
633                         ptrace_set_bpt(current);
634                 return 1;
635         }
636
637  no_signal:
638         /*
639          * No signal to deliver to the process - restart the syscall.
640          */
641         if (syscall) {
642                 if (regs->ARM_r0 == -ERESTART_RESTARTBLOCK) {
643                         if (thumb_mode(regs)) {
644                                 regs->ARM_r7 = __NR_restart_syscall;
645                                 regs->ARM_pc -= 2;
646                         } else {
647                                 u32 __user *usp;
648
649                                 regs->ARM_sp -= 12;
650                                 usp = (u32 __user *)regs->ARM_sp;
651
652                                 put_user(regs->ARM_pc, &usp[0]);
653                                 /* swi __NR_restart_syscall */
654                                 put_user(0xef000000 | __NR_restart_syscall, &usp[1]);
655                                 /* ldr  pc, [sp], #12 */
656                                 put_user(0xe49df00c, &usp[2]);
657
658                                 flush_icache_range((unsigned long)usp,
659                                                    (unsigned long)(usp + 3));
660
661                                 regs->ARM_pc = regs->ARM_sp + 4;
662                         }
663                 }
664                 if (regs->ARM_r0 == -ERESTARTNOHAND ||
665                     regs->ARM_r0 == -ERESTARTSYS ||
666                     regs->ARM_r0 == -ERESTARTNOINTR) {
667                         restart_syscall(regs);
668                 }
669         }
670         if (current->ptrace & PT_SINGLESTEP)
671                 ptrace_set_bpt(current);
672         return 0;
673 }
674
675 asmlinkage void
676 do_notify_resume(struct pt_regs *regs, unsigned int thread_flags, int syscall)
677 {
678         if (thread_flags & _TIF_SIGPENDING)
679                 do_signal(&current->blocked, regs, syscall);
680 }