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