Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6] / arch / sparc / kernel / signal.c
1 /*  linux/arch/sparc/kernel/signal.c
2  *
3  *  Copyright (C) 1991, 1992  Linus Torvalds
4  *  Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5  *  Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
6  *  Copyright (C) 1997 Eddie C. Dost   (ecd@skynet.be)
7  */
8
9 #include <linux/sched.h>
10 #include <linux/kernel.h>
11 #include <linux/signal.h>
12 #include <linux/errno.h>
13 #include <linux/wait.h>
14 #include <linux/ptrace.h>
15 #include <linux/unistd.h>
16 #include <linux/mm.h>
17 #include <linux/tty.h>
18 #include <linux/smp.h>
19 #include <linux/binfmts.h>      /* do_coredum */
20 #include <linux/bitops.h>
21
22 #include <asm/uaccess.h>
23 #include <asm/ptrace.h>
24 #include <asm/pgalloc.h>
25 #include <asm/pgtable.h>
26 #include <asm/cacheflush.h>     /* flush_sig_insns */
27
28 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
29
30 extern void fpsave(unsigned long *fpregs, unsigned long *fsr,
31                    void *fpqueue, unsigned long *fpqdepth);
32 extern void fpload(unsigned long *fpregs, unsigned long *fsr);
33
34 struct signal_frame {
35         struct sparc_stackf     ss;
36         __siginfo_t             info;
37         __siginfo_fpu_t __user  *fpu_save;
38         unsigned long           insns[2] __attribute__ ((aligned (8)));
39         unsigned int            extramask[_NSIG_WORDS - 1];
40         unsigned int            extra_size; /* Should be 0 */
41         __siginfo_fpu_t         fpu_state;
42 };
43
44 struct rt_signal_frame {
45         struct sparc_stackf     ss;
46         siginfo_t               info;
47         struct pt_regs          regs;
48         sigset_t                mask;
49         __siginfo_fpu_t __user  *fpu_save;
50         unsigned int            insns[2];
51         stack_t                 stack;
52         unsigned int            extra_size; /* Should be 0 */
53         __siginfo_fpu_t         fpu_state;
54 };
55
56 /* Align macros */
57 #define SF_ALIGNEDSZ  (((sizeof(struct signal_frame) + 7) & (~7)))
58 #define RT_ALIGNEDSZ  (((sizeof(struct rt_signal_frame) + 7) & (~7)))
59
60 static int _sigpause_common(old_sigset_t set)
61 {
62         set &= _BLOCKABLE;
63         spin_lock_irq(&current->sighand->siglock);
64         current->saved_sigmask = current->blocked;
65         siginitset(&current->blocked, set);
66         recalc_sigpending();
67         spin_unlock_irq(&current->sighand->siglock);
68
69         current->state = TASK_INTERRUPTIBLE;
70         schedule();
71         set_thread_flag(TIF_RESTORE_SIGMASK);
72
73         return -ERESTARTNOHAND;
74 }
75
76 asmlinkage int sys_sigsuspend(old_sigset_t set)
77 {
78         return _sigpause_common(set);
79 }
80
81 static inline int
82 restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
83 {
84         int err;
85 #ifdef CONFIG_SMP
86         if (test_tsk_thread_flag(current, TIF_USEDFPU))
87                 regs->psr &= ~PSR_EF;
88 #else
89         if (current == last_task_used_math) {
90                 last_task_used_math = NULL;
91                 regs->psr &= ~PSR_EF;
92         }
93 #endif
94         set_used_math();
95         clear_tsk_thread_flag(current, TIF_USEDFPU);
96
97         if (!access_ok(VERIFY_READ, fpu, sizeof(*fpu)))
98                 return -EFAULT;
99
100         err = __copy_from_user(&current->thread.float_regs[0], &fpu->si_float_regs[0],
101                                (sizeof(unsigned long) * 32));
102         err |= __get_user(current->thread.fsr, &fpu->si_fsr);
103         err |= __get_user(current->thread.fpqdepth, &fpu->si_fpqdepth);
104         if (current->thread.fpqdepth != 0)
105                 err |= __copy_from_user(&current->thread.fpqueue[0],
106                                         &fpu->si_fpqueue[0],
107                                         ((sizeof(unsigned long) +
108                                         (sizeof(unsigned long *)))*16));
109         return err;
110 }
111
112 asmlinkage void do_sigreturn(struct pt_regs *regs)
113 {
114         struct signal_frame __user *sf;
115         unsigned long up_psr, pc, npc;
116         sigset_t set;
117         __siginfo_fpu_t __user *fpu_save;
118         int err;
119
120         /* Always make any pending restarted system calls return -EINTR */
121         current_thread_info()->restart_block.fn = do_no_restart_syscall;
122
123         synchronize_user_stack();
124
125         sf = (struct signal_frame __user *) regs->u_regs[UREG_FP];
126
127         /* 1. Make sure we are not getting garbage from the user */
128         if (!access_ok(VERIFY_READ, sf, sizeof(*sf)))
129                 goto segv_and_exit;
130
131         if (((unsigned long) sf) & 3)
132                 goto segv_and_exit;
133
134         err = __get_user(pc,  &sf->info.si_regs.pc);
135         err |= __get_user(npc, &sf->info.si_regs.npc);
136
137         if ((pc | npc) & 3)
138                 goto segv_and_exit;
139
140         /* 2. Restore the state */
141         up_psr = regs->psr;
142         err |= __copy_from_user(regs, &sf->info.si_regs, sizeof(struct pt_regs));
143
144         /* User can only change condition codes and FPU enabling in %psr. */
145         regs->psr = (up_psr & ~(PSR_ICC | PSR_EF))
146                   | (regs->psr & (PSR_ICC | PSR_EF));
147
148         err |= __get_user(fpu_save, &sf->fpu_save);
149
150         if (fpu_save)
151                 err |= restore_fpu_state(regs, fpu_save);
152
153         /* This is pretty much atomic, no amount locking would prevent
154          * the races which exist anyways.
155          */
156         err |= __get_user(set.sig[0], &sf->info.si_mask);
157         err |= __copy_from_user(&set.sig[1], &sf->extramask,
158                                 (_NSIG_WORDS-1) * sizeof(unsigned int));
159                            
160         if (err)
161                 goto segv_and_exit;
162
163         sigdelsetmask(&set, ~_BLOCKABLE);
164         spin_lock_irq(&current->sighand->siglock);
165         current->blocked = set;
166         recalc_sigpending();
167         spin_unlock_irq(&current->sighand->siglock);
168         return;
169
170 segv_and_exit:
171         force_sig(SIGSEGV, current);
172 }
173
174 asmlinkage void do_rt_sigreturn(struct pt_regs *regs)
175 {
176         struct rt_signal_frame __user *sf;
177         unsigned int psr, pc, npc;
178         __siginfo_fpu_t __user *fpu_save;
179         mm_segment_t old_fs;
180         sigset_t set;
181         stack_t st;
182         int err;
183
184         synchronize_user_stack();
185         sf = (struct rt_signal_frame __user *) regs->u_regs[UREG_FP];
186         if (!access_ok(VERIFY_READ, sf, sizeof(*sf)) ||
187             (((unsigned long) sf) & 0x03))
188                 goto segv;
189
190         err = __get_user(pc, &sf->regs.pc);
191         err |= __get_user(npc, &sf->regs.npc);
192         err |= ((pc | npc) & 0x03);
193
194         err |= __get_user(regs->y, &sf->regs.y);
195         err |= __get_user(psr, &sf->regs.psr);
196
197         err |= __copy_from_user(&regs->u_regs[UREG_G1],
198                                 &sf->regs.u_regs[UREG_G1], 15 * sizeof(u32));
199
200         regs->psr = (regs->psr & ~PSR_ICC) | (psr & PSR_ICC);
201
202         err |= __get_user(fpu_save, &sf->fpu_save);
203
204         if (fpu_save)
205                 err |= restore_fpu_state(regs, fpu_save);
206         err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t));
207         
208         err |= __copy_from_user(&st, &sf->stack, sizeof(stack_t));
209         
210         if (err)
211                 goto segv;
212                 
213         regs->pc = pc;
214         regs->npc = npc;
215         
216         /* It is more difficult to avoid calling this function than to
217          * call it and ignore errors.
218          */
219         old_fs = get_fs();
220         set_fs(KERNEL_DS);
221         do_sigaltstack((const stack_t __user *) &st, NULL, (unsigned long)sf);
222         set_fs(old_fs);
223
224         sigdelsetmask(&set, ~_BLOCKABLE);
225         spin_lock_irq(&current->sighand->siglock);
226         current->blocked = set;
227         recalc_sigpending();
228         spin_unlock_irq(&current->sighand->siglock);
229         return;
230 segv:
231         force_sig(SIGSEGV, current);
232 }
233
234 /* Checks if the fp is valid */
235 static inline int invalid_frame_pointer(void __user *fp, int fplen)
236 {
237         if ((((unsigned long) fp) & 7) ||
238             !__access_ok((unsigned long)fp, fplen) ||
239             ((sparc_cpu_model == sun4 || sparc_cpu_model == sun4c) &&
240              ((unsigned long) fp < 0xe0000000 && (unsigned long) fp >= 0x20000000)))
241                 return 1;
242         
243         return 0;
244 }
245
246 static inline void __user *get_sigframe(struct sigaction *sa, struct pt_regs *regs, unsigned long framesize)
247 {
248         unsigned long sp = regs->u_regs[UREG_FP];
249
250         /*
251          * If we are on the alternate signal stack and would overflow it, don't.
252          * Return an always-bogus address instead so we will die with SIGSEGV.
253          */
254         if (on_sig_stack(sp) && !likely(on_sig_stack(sp - framesize)))
255                 return (void __user *) -1L;
256
257         /* This is the X/Open sanctioned signal stack switching.  */
258         if (sa->sa_flags & SA_ONSTACK) {
259                 if (sas_ss_flags(sp) == 0)
260                         sp = current->sas_ss_sp + current->sas_ss_size;
261         }
262
263         /* Always align the stack frame.  This handles two cases.  First,
264          * sigaltstack need not be mindful of platform specific stack
265          * alignment.  Second, if we took this signal because the stack
266          * is not aligned properly, we'd like to take the signal cleanly
267          * and report that.
268          */
269         sp &= ~7UL;
270
271         return (void __user *)(sp - framesize);
272 }
273
274 static inline int
275 save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
276 {
277         int err = 0;
278 #ifdef CONFIG_SMP
279         if (test_tsk_thread_flag(current, TIF_USEDFPU)) {
280                 put_psr(get_psr() | PSR_EF);
281                 fpsave(&current->thread.float_regs[0], &current->thread.fsr,
282                        &current->thread.fpqueue[0], &current->thread.fpqdepth);
283                 regs->psr &= ~(PSR_EF);
284                 clear_tsk_thread_flag(current, TIF_USEDFPU);
285         }
286 #else
287         if (current == last_task_used_math) {
288                 put_psr(get_psr() | PSR_EF);
289                 fpsave(&current->thread.float_regs[0], &current->thread.fsr,
290                        &current->thread.fpqueue[0], &current->thread.fpqdepth);
291                 last_task_used_math = NULL;
292                 regs->psr &= ~(PSR_EF);
293         }
294 #endif
295         err |= __copy_to_user(&fpu->si_float_regs[0],
296                               &current->thread.float_regs[0],
297                               (sizeof(unsigned long) * 32));
298         err |= __put_user(current->thread.fsr, &fpu->si_fsr);
299         err |= __put_user(current->thread.fpqdepth, &fpu->si_fpqdepth);
300         if (current->thread.fpqdepth != 0)
301                 err |= __copy_to_user(&fpu->si_fpqueue[0],
302                                       &current->thread.fpqueue[0],
303                                       ((sizeof(unsigned long) +
304                                       (sizeof(unsigned long *)))*16));
305         clear_used_math();
306         return err;
307 }
308
309 static void setup_frame(struct k_sigaction *ka, struct pt_regs *regs,
310                         int signo, sigset_t *oldset)
311 {
312         struct signal_frame __user *sf;
313         int sigframe_size, err;
314
315         /* 1. Make sure everything is clean */
316         synchronize_user_stack();
317
318         sigframe_size = SF_ALIGNEDSZ;
319         if (!used_math())
320                 sigframe_size -= sizeof(__siginfo_fpu_t);
321
322         sf = (struct signal_frame __user *)
323                 get_sigframe(&ka->sa, regs, sigframe_size);
324
325         if (invalid_frame_pointer(sf, sigframe_size))
326                 goto sigill_and_return;
327
328         if (current_thread_info()->w_saved != 0)
329                 goto sigill_and_return;
330
331         /* 2. Save the current process state */
332         err = __copy_to_user(&sf->info.si_regs, regs, sizeof(struct pt_regs));
333         
334         err |= __put_user(0, &sf->extra_size);
335
336         if (used_math()) {
337                 err |= save_fpu_state(regs, &sf->fpu_state);
338                 err |= __put_user(&sf->fpu_state, &sf->fpu_save);
339         } else {
340                 err |= __put_user(0, &sf->fpu_save);
341         }
342
343         err |= __put_user(oldset->sig[0], &sf->info.si_mask);
344         err |= __copy_to_user(sf->extramask, &oldset->sig[1],
345                               (_NSIG_WORDS - 1) * sizeof(unsigned int));
346         err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP],
347                               sizeof(struct reg_window));
348         if (err)
349                 goto sigsegv;
350         
351         /* 3. signal handler back-trampoline and parameters */
352         regs->u_regs[UREG_FP] = (unsigned long) sf;
353         regs->u_regs[UREG_I0] = signo;
354         regs->u_regs[UREG_I1] = (unsigned long) &sf->info;
355         regs->u_regs[UREG_I2] = (unsigned long) &sf->info;
356
357         /* 4. signal handler */
358         regs->pc = (unsigned long) ka->sa.sa_handler;
359         regs->npc = (regs->pc + 4);
360
361         /* 5. return to kernel instructions */
362         if (ka->ka_restorer)
363                 regs->u_regs[UREG_I7] = (unsigned long)ka->ka_restorer;
364         else {
365                 regs->u_regs[UREG_I7] = (unsigned long)(&(sf->insns[0]) - 2);
366
367                 /* mov __NR_sigreturn, %g1 */
368                 err |= __put_user(0x821020d8, &sf->insns[0]);
369
370                 /* t 0x10 */
371                 err |= __put_user(0x91d02010, &sf->insns[1]);
372                 if (err)
373                         goto sigsegv;
374
375                 /* Flush instruction space. */
376                 flush_sig_insns(current->mm, (unsigned long) &(sf->insns[0]));
377         }
378         return;
379
380 sigill_and_return:
381         do_exit(SIGILL);
382 sigsegv:
383         force_sigsegv(signo, current);
384 }
385
386 static void setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
387                            int signo, sigset_t *oldset, siginfo_t *info)
388 {
389         struct rt_signal_frame __user *sf;
390         int sigframe_size;
391         unsigned int psr;
392         int err;
393
394         synchronize_user_stack();
395         sigframe_size = RT_ALIGNEDSZ;
396         if (!used_math())
397                 sigframe_size -= sizeof(__siginfo_fpu_t);
398         sf = (struct rt_signal_frame __user *)
399                 get_sigframe(&ka->sa, regs, sigframe_size);
400         if (invalid_frame_pointer(sf, sigframe_size))
401                 goto sigill;
402         if (current_thread_info()->w_saved != 0)
403                 goto sigill;
404
405         err  = __put_user(regs->pc, &sf->regs.pc);
406         err |= __put_user(regs->npc, &sf->regs.npc);
407         err |= __put_user(regs->y, &sf->regs.y);
408         psr = regs->psr;
409         if (used_math())
410                 psr |= PSR_EF;
411         err |= __put_user(psr, &sf->regs.psr);
412         err |= __copy_to_user(&sf->regs.u_regs, regs->u_regs, sizeof(regs->u_regs));
413         err |= __put_user(0, &sf->extra_size);
414
415         if (psr & PSR_EF) {
416                 err |= save_fpu_state(regs, &sf->fpu_state);
417                 err |= __put_user(&sf->fpu_state, &sf->fpu_save);
418         } else {
419                 err |= __put_user(0, &sf->fpu_save);
420         }
421         err |= __copy_to_user(&sf->mask, &oldset->sig[0], sizeof(sigset_t));
422         
423         /* Setup sigaltstack */
424         err |= __put_user(current->sas_ss_sp, &sf->stack.ss_sp);
425         err |= __put_user(sas_ss_flags(regs->u_regs[UREG_FP]), &sf->stack.ss_flags);
426         err |= __put_user(current->sas_ss_size, &sf->stack.ss_size);
427         
428         err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP],
429                               sizeof(struct reg_window));       
430
431         err |= copy_siginfo_to_user(&sf->info, info);
432
433         if (err)
434                 goto sigsegv;
435
436         regs->u_regs[UREG_FP] = (unsigned long) sf;
437         regs->u_regs[UREG_I0] = signo;
438         regs->u_regs[UREG_I1] = (unsigned long) &sf->info;
439         regs->u_regs[UREG_I2] = (unsigned long) &sf->regs;
440
441         regs->pc = (unsigned long) ka->sa.sa_handler;
442         regs->npc = (regs->pc + 4);
443
444         if (ka->ka_restorer)
445                 regs->u_regs[UREG_I7] = (unsigned long)ka->ka_restorer;
446         else {
447                 regs->u_regs[UREG_I7] = (unsigned long)(&(sf->insns[0]) - 2);
448
449                 /* mov __NR_sigreturn, %g1 */
450                 err |= __put_user(0x821020d8, &sf->insns[0]);
451
452                 /* t 0x10 */
453                 err |= __put_user(0x91d02010, &sf->insns[1]);
454                 if (err)
455                         goto sigsegv;
456
457                 /* Flush instruction space. */
458                 flush_sig_insns(current->mm, (unsigned long) &(sf->insns[0]));
459         }
460         return;
461
462 sigill:
463         do_exit(SIGILL);
464 sigsegv:
465         force_sigsegv(signo, current);
466 }
467
468 static inline void
469 handle_signal(unsigned long signr, struct k_sigaction *ka,
470               siginfo_t *info, sigset_t *oldset, struct pt_regs *regs)
471 {
472         if (ka->sa.sa_flags & SA_SIGINFO)
473                 setup_rt_frame(ka, regs, signr, oldset, info);
474         else
475                 setup_frame(ka, regs, signr, oldset);
476
477         spin_lock_irq(&current->sighand->siglock);
478         sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
479         if (!(ka->sa.sa_flags & SA_NOMASK))
480                 sigaddset(&current->blocked, signr);
481         recalc_sigpending();
482         spin_unlock_irq(&current->sighand->siglock);
483 }
484
485 static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs,
486                                    struct sigaction *sa)
487 {
488         switch(regs->u_regs[UREG_I0]) {
489         case ERESTART_RESTARTBLOCK:
490         case ERESTARTNOHAND:
491         no_system_call_restart:
492                 regs->u_regs[UREG_I0] = EINTR;
493                 regs->psr |= PSR_C;
494                 break;
495         case ERESTARTSYS:
496                 if (!(sa->sa_flags & SA_RESTART))
497                         goto no_system_call_restart;
498                 /* fallthrough */
499         case ERESTARTNOINTR:
500                 regs->u_regs[UREG_I0] = orig_i0;
501                 regs->pc -= 4;
502                 regs->npc -= 4;
503         }
504 }
505
506 /* Note that 'init' is a special process: it doesn't get signals it doesn't
507  * want to handle. Thus you cannot kill init even with a SIGKILL even by
508  * mistake.
509  */
510 asmlinkage void do_signal(struct pt_regs * regs, unsigned long orig_i0, int restart_syscall)
511 {
512         siginfo_t info;
513         struct sparc_deliver_cookie cookie;
514         struct k_sigaction ka;
515         int signr;
516         sigset_t *oldset;
517
518         cookie.restart_syscall = restart_syscall;
519         cookie.orig_i0 = orig_i0;
520
521         if (test_thread_flag(TIF_RESTORE_SIGMASK))
522                 oldset = &current->saved_sigmask;
523         else
524                 oldset = &current->blocked;
525
526         signr = get_signal_to_deliver(&info, &ka, regs, &cookie);
527         if (signr > 0) {
528                 if (cookie.restart_syscall)
529                         syscall_restart(cookie.orig_i0, regs, &ka.sa);
530                 handle_signal(signr, &ka, &info, oldset, regs);
531
532                 /* a signal was successfully delivered; the saved
533                  * sigmask will have been stored in the signal frame,
534                  * and will be restored by sigreturn, so we can simply
535                  * clear the TIF_RESTORE_SIGMASK flag.
536                  */
537                 if (test_thread_flag(TIF_RESTORE_SIGMASK))
538                         clear_thread_flag(TIF_RESTORE_SIGMASK);
539                 return;
540         }
541         if (cookie.restart_syscall &&
542             (regs->u_regs[UREG_I0] == ERESTARTNOHAND ||
543              regs->u_regs[UREG_I0] == ERESTARTSYS ||
544              regs->u_regs[UREG_I0] == ERESTARTNOINTR)) {
545                 /* replay the system call when we are done */
546                 regs->u_regs[UREG_I0] = cookie.orig_i0;
547                 regs->pc -= 4;
548                 regs->npc -= 4;
549         }
550         if (cookie.restart_syscall &&
551             regs->u_regs[UREG_I0] == ERESTART_RESTARTBLOCK) {
552                 regs->u_regs[UREG_G1] = __NR_restart_syscall;
553                 regs->pc -= 4;
554                 regs->npc -= 4;
555         }
556
557         /* if there's no signal to deliver, we just put the saved sigmask
558          * back
559          */
560         if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
561                 clear_thread_flag(TIF_RESTORE_SIGMASK);
562                 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
563         }
564 }
565
566 asmlinkage int
567 do_sys_sigstack(struct sigstack __user *ssptr, struct sigstack __user *ossptr,
568                 unsigned long sp)
569 {
570         int ret = -EFAULT;
571
572         /* First see if old state is wanted. */
573         if (ossptr) {
574                 if (put_user(current->sas_ss_sp + current->sas_ss_size,
575                              &ossptr->the_stack) ||
576                     __put_user(on_sig_stack(sp), &ossptr->cur_status))
577                         goto out;
578         }
579
580         /* Now see if we want to update the new state. */
581         if (ssptr) {
582                 char *ss_sp;
583
584                 if (get_user(ss_sp, &ssptr->the_stack))
585                         goto out;
586                 /* If the current stack was set with sigaltstack, don't
587                    swap stacks while we are on it.  */
588                 ret = -EPERM;
589                 if (current->sas_ss_sp && on_sig_stack(sp))
590                         goto out;
591
592                 /* Since we don't know the extent of the stack, and we don't
593                    track onstack-ness, but rather calculate it, we must
594                    presume a size.  Ho hum this interface is lossy.  */
595                 current->sas_ss_sp = (unsigned long)ss_sp - SIGSTKSZ;
596                 current->sas_ss_size = SIGSTKSZ;
597         }
598         ret = 0;
599 out:
600         return ret;
601 }
602
603 void ptrace_signal_deliver(struct pt_regs *regs, void *cookie)
604 {
605         struct sparc_deliver_cookie *cp = cookie;
606
607         if (cp->restart_syscall &&
608             (regs->u_regs[UREG_I0] == ERESTARTNOHAND ||
609              regs->u_regs[UREG_I0] == ERESTARTSYS ||
610              regs->u_regs[UREG_I0] == ERESTARTNOINTR)) {
611                 /* replay the system call when we are done */
612                 regs->u_regs[UREG_I0] = cp->orig_i0;
613                 regs->pc -= 4;
614                 regs->npc -= 4;
615                 cp->restart_syscall = 0;
616         }
617
618         if (cp->restart_syscall &&
619             regs->u_regs[UREG_I0] == ERESTART_RESTARTBLOCK) {
620                 regs->u_regs[UREG_G1] = __NR_restart_syscall;
621                 regs->pc -= 4;
622                 regs->npc -= 4;
623                 cp->restart_syscall = 0;
624         }
625 }