]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blob - arch/arm/kernel/signal.c
Merge signal handler branch
[mirror_ubuntu-hirsute-kernel.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 static int preserve_iwmmxt_context(struct iwmmxt_sigframe *frame)
138 {
139 char kbuf[sizeof(*frame) + 8];
140 struct iwmmxt_sigframe *kframe;
141
142 /* the iWMMXt context must be 64 bit aligned */
143 kframe = (struct iwmmxt_sigframe *)((unsigned long)(kbuf + 8) & ~7);
144 kframe->magic = IWMMXT_MAGIC;
145 kframe->size = IWMMXT_STORAGE_SIZE;
146 iwmmxt_task_copy(current_thread_info(), &kframe->storage);
147 return __copy_to_user(frame, kframe, sizeof(*frame));
148 }
149
150 static int restore_iwmmxt_context(struct iwmmxt_sigframe *frame)
151 {
152 char kbuf[sizeof(*frame) + 8];
153 struct iwmmxt_sigframe *kframe;
154
155 /* the iWMMXt context must be 64 bit aligned */
156 kframe = (struct iwmmxt_sigframe *)((unsigned long)(kbuf + 8) & ~7);
157 if (__copy_from_user(kframe, frame, sizeof(*frame)))
158 return -1;
159 if (kframe->magic != IWMMXT_MAGIC ||
160 kframe->size != IWMMXT_STORAGE_SIZE)
161 return -1;
162 iwmmxt_task_restore(current_thread_info(), &kframe->storage);
163 return 0;
164 }
165
166 #endif
167
168 /*
169 * Do a signal return; undo the signal stack. These are aligned to 64-bit.
170 */
171 struct sigframe {
172 struct ucontext uc;
173 unsigned long retcode[2];
174 };
175
176 struct rt_sigframe {
177 struct siginfo info;
178 struct sigframe sig;
179 };
180
181 static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf)
182 {
183 struct aux_sigframe __user *aux;
184 sigset_t set;
185 int err;
186
187 err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set));
188 if (err == 0) {
189 sigdelsetmask(&set, ~_BLOCKABLE);
190 spin_lock_irq(&current->sighand->siglock);
191 current->blocked = set;
192 recalc_sigpending();
193 spin_unlock_irq(&current->sighand->siglock);
194 }
195
196 __get_user_error(regs->ARM_r0, &sf->uc.uc_mcontext.arm_r0, err);
197 __get_user_error(regs->ARM_r1, &sf->uc.uc_mcontext.arm_r1, err);
198 __get_user_error(regs->ARM_r2, &sf->uc.uc_mcontext.arm_r2, err);
199 __get_user_error(regs->ARM_r3, &sf->uc.uc_mcontext.arm_r3, err);
200 __get_user_error(regs->ARM_r4, &sf->uc.uc_mcontext.arm_r4, err);
201 __get_user_error(regs->ARM_r5, &sf->uc.uc_mcontext.arm_r5, err);
202 __get_user_error(regs->ARM_r6, &sf->uc.uc_mcontext.arm_r6, err);
203 __get_user_error(regs->ARM_r7, &sf->uc.uc_mcontext.arm_r7, err);
204 __get_user_error(regs->ARM_r8, &sf->uc.uc_mcontext.arm_r8, err);
205 __get_user_error(regs->ARM_r9, &sf->uc.uc_mcontext.arm_r9, err);
206 __get_user_error(regs->ARM_r10, &sf->uc.uc_mcontext.arm_r10, err);
207 __get_user_error(regs->ARM_fp, &sf->uc.uc_mcontext.arm_fp, err);
208 __get_user_error(regs->ARM_ip, &sf->uc.uc_mcontext.arm_ip, err);
209 __get_user_error(regs->ARM_sp, &sf->uc.uc_mcontext.arm_sp, err);
210 __get_user_error(regs->ARM_lr, &sf->uc.uc_mcontext.arm_lr, err);
211 __get_user_error(regs->ARM_pc, &sf->uc.uc_mcontext.arm_pc, err);
212 __get_user_error(regs->ARM_cpsr, &sf->uc.uc_mcontext.arm_cpsr, err);
213
214 err |= !valid_user_regs(regs);
215
216 aux = (struct aux_sigframe __user *) sf->uc.uc_regspace;
217 #ifdef CONFIG_IWMMXT
218 if (err == 0 && test_thread_flag(TIF_USING_IWMMXT))
219 err |= restore_iwmmxt_context(&aux->iwmmxt);
220 #endif
221 #ifdef CONFIG_VFP
222 // if (err == 0)
223 // err |= vfp_restore_state(&sf->aux.vfp);
224 #endif
225
226 return err;
227 }
228
229 asmlinkage int sys_sigreturn(struct pt_regs *regs)
230 {
231 struct sigframe __user *frame;
232
233 /* Always make any pending restarted system calls return -EINTR */
234 current_thread_info()->restart_block.fn = do_no_restart_syscall;
235
236 /*
237 * Since we stacked the signal on a 64-bit boundary,
238 * then 'sp' should be word aligned here. If it's
239 * not, then the user is trying to mess with us.
240 */
241 if (regs->ARM_sp & 7)
242 goto badframe;
243
244 frame = (struct sigframe __user *)regs->ARM_sp;
245
246 if (!access_ok(VERIFY_READ, frame, sizeof (*frame)))
247 goto badframe;
248
249 if (restore_sigframe(regs, frame))
250 goto badframe;
251
252 /* Send SIGTRAP if we're single-stepping */
253 if (current->ptrace & PT_SINGLESTEP) {
254 ptrace_cancel_bpt(current);
255 send_sig(SIGTRAP, current, 1);
256 }
257
258 return regs->ARM_r0;
259
260 badframe:
261 force_sig(SIGSEGV, current);
262 return 0;
263 }
264
265 asmlinkage int sys_rt_sigreturn(struct pt_regs *regs)
266 {
267 struct rt_sigframe __user *frame;
268
269 /* Always make any pending restarted system calls return -EINTR */
270 current_thread_info()->restart_block.fn = do_no_restart_syscall;
271
272 /*
273 * Since we stacked the signal on a 64-bit boundary,
274 * then 'sp' should be word aligned here. If it's
275 * not, then the user is trying to mess with us.
276 */
277 if (regs->ARM_sp & 7)
278 goto badframe;
279
280 frame = (struct rt_sigframe __user *)regs->ARM_sp;
281
282 if (!access_ok(VERIFY_READ, frame, sizeof (*frame)))
283 goto badframe;
284
285 if (restore_sigframe(regs, &frame->sig))
286 goto badframe;
287
288 if (do_sigaltstack(&frame->sig.uc.uc_stack, NULL, regs->ARM_sp) == -EFAULT)
289 goto badframe;
290
291 /* Send SIGTRAP if we're single-stepping */
292 if (current->ptrace & PT_SINGLESTEP) {
293 ptrace_cancel_bpt(current);
294 send_sig(SIGTRAP, current, 1);
295 }
296
297 return regs->ARM_r0;
298
299 badframe:
300 force_sig(SIGSEGV, current);
301 return 0;
302 }
303
304 static int
305 setup_sigframe(struct sigframe __user *sf, struct pt_regs *regs, sigset_t *set)
306 {
307 struct aux_sigframe __user *aux;
308 int err = 0;
309
310 __put_user_error(regs->ARM_r0, &sf->uc.uc_mcontext.arm_r0, err);
311 __put_user_error(regs->ARM_r1, &sf->uc.uc_mcontext.arm_r1, err);
312 __put_user_error(regs->ARM_r2, &sf->uc.uc_mcontext.arm_r2, err);
313 __put_user_error(regs->ARM_r3, &sf->uc.uc_mcontext.arm_r3, err);
314 __put_user_error(regs->ARM_r4, &sf->uc.uc_mcontext.arm_r4, err);
315 __put_user_error(regs->ARM_r5, &sf->uc.uc_mcontext.arm_r5, err);
316 __put_user_error(regs->ARM_r6, &sf->uc.uc_mcontext.arm_r6, err);
317 __put_user_error(regs->ARM_r7, &sf->uc.uc_mcontext.arm_r7, err);
318 __put_user_error(regs->ARM_r8, &sf->uc.uc_mcontext.arm_r8, err);
319 __put_user_error(regs->ARM_r9, &sf->uc.uc_mcontext.arm_r9, err);
320 __put_user_error(regs->ARM_r10, &sf->uc.uc_mcontext.arm_r10, err);
321 __put_user_error(regs->ARM_fp, &sf->uc.uc_mcontext.arm_fp, err);
322 __put_user_error(regs->ARM_ip, &sf->uc.uc_mcontext.arm_ip, err);
323 __put_user_error(regs->ARM_sp, &sf->uc.uc_mcontext.arm_sp, err);
324 __put_user_error(regs->ARM_lr, &sf->uc.uc_mcontext.arm_lr, err);
325 __put_user_error(regs->ARM_pc, &sf->uc.uc_mcontext.arm_pc, err);
326 __put_user_error(regs->ARM_cpsr, &sf->uc.uc_mcontext.arm_cpsr, err);
327
328 __put_user_error(current->thread.trap_no, &sf->uc.uc_mcontext.trap_no, err);
329 __put_user_error(current->thread.error_code, &sf->uc.uc_mcontext.error_code, err);
330 __put_user_error(current->thread.address, &sf->uc.uc_mcontext.fault_address, err);
331 __put_user_error(set->sig[0], &sf->uc.uc_mcontext.oldmask, err);
332
333 err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(*set));
334
335 aux = (struct aux_sigframe __user *) sf->uc.uc_regspace;
336 #ifdef CONFIG_IWMMXT
337 if (err == 0 && test_thread_flag(TIF_USING_IWMMXT))
338 err |= preserve_iwmmxt_context(&aux->iwmmxt);
339 #endif
340 #ifdef CONFIG_VFP
341 // if (err == 0)
342 // err |= vfp_save_state(&sf->aux.vfp);
343 #endif
344 __put_user_error(0, &aux->end_magic, err);
345
346 return err;
347 }
348
349 static inline void __user *
350 get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, int framesize)
351 {
352 unsigned long sp = regs->ARM_sp;
353 void __user *frame;
354
355 /*
356 * This is the X/Open sanctioned signal stack switching.
357 */
358 if ((ka->sa.sa_flags & SA_ONSTACK) && !sas_ss_flags(sp))
359 sp = current->sas_ss_sp + current->sas_ss_size;
360
361 /*
362 * ATPCS B01 mandates 8-byte alignment
363 */
364 frame = (void __user *)((sp - framesize) & ~7);
365
366 /*
367 * Check that we can actually write to the signal frame.
368 */
369 if (!access_ok(VERIFY_WRITE, frame, framesize))
370 frame = NULL;
371
372 return frame;
373 }
374
375 static int
376 setup_return(struct pt_regs *regs, struct k_sigaction *ka,
377 unsigned long __user *rc, void __user *frame, int usig)
378 {
379 unsigned long handler = (unsigned long)ka->sa.sa_handler;
380 unsigned long retcode;
381 int thumb = 0;
382 unsigned long cpsr = regs->ARM_cpsr & ~PSR_f;
383
384 /*
385 * Maybe we need to deliver a 32-bit signal to a 26-bit task.
386 */
387 if (ka->sa.sa_flags & SA_THIRTYTWO)
388 cpsr = (cpsr & ~MODE_MASK) | USR_MODE;
389
390 #ifdef CONFIG_ARM_THUMB
391 if (elf_hwcap & HWCAP_THUMB) {
392 /*
393 * The LSB of the handler determines if we're going to
394 * be using THUMB or ARM mode for this signal handler.
395 */
396 thumb = handler & 1;
397
398 if (thumb)
399 cpsr |= PSR_T_BIT;
400 else
401 cpsr &= ~PSR_T_BIT;
402 }
403 #endif
404
405 if (ka->sa.sa_flags & SA_RESTORER) {
406 retcode = (unsigned long)ka->sa.sa_restorer;
407 } else {
408 unsigned int idx = thumb << 1;
409
410 if (ka->sa.sa_flags & SA_SIGINFO)
411 idx += 3;
412
413 if (__put_user(sigreturn_codes[idx], rc) ||
414 __put_user(sigreturn_codes[idx+1], rc+1))
415 return 1;
416
417 if (cpsr & MODE32_BIT) {
418 /*
419 * 32-bit code can use the new high-page
420 * signal return code support.
421 */
422 retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
423 } else {
424 /*
425 * Ensure that the instruction cache sees
426 * the return code written onto the stack.
427 */
428 flush_icache_range((unsigned long)rc,
429 (unsigned long)(rc + 2));
430
431 retcode = ((unsigned long)rc) + thumb;
432 }
433 }
434
435 regs->ARM_r0 = usig;
436 regs->ARM_sp = (unsigned long)frame;
437 regs->ARM_lr = retcode;
438 regs->ARM_pc = handler;
439 regs->ARM_cpsr = cpsr;
440
441 return 0;
442 }
443
444 static int
445 setup_frame(int usig, struct k_sigaction *ka, sigset_t *set, struct pt_regs *regs)
446 {
447 struct sigframe __user *frame = get_sigframe(ka, regs, sizeof(*frame));
448 int err = 0;
449
450 if (!frame)
451 return 1;
452
453 /*
454 * Set uc.uc_flags to a value which sc.trap_no would never have.
455 */
456 __put_user_error(0x5ac3c35a, &frame->uc.uc_flags, err);
457
458 err |= setup_sigframe(frame, regs, set);
459 if (err == 0)
460 err = setup_return(regs, ka, frame->retcode, frame, usig);
461
462 return err;
463 }
464
465 static int
466 setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
467 sigset_t *set, struct pt_regs *regs)
468 {
469 struct rt_sigframe __user *frame = get_sigframe(ka, regs, sizeof(*frame));
470 stack_t stack;
471 int err = 0;
472
473 if (!frame)
474 return 1;
475
476 err |= copy_siginfo_to_user(&frame->info, info);
477
478 __put_user_error(0, &frame->sig.uc.uc_flags, err);
479 __put_user_error(NULL, &frame->sig.uc.uc_link, err);
480
481 memset(&stack, 0, sizeof(stack));
482 stack.ss_sp = (void __user *)current->sas_ss_sp;
483 stack.ss_flags = sas_ss_flags(regs->ARM_sp);
484 stack.ss_size = current->sas_ss_size;
485 err |= __copy_to_user(&frame->sig.uc.uc_stack, &stack, sizeof(stack));
486
487 err |= setup_sigframe(&frame->sig, regs, set);
488 if (err == 0)
489 err = setup_return(regs, ka, frame->sig.retcode, frame, usig);
490
491 if (err == 0) {
492 /*
493 * For realtime signals we must also set the second and third
494 * arguments for the signal handler.
495 * -- Peter Maydell <pmaydell@chiark.greenend.org.uk> 2000-12-06
496 */
497 regs->ARM_r1 = (unsigned long)&frame->info;
498 regs->ARM_r2 = (unsigned long)&frame->sig.uc;
499 }
500
501 return err;
502 }
503
504 static inline void restart_syscall(struct pt_regs *regs)
505 {
506 regs->ARM_r0 = regs->ARM_ORIG_r0;
507 regs->ARM_pc -= thumb_mode(regs) ? 2 : 4;
508 }
509
510 /*
511 * OK, we're invoking a handler
512 */
513 static void
514 handle_signal(unsigned long sig, struct k_sigaction *ka,
515 siginfo_t *info, sigset_t *oldset,
516 struct pt_regs * regs, int syscall)
517 {
518 struct thread_info *thread = current_thread_info();
519 struct task_struct *tsk = current;
520 int usig = sig;
521 int ret;
522
523 /*
524 * If we were from a system call, check for system call restarting...
525 */
526 if (syscall) {
527 switch (regs->ARM_r0) {
528 case -ERESTART_RESTARTBLOCK:
529 case -ERESTARTNOHAND:
530 regs->ARM_r0 = -EINTR;
531 break;
532 case -ERESTARTSYS:
533 if (!(ka->sa.sa_flags & SA_RESTART)) {
534 regs->ARM_r0 = -EINTR;
535 break;
536 }
537 /* fallthrough */
538 case -ERESTARTNOINTR:
539 restart_syscall(regs);
540 }
541 }
542
543 /*
544 * translate the signal
545 */
546 if (usig < 32 && thread->exec_domain && thread->exec_domain->signal_invmap)
547 usig = thread->exec_domain->signal_invmap[usig];
548
549 /*
550 * Set up the stack frame
551 */
552 if (ka->sa.sa_flags & SA_SIGINFO)
553 ret = setup_rt_frame(usig, ka, info, oldset, regs);
554 else
555 ret = setup_frame(usig, ka, oldset, regs);
556
557 /*
558 * Check that the resulting registers are actually sane.
559 */
560 ret |= !valid_user_regs(regs);
561
562 if (ret != 0) {
563 force_sigsegv(sig, tsk);
564 return;
565 }
566
567 /*
568 * Block the signal if we were successful.
569 */
570 spin_lock_irq(&tsk->sighand->siglock);
571 sigorsets(&tsk->blocked, &tsk->blocked,
572 &ka->sa.sa_mask);
573 if (!(ka->sa.sa_flags & SA_NODEFER))
574 sigaddset(&tsk->blocked, sig);
575 recalc_sigpending();
576 spin_unlock_irq(&tsk->sighand->siglock);
577
578 }
579
580 /*
581 * Note that 'init' is a special process: it doesn't get signals it doesn't
582 * want to handle. Thus you cannot kill init even with a SIGKILL even by
583 * mistake.
584 *
585 * Note that we go through the signals twice: once to check the signals that
586 * the kernel can handle, and then we build all the user-level signal handling
587 * stack-frames in one go after that.
588 */
589 static int do_signal(sigset_t *oldset, struct pt_regs *regs, int syscall)
590 {
591 struct k_sigaction ka;
592 siginfo_t info;
593 int signr;
594
595 /*
596 * We want the common case to go fast, which
597 * is why we may in certain cases get here from
598 * kernel mode. Just return without doing anything
599 * if so.
600 */
601 if (!user_mode(regs))
602 return 0;
603
604 if (try_to_freeze())
605 goto no_signal;
606
607 if (current->ptrace & PT_SINGLESTEP)
608 ptrace_cancel_bpt(current);
609
610 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
611 if (signr > 0) {
612 handle_signal(signr, &ka, &info, oldset, regs, syscall);
613 if (current->ptrace & PT_SINGLESTEP)
614 ptrace_set_bpt(current);
615 return 1;
616 }
617
618 no_signal:
619 /*
620 * No signal to deliver to the process - restart the syscall.
621 */
622 if (syscall) {
623 if (regs->ARM_r0 == -ERESTART_RESTARTBLOCK) {
624 if (thumb_mode(regs)) {
625 regs->ARM_r7 = __NR_restart_syscall - __NR_SYSCALL_BASE;
626 regs->ARM_pc -= 2;
627 } else {
628 #if defined(CONFIG_AEABI) && !defined(CONFIG_OABI_COMPAT)
629 regs->ARM_r7 = __NR_restart_syscall;
630 regs->ARM_pc -= 4;
631 #else
632 u32 __user *usp;
633 u32 swival = __NR_restart_syscall;
634
635 regs->ARM_sp -= 12;
636 usp = (u32 __user *)regs->ARM_sp;
637
638 /*
639 * Either we supports OABI only, or we have
640 * EABI with the OABI compat layer enabled.
641 * In the later case we don't know if user
642 * space is EABI or not, and if not we must
643 * not clobber r7. Always using the OABI
644 * syscall solves that issue and works for
645 * all those cases.
646 */
647 swival = swival - __NR_SYSCALL_BASE + __NR_OABI_SYSCALL_BASE;
648
649 put_user(regs->ARM_pc, &usp[0]);
650 /* swi __NR_restart_syscall */
651 put_user(0xef000000 | swival, &usp[1]);
652 /* ldr pc, [sp], #12 */
653 put_user(0xe49df00c, &usp[2]);
654
655 flush_icache_range((unsigned long)usp,
656 (unsigned long)(usp + 3));
657
658 regs->ARM_pc = regs->ARM_sp + 4;
659 #endif
660 }
661 }
662 if (regs->ARM_r0 == -ERESTARTNOHAND ||
663 regs->ARM_r0 == -ERESTARTSYS ||
664 regs->ARM_r0 == -ERESTARTNOINTR) {
665 restart_syscall(regs);
666 }
667 }
668 if (current->ptrace & PT_SINGLESTEP)
669 ptrace_set_bpt(current);
670 return 0;
671 }
672
673 asmlinkage void
674 do_notify_resume(struct pt_regs *regs, unsigned int thread_flags, int syscall)
675 {
676 if (thread_flags & _TIF_SIGPENDING)
677 do_signal(&current->blocked, regs, syscall);
678 }