import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / arch / cris / kernel / signal.c
1 /*
2  *  linux/arch/cris/kernel/signal.c
3  *
4  *  Based on arch/i386/kernel/signal.c by
5  *     Copyright (C) 1991, 1992  Linus Torvalds
6  *     1997-11-28  Modified for POSIX.1b signals by Richard Henderson *
7  *
8  *  Ideas also taken from arch/arm.
9  *
10  *  Copyright (C) 2000, 2001, 2002 Axis Communications AB
11  *
12  *  Authors:  Bjorn Wesen (bjornw@axis.com)
13  *
14  */
15
16 #include <linux/sched.h>
17 #include <linux/mm.h>
18 #include <linux/smp.h>
19 #include <linux/smp_lock.h>
20 #include <linux/kernel.h>
21 #include <linux/signal.h>
22 #include <linux/errno.h>
23 #include <linux/wait.h>
24 #include <linux/ptrace.h>
25 #include <linux/unistd.h>
26 #include <linux/stddef.h>
27
28 #include <asm/processor.h>
29 #include <asm/ucontext.h>
30 #include <asm/uaccess.h>
31
32 #define DEBUG_SIG 0
33
34 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
35
36 /* a syscall in Linux/CRIS is a break 13 instruction which is 2 bytes */
37 /* manipulate regs so that upon return, it will be re-executed */
38
39 /* We rely on that pc points to the instruction after "break 13", so the
40  * library must never do strange things like putting it in a delay slot.
41  */
42 #define RESTART_CRIS_SYS(regs) regs->r10 = regs->orig_r10; regs->irp -= 2;
43
44 int do_signal(int canrestart, sigset_t *oldset, struct pt_regs *regs);
45
46 int copy_siginfo_to_user(siginfo_t *to, siginfo_t *from)
47 {
48         if (!access_ok (VERIFY_WRITE, to, sizeof(siginfo_t)))
49                 return -EFAULT;
50         if (from->si_code < 0)
51                 return __copy_to_user(to, from, sizeof(siginfo_t));
52         else {
53                 int err;
54
55                 /* If you change siginfo_t structure, please be sure
56                    this code is fixed accordingly.
57                    It should never copy any pad contained in the structure
58                    to avoid security leaks, but must copy the generic
59                    3 ints plus the relevant union member.  */
60                 err = __put_user(from->si_signo, &to->si_signo);
61                 err |= __put_user(from->si_errno, &to->si_errno);
62                 err |= __put_user((short)from->si_code, &to->si_code);
63                 /* First 32bits of unions are always present.  */
64                 err |= __put_user(from->si_pid, &to->si_pid);
65                 switch (from->si_code >> 16) {
66                 case __SI_FAULT >> 16:
67                         err |= __put_user(from->si_addr, &to->si_addr);
68                         break;
69                 case __SI_CHLD >> 16:
70                         err |= __put_user(from->si_utime, &to->si_utime);
71                         err |= __put_user(from->si_stime, &to->si_stime);
72                         err |= __put_user(from->si_status, &to->si_status);
73                 default:
74                         err |= __put_user(from->si_uid, &to->si_uid);
75                         break;
76                 /* case __SI_RT: This is not generated by the kernel as of now.  */
77                 }
78                 return err;
79         }
80 }
81
82 /*
83  * Atomically swap in the new signal mask, and wait for a signal.  Define 
84  * dummy arguments to be able to reach the regs argument.  (Note that this
85  * arrangement relies on old_sigset_t occupying one register.)
86  */
87 int
88 sys_sigsuspend(old_sigset_t mask, long r11, long r12, long r13, long mof, 
89                long srp, struct pt_regs *regs)
90 {
91         sigset_t saveset;
92
93         mask &= _BLOCKABLE;
94         spin_lock_irq(&current->sigmask_lock);
95         saveset = current->blocked;
96         siginitset(&current->blocked, mask);
97         recalc_sigpending(current);
98         spin_unlock_irq(&current->sigmask_lock);
99
100         regs->r10 = -EINTR;
101         while (1) {
102                 current->state = TASK_INTERRUPTIBLE;
103                 schedule();
104                 if (do_signal(0, &saveset, regs))
105                         /* We will get here twice: once to call the signal
106                            handler, then again to return from the
107                            sigsuspend system call.  When calling the
108                            signal handler, R10 holds the signal number as
109                            set through do_signal.  The sigsuspend call
110                            will return with the restored value set above;
111                            always -EINTR.  */
112                         return regs->r10;
113         }
114 }
115
116 /* Define dummy arguments to be able to reach the regs argument.  (Note that
117  * this arrangement relies on size_t occupying one register.)
118  */
119 int
120 sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize, long r12, long r13, 
121                   long mof, long srp, struct pt_regs *regs)
122 {
123         sigset_t saveset, newset;
124
125         /* XXX: Don't preclude handling different sized sigset_t's.  */
126         if (sigsetsize != sizeof(sigset_t))
127                 return -EINVAL;
128
129         if (copy_from_user(&newset, unewset, sizeof(newset)))
130                 return -EFAULT;
131         sigdelsetmask(&newset, ~_BLOCKABLE);
132
133         spin_lock_irq(&current->sigmask_lock);
134         saveset = current->blocked;
135         current->blocked = newset;
136         recalc_sigpending(current);
137         spin_unlock_irq(&current->sigmask_lock);
138
139         regs->r10 = -EINTR;
140         while (1) {
141                 current->state = TASK_INTERRUPTIBLE;
142                 schedule();
143                 if (do_signal(0, &saveset, regs))
144                         /* We will get here twice: once to call the signal
145                            handler, then again to return from the
146                            sigsuspend system call.  When calling the
147                            signal handler, R10 holds the signal number as
148                            set through do_signal.  The sigsuspend call
149                            will return with the restored value set above;
150                            always -EINTR.  */
151                         return regs->r10;
152         }
153 }
154
155 int 
156 sys_sigaction(int sig, const struct old_sigaction *act,
157               struct old_sigaction *oact)
158 {
159         struct k_sigaction new_ka, old_ka;
160         int ret;
161
162         if (act) {
163                 old_sigset_t mask;
164                 if (verify_area(VERIFY_READ, act, sizeof(*act)) ||
165                     __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
166                     __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
167                         return -EFAULT;
168                 __get_user(new_ka.sa.sa_flags, &act->sa_flags);
169                 __get_user(mask, &act->sa_mask);
170                 siginitset(&new_ka.sa.sa_mask, mask);
171         }
172
173         ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
174
175         if (!ret && oact) {
176                 if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) ||
177                     __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
178                     __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
179                         return -EFAULT;
180                 __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
181                 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
182         }
183
184         return ret;
185 }
186
187 int
188 sys_sigaltstack(const stack_t *uss, stack_t *uoss)
189 {
190         return do_sigaltstack(uss, uoss, rdusp());
191 }
192
193
194 /*
195  * Do a signal return; undo the signal stack.
196  */
197
198 struct sigframe {
199         struct sigcontext sc;
200         unsigned long extramask[_NSIG_WORDS-1];
201         unsigned char retcode[8];  /* trampoline code */
202 };
203
204 struct rt_sigframe {
205         struct siginfo *pinfo;
206         void *puc;
207         struct siginfo info;
208         struct ucontext uc;
209         unsigned char retcode[8];  /* trampoline code */
210 };
211
212
213 static int
214 restore_sigcontext(struct pt_regs *regs, struct sigcontext *sc)
215 {
216         unsigned int err = 0;
217         unsigned long old_usp;
218
219         /* restore the regs from &sc->regs (same as sc, since regs is first)
220          * (sc is already checked for VERIFY_READ since the sigframe was
221          *  checked in sys_sigreturn previously)
222          */
223
224         if (__copy_from_user(regs, sc, sizeof(struct pt_regs)))
225                 goto badframe;
226
227         /* make sure the U-flag is set so user-mode cannot fool us */
228
229         regs->dccr |= 1 << 8;
230
231         /* restore the old USP as it was before we stacked the sc etc.
232          * (we cannot just pop the sigcontext since we aligned the sp and
233          *  stuff after pushing it)
234          */
235
236         err |= __get_user(old_usp, &sc->usp);
237
238         wrusp(old_usp);
239
240         /* TODO: the other ports use regs->orig_XX to disable syscall checks
241          * after this completes, but we don't use that mechanism. maybe we can
242          * use it now ? 
243          */
244
245         return err;
246
247 badframe:
248         return 1;
249 }
250
251 /* Define dummy arguments to be able to reach the regs argument.  */
252
253 asmlinkage int sys_sigreturn(long r10, long r11, long r12, long r13, long mof, 
254                              long srp, struct pt_regs *regs)
255 {
256         struct sigframe *frame = (struct sigframe *)rdusp();
257         sigset_t set;
258
259         /*
260          * Since we stacked the signal on a dword boundary,
261          * then frame should be dword aligned here.  If it's
262          * not, then the user is trying to mess with us.
263          */
264         if (((long)frame) & 3)
265                 goto badframe;
266
267         if (verify_area(VERIFY_READ, frame, sizeof(*frame)))
268                 goto badframe;
269         if (__get_user(set.sig[0], &frame->sc.oldmask)
270             || (_NSIG_WORDS > 1
271                 && __copy_from_user(&set.sig[1], &frame->extramask,
272                                     sizeof(frame->extramask))))
273                 goto badframe;
274
275         sigdelsetmask(&set, ~_BLOCKABLE);
276         spin_lock_irq(&current->sigmask_lock);
277         current->blocked = set;
278         recalc_sigpending(current);
279         spin_unlock_irq(&current->sigmask_lock);
280         
281         if (restore_sigcontext(regs, &frame->sc))
282                 goto badframe;
283
284         /* TODO: SIGTRAP when single-stepping as in arm ? */
285
286         return regs->r10;
287
288 badframe:
289         force_sig(SIGSEGV, current);
290         return 0;
291 }       
292
293 /* Define dummy arguments to be able to reach the regs argument.  */
294
295 asmlinkage int sys_rt_sigreturn(long r10, long r11, long r12, long r13, 
296                                 long mof, long srp, struct pt_regs *regs)
297 {
298         struct rt_sigframe *frame = (struct rt_sigframe *)rdusp();
299         sigset_t set;
300         stack_t st;
301
302         /*
303          * Since we stacked the signal on a dword boundary,
304          * then frame should be dword aligned here.  If it's
305          * not, then the user is trying to mess with us.
306          */
307         if (((long)frame) & 3)
308                 goto badframe;
309
310         if (verify_area(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->sigmask_lock);
317         current->blocked = set;
318         recalc_sigpending(current);
319         spin_unlock_irq(&current->sigmask_lock);
320         
321         if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
322                 goto badframe;
323
324         if (__copy_from_user(&st, &frame->uc.uc_stack, sizeof(st)))
325                 goto badframe;
326         /* It is more difficult to avoid calling this function than to
327            call it and ignore errors.  */
328         do_sigaltstack(&st, NULL, rdusp());
329
330         return regs->r10;
331
332 badframe:
333         force_sig(SIGSEGV, current);
334         return 0;
335 }       
336
337 /*
338  * Set up a signal frame.
339  */
340
341 static int
342 setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs, unsigned long mask)
343 {
344         int err = 0;
345         unsigned long usp = rdusp();
346
347         /* copy the regs. they are first in sc so we can use sc directly */
348
349         err |= __copy_to_user(sc, regs, sizeof(struct pt_regs));
350
351         /* Set the frametype to CRIS_FRAME_NORMAL for the execution of
352            the signal handler. The frametype will be restored to its previous
353            value in restore_sigcontext. */
354         regs->frametype = CRIS_FRAME_NORMAL;
355
356         /* then some other stuff */
357
358         err |= __put_user(mask, &sc->oldmask);
359
360         err |= __put_user(usp, &sc->usp);
361
362         return err;
363 }
364
365 /* figure out where we want to put the new signal frame - usually on the stack */
366
367 static inline void *
368 get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size)
369 {
370         unsigned long sp = rdusp();
371
372         /* This is the X/Open sanctioned signal stack switching.  */
373         if (ka->sa.sa_flags & SA_ONSTACK) {
374                 if (! on_sig_stack(sp))
375                         sp = current->sas_ss_sp + current->sas_ss_size;
376         }
377
378         /* make sure the frame is dword-aligned */
379
380         sp &= ~3;
381
382         return (void *)(sp - frame_size);
383 }
384
385 /* grab and setup a signal frame.
386  * 
387  * basically we stack a lot of state info, and arrange for the
388  * user-mode program to return to the kernel using either a
389  * trampoline which performs the syscall sigreturn, or a provided
390  * user-mode trampoline.
391  */
392
393 static void setup_frame(int sig, struct k_sigaction *ka,
394                         sigset_t *set, struct pt_regs * regs)
395 {
396         struct sigframe *frame;
397         unsigned long return_ip;
398         int err = 0;
399
400         frame = get_sigframe(ka, regs, sizeof(*frame));
401
402         if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
403                 goto give_sigsegv;
404
405         err |= setup_sigcontext(&frame->sc, regs, set->sig[0]);
406         if (err)
407                 goto give_sigsegv;
408
409         if (_NSIG_WORDS > 1) {
410                 err |= __copy_to_user(frame->extramask, &set->sig[1],
411                                       sizeof(frame->extramask));
412         }
413         if (err)
414                 goto give_sigsegv;
415
416         /* Set up to return from userspace.  If provided, use a stub
417            already in userspace.  */
418         if (ka->sa.sa_flags & SA_RESTORER) {
419                 return_ip = (unsigned long)ka->sa.sa_restorer;
420         } else {
421                 /* trampoline - the desired return ip is the retcode itself */
422                 return_ip = (unsigned long)&frame->retcode;
423                 /* This is movu.w __NR_sigreturn, r9; break 13; */
424                 err |= __put_user(0x9c5f,         (short *)(frame->retcode+0));
425                 err |= __put_user(__NR_sigreturn, (short *)(frame->retcode+2));
426                 err |= __put_user(0xe93d,         (short *)(frame->retcode+4));
427         }
428
429         if (err)
430                 goto give_sigsegv;
431
432         /* Set up registers for signal handler */
433
434         regs->irp = (unsigned long) ka->sa.sa_handler;  /* what we enter NOW   */
435         regs->srp = return_ip;                          /* what we enter LATER */
436         regs->r10 = sig;                                /* first argument is signo */
437
438         /* actually move the usp to reflect the stacked frame */
439
440         wrusp((unsigned long)frame);
441
442         return;
443
444 give_sigsegv:
445         if (sig == SIGSEGV)
446                 ka->sa.sa_handler = SIG_DFL;
447         force_sig(SIGSEGV, current);
448 }
449
450 static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
451                            sigset_t *set, struct pt_regs * regs)
452 {
453         struct rt_sigframe *frame;
454         unsigned long return_ip;
455         int err = 0;
456
457         frame = get_sigframe(ka, regs, sizeof(*frame));
458
459         if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
460                 goto give_sigsegv;
461
462         err |= __put_user(&frame->info, &frame->pinfo);
463         err |= __put_user(&frame->uc, &frame->puc);
464         err |= copy_siginfo_to_user(&frame->info, info);
465         if (err)
466                 goto give_sigsegv;
467
468         /* Clear all the bits of the ucontext we don't use.  */
469         err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext));
470
471         err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, set->sig[0]);
472
473         err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
474
475         if (err)
476                 goto give_sigsegv;
477
478         /* Set up to return from userspace.  If provided, use a stub
479            already in userspace.  */
480         if (ka->sa.sa_flags & SA_RESTORER) {
481                 return_ip = (unsigned long)ka->sa.sa_restorer;
482         } else {
483                 /* trampoline - the desired return ip is the retcode itself */
484                 return_ip = (unsigned long)&frame->retcode;
485                 /* This is movu.w __NR_rt_sigreturn, r9; break 13; */
486                 err |= __put_user(0x9c5f,            (short *)(frame->retcode+0));
487                 err |= __put_user(__NR_rt_sigreturn, (short *)(frame->retcode+2));
488                 err |= __put_user(0xe93d,            (short *)(frame->retcode+4));
489         }
490
491         if (err)
492                 goto give_sigsegv;
493
494         /* TODO what is the current->exec_domain stuff and invmap ? */
495
496         /* Set up registers for signal handler */
497
498         regs->irp = (unsigned long) ka->sa.sa_handler;  /* what we enter NOW   */
499         regs->srp = return_ip;                          /* what we enter LATER */
500         regs->r10 = sig;                                /* first argument is signo */
501         regs->r11 = (unsigned long) &frame->info;       /* second argument is (siginfo_t *) */
502         regs->r12 = 0;                                  /* third argument is unused */
503
504         /* actually move the usp to reflect the stacked frame */
505
506         wrusp((unsigned long)frame);
507
508         return;
509
510 give_sigsegv:
511         if (sig == SIGSEGV)
512                 ka->sa.sa_handler = SIG_DFL;
513         force_sig(SIGSEGV, current);
514 }
515
516 /*
517  * OK, we're invoking a handler
518  */     
519
520 extern inline void
521 handle_signal(int canrestart, unsigned long sig, struct k_sigaction *ka,
522               siginfo_t *info, sigset_t *oldset, struct pt_regs * regs)
523 {
524         /* Are we from a system call? */
525         if (canrestart) {
526                 /* If so, check system call restarting.. */
527                 switch (regs->r10) {
528                         case -ERESTARTNOHAND:
529                                 /* ERESTARTNOHAND means that the syscall should only be
530                                    restarted if there was no handler for the signal, and since
531                                    we only get here if there is a handler, we don't restart */
532                                 regs->r10 = -EINTR;
533                                 break;
534
535                         case -ERESTARTSYS:
536                                 /* ERESTARTSYS means to restart the syscall if there is no
537                                    handler or the handler was registered with SA_RESTART */
538                                 if (!(ka->sa.sa_flags & SA_RESTART)) {
539                                         regs->r10 = -EINTR;
540                                         break;
541                                 }
542                         /* fallthrough */
543                         case -ERESTARTNOINTR:
544                                 /* ERESTARTNOINTR means that the syscall should be called again
545                                    after the signal handler returns. */
546                                 RESTART_CRIS_SYS(regs);
547                 }
548         }
549
550         /* Set up the stack frame */
551         if (ka->sa.sa_flags & SA_SIGINFO)
552                 setup_rt_frame(sig, ka, info, oldset, regs);
553         else
554                 setup_frame(sig, ka, oldset, regs);
555
556         if (ka->sa.sa_flags & SA_ONESHOT)
557                 ka->sa.sa_handler = SIG_DFL;
558
559         if (!(ka->sa.sa_flags & SA_NODEFER)) {
560                 spin_lock_irq(&current->sigmask_lock);
561                 sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
562                 sigaddset(&current->blocked,sig);
563                 recalc_sigpending(current);
564                 spin_unlock_irq(&current->sigmask_lock);
565         }
566 }
567
568 /*
569  * Note that 'init' is a special process: it doesn't get signals it doesn't
570  * want to handle. Thus you cannot kill init even with a SIGKILL even by
571  * mistake.
572  *
573  * Also note that the regs structure given here as an argument, is the latest
574  * pushed pt_regs. It may or may not be the same as the first pushed registers
575  * when the initial usermode->kernelmode transition took place. Therefore
576  * we can use user_mode(regs) to see if we came directly from kernel or user
577  * mode below.
578  */
579
580 int do_signal(int canrestart, sigset_t *oldset, struct pt_regs *regs)
581 {
582         siginfo_t info;
583         struct k_sigaction *ka;
584
585         /*
586          * We want the common case to go fast, which
587          * is why we may in certain cases get here from
588          * kernel mode. Just return without doing anything
589          * if so.
590          */
591         if (!user_mode(regs))
592                 return 1;
593
594         if (!oldset)
595                 oldset = &current->blocked;
596
597         for (;;) {
598                 unsigned long signr;
599
600                 spin_lock_irq(&current->sigmask_lock);
601                 signr = dequeue_signal(&current->blocked, &info);
602                 spin_unlock_irq(&current->sigmask_lock);
603
604                 if (!signr)
605                         break;
606
607                 if ((current->ptrace & PT_PTRACED) && signr != SIGKILL) {
608                         /* Let the debugger run.  */
609                         current->exit_code = signr;
610                         current->state = TASK_STOPPED;
611                         notify_parent(current, SIGCHLD);
612                         schedule();
613
614                         /* We're back.  Did the debugger cancel the sig?  */
615                         if (!(signr = current->exit_code))
616                                 continue;
617                         current->exit_code = 0;
618
619                         /* The debugger continued.  Ignore SIGSTOP.  */
620                         if (signr == SIGSTOP)
621                                 continue;
622
623                         /* Update the siginfo structure.  Is this good?  */
624                         if (signr != info.si_signo) {
625                                 info.si_signo = signr;
626                                 info.si_errno = 0;
627                                 info.si_code = SI_USER;
628                                 info.si_pid = current->p_pptr->pid;
629                                 info.si_uid = current->p_pptr->uid;
630                         }
631
632                         /* If the (new) signal is now blocked, requeue it.  */
633                         if (sigismember(&current->blocked, signr)) {
634                                 send_sig_info(signr, &info, current);
635                                 continue;
636                         }
637                 }
638
639                 ka = &current->sig->action[signr-1];
640                 if (ka->sa.sa_handler == SIG_IGN) {
641                         if (signr != SIGCHLD)
642                                 continue;
643                         /* Check for SIGCHLD: it's special.  */
644                         while (sys_wait4(-1, NULL, WNOHANG, NULL) > 0)
645                                 /* nothing */;
646                         continue;
647                 }
648
649                 if (ka->sa.sa_handler == SIG_DFL) {
650                         int exit_code = signr;
651
652                         /* Init gets no signals it doesn't want.  */
653                         if (current->pid == 1)
654                                 continue;
655
656                         switch (signr) {
657                         case SIGCONT: case SIGCHLD: case SIGWINCH:
658                                 continue;
659
660                         case SIGTSTP: case SIGTTIN: case SIGTTOU:
661                                 if (is_orphaned_pgrp(current->pgrp))
662                                         continue;
663                                 /* FALLTHRU */
664
665                         case SIGSTOP:
666                                 current->state = TASK_STOPPED;
667                                 current->exit_code = signr;
668                                 if (!(current->p_pptr->sig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP))
669                                         notify_parent(current, SIGCHLD);
670                                 schedule();
671                                 continue;
672
673                         case SIGQUIT: case SIGILL: case SIGTRAP:
674                         case SIGABRT: case SIGFPE: case SIGSEGV:
675                         case SIGBUS: case SIGSYS: case SIGXCPU: case SIGXFSZ:
676                                 if (do_coredump(signr, regs))
677                                         exit_code |= 0x80;
678                                 /* FALLTHRU */
679
680                         default:
681                                 lock_kernel();
682                                 sig_exit(signr, exit_code, &info);
683                                 /* NOTREACHED */
684                         }
685                 }
686
687                 /* Whee!  Actually deliver the signal.  */
688                 handle_signal(canrestart, signr, ka, &info, oldset, regs);
689                 return 1;
690         }
691
692         /* Did we come from a system call? */
693         if (canrestart) {
694                 /* Restart the system call - no handlers present */
695                 if (regs->r10 == -ERESTARTNOHAND ||
696                     regs->r10 == -ERESTARTSYS ||
697                     regs->r10 == -ERESTARTNOINTR) {
698                         RESTART_CRIS_SYS(regs);
699                 }
700         }
701         return 0;
702 }