blob: 5b7146f54fd5814f4ba00447c04d676b4dd945cf [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* signal.c: FRV specific bits of signal handling
2 *
3 * Copyright (C) 2003-5 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 * - Derived from arch/m68k/kernel/signal.c
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#include <linux/sched.h>
14#include <linux/mm.h>
15#include <linux/smp.h>
16#include <linux/smp_lock.h>
17#include <linux/kernel.h>
18#include <linux/signal.h>
19#include <linux/errno.h>
20#include <linux/wait.h>
21#include <linux/ptrace.h>
22#include <linux/unistd.h>
23#include <linux/personality.h>
24#include <linux/suspend.h>
25#include <asm/ucontext.h>
26#include <asm/uaccess.h>
27#include <asm/cacheflush.h>
28
29#define DEBUG_SIG 0
30
31#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
32
33struct fdpic_func_descriptor {
34 unsigned long text;
35 unsigned long GOT;
36};
37
David Howellsfef2b582006-01-06 00:11:45 -080038static int do_signal(sigset_t *oldset);
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/*
41 * Atomically swap in the new signal mask, and wait for a signal.
42 */
43asmlinkage int sys_sigsuspend(int history0, int history1, old_sigset_t mask)
44{
45 sigset_t saveset;
46
47 mask &= _BLOCKABLE;
48 spin_lock_irq(&current->sighand->siglock);
49 saveset = current->blocked;
50 siginitset(&current->blocked, mask);
51 recalc_sigpending();
52 spin_unlock_irq(&current->sighand->siglock);
53
54 __frame->gr8 = -EINTR;
55 while (1) {
56 current->state = TASK_INTERRUPTIBLE;
57 schedule();
David Howellsfef2b582006-01-06 00:11:45 -080058 if (do_signal(&saveset))
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 /* return the signal number as the return value of this function
60 * - this is an utterly evil hack. syscalls should not invoke do_signal()
61 * as entry.S sets regs->gr8 to the return value of the system call
62 * - we can't just use sigpending() as we'd have to discard SIG_IGN signals
63 * and call waitpid() if SIGCHLD needed discarding
64 * - this only works on the i386 because it passes arguments to the signal
65 * handler on the stack, and the return value in EAX is effectively
66 * discarded
67 */
68 return __frame->gr8;
69 }
70}
71
72asmlinkage int sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize)
73{
74 sigset_t saveset, newset;
75
76 /* XXX: Don't preclude handling different sized sigset_t's. */
77 if (sigsetsize != sizeof(sigset_t))
78 return -EINVAL;
79
80 if (copy_from_user(&newset, unewset, sizeof(newset)))
81 return -EFAULT;
82 sigdelsetmask(&newset, ~_BLOCKABLE);
83
84 spin_lock_irq(&current->sighand->siglock);
85 saveset = current->blocked;
86 current->blocked = newset;
87 recalc_sigpending();
88 spin_unlock_irq(&current->sighand->siglock);
89
90 __frame->gr8 = -EINTR;
91 while (1) {
92 current->state = TASK_INTERRUPTIBLE;
93 schedule();
David Howellsfef2b582006-01-06 00:11:45 -080094 if (do_signal(&saveset))
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 /* return the signal number as the return value of this function
96 * - this is an utterly evil hack. syscalls should not invoke do_signal()
97 * as entry.S sets regs->gr8 to the return value of the system call
98 * - we can't just use sigpending() as we'd have to discard SIG_IGN signals
99 * and call waitpid() if SIGCHLD needed discarding
100 * - this only works on the i386 because it passes arguments to the signal
101 * handler on the stack, and the return value in EAX is effectively
102 * discarded
103 */
104 return __frame->gr8;
105 }
106}
107
108asmlinkage int sys_sigaction(int sig,
109 const struct old_sigaction __user *act,
110 struct old_sigaction __user *oact)
111{
112 struct k_sigaction new_ka, old_ka;
113 int ret;
114
115 if (act) {
116 old_sigset_t mask;
117 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
118 __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
119 __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
120 return -EFAULT;
121 __get_user(new_ka.sa.sa_flags, &act->sa_flags);
122 __get_user(mask, &act->sa_mask);
123 siginitset(&new_ka.sa.sa_mask, mask);
124 }
125
126 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
127
128 if (!ret && oact) {
129 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
130 __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
131 __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
132 return -EFAULT;
133 __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
134 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
135 }
136
137 return ret;
138}
139
140asmlinkage
141int sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss)
142{
143 return do_sigaltstack(uss, uoss, __frame->sp);
144}
145
146
147/*
148 * Do a signal return; undo the signal stack.
149 */
150
151struct sigframe
152{
153 void (*pretcode)(void);
154 int sig;
155 struct sigcontext sc;
156 unsigned long extramask[_NSIG_WORDS-1];
157 uint32_t retcode[2];
158};
159
160struct rt_sigframe
161{
162 void (*pretcode)(void);
163 int sig;
164 struct siginfo *pinfo;
165 void *puc;
166 struct siginfo info;
167 struct ucontext uc;
168 uint32_t retcode[2];
169};
170
171static int restore_sigcontext(struct sigcontext __user *sc, int *_gr8)
172{
173 struct user_context *user = current->thread.user;
174 unsigned long tbr, psr;
175
176 tbr = user->i.tbr;
177 psr = user->i.psr;
178 if (copy_from_user(user, &sc->sc_context, sizeof(sc->sc_context)))
179 goto badframe;
180 user->i.tbr = tbr;
181 user->i.psr = psr;
182
183 restore_user_regs(user);
184
185 user->i.syscallno = -1; /* disable syscall checks */
186
187 *_gr8 = user->i.gr[8];
188 return 0;
189
190 badframe:
191 return 1;
192}
193
194asmlinkage int sys_sigreturn(void)
195{
196 struct sigframe __user *frame = (struct sigframe __user *) __frame->sp;
197 sigset_t set;
198 int gr8;
199
200 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
201 goto badframe;
202 if (__get_user(set.sig[0], &frame->sc.sc_oldmask))
203 goto badframe;
204
205 if (_NSIG_WORDS > 1 &&
206 __copy_from_user(&set.sig[1], &frame->extramask, sizeof(frame->extramask)))
207 goto badframe;
208
209 sigdelsetmask(&set, ~_BLOCKABLE);
210 spin_lock_irq(&current->sighand->siglock);
211 current->blocked = set;
212 recalc_sigpending();
213 spin_unlock_irq(&current->sighand->siglock);
214
215 if (restore_sigcontext(&frame->sc, &gr8))
216 goto badframe;
217 return gr8;
218
219 badframe:
220 force_sig(SIGSEGV, current);
221 return 0;
222}
223
224asmlinkage int sys_rt_sigreturn(void)
225{
226 struct rt_sigframe __user *frame = (struct rt_sigframe __user *) __frame->sp;
227 sigset_t set;
228 int gr8;
229
230 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
231 goto badframe;
232 if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
233 goto badframe;
234
235 sigdelsetmask(&set, ~_BLOCKABLE);
236 spin_lock_irq(&current->sighand->siglock);
237 current->blocked = set;
238 recalc_sigpending();
239 spin_unlock_irq(&current->sighand->siglock);
240
241 if (restore_sigcontext(&frame->uc.uc_mcontext, &gr8))
242 goto badframe;
243
244 if (do_sigaltstack(&frame->uc.uc_stack, NULL, __frame->sp) == -EFAULT)
245 goto badframe;
246
247 return gr8;
248
249badframe:
250 force_sig(SIGSEGV, current);
251 return 0;
252}
253
254/*
255 * Set up a signal frame
256 */
257static int setup_sigcontext(struct sigcontext __user *sc, unsigned long mask)
258{
259 save_user_regs(current->thread.user);
260
261 if (copy_to_user(&sc->sc_context, current->thread.user, sizeof(sc->sc_context)) != 0)
262 goto badframe;
263
264 /* non-iBCS2 extensions.. */
265 if (__put_user(mask, &sc->sc_oldmask) < 0)
266 goto badframe;
267
268 return 0;
269
270 badframe:
271 return 1;
272}
273
274/*****************************************************************************/
275/*
276 * Determine which stack to use..
277 */
278static inline void __user *get_sigframe(struct k_sigaction *ka,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 size_t frame_size)
280{
281 unsigned long sp;
282
283 /* Default to using normal stack */
David Howellsfef2b582006-01-06 00:11:45 -0800284 sp = __frame->sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
286 /* This is the X/Open sanctioned signal stack switching. */
287 if (ka->sa.sa_flags & SA_ONSTACK) {
288 if (! on_sig_stack(sp))
289 sp = current->sas_ss_sp + current->sas_ss_size;
290 }
291
292 return (void __user *) ((sp - frame_size) & ~7UL);
David Howellsfef2b582006-01-06 00:11:45 -0800293
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294} /* end get_sigframe() */
295
296/*****************************************************************************/
297/*
298 *
299 */
David Howellsfef2b582006-01-06 00:11:45 -0800300static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301{
302 struct sigframe __user *frame;
303 int rsig;
304
David Howellsfef2b582006-01-06 00:11:45 -0800305 frame = get_sigframe(ka, sizeof(*frame));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
307 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
308 goto give_sigsegv;
309
310 rsig = sig;
311 if (sig < 32 &&
312 __current_thread_info->exec_domain &&
313 __current_thread_info->exec_domain->signal_invmap)
314 rsig = __current_thread_info->exec_domain->signal_invmap[sig];
315
316 if (__put_user(rsig, &frame->sig) < 0)
317 goto give_sigsegv;
318
319 if (setup_sigcontext(&frame->sc, set->sig[0]))
320 goto give_sigsegv;
321
322 if (_NSIG_WORDS > 1) {
323 if (__copy_to_user(frame->extramask, &set->sig[1],
324 sizeof(frame->extramask)))
325 goto give_sigsegv;
326 }
327
328 /* Set up to return from userspace. If provided, use a stub
329 * already in userspace. */
330 if (ka->sa.sa_flags & SA_RESTORER) {
331 if (__put_user(ka->sa.sa_restorer, &frame->pretcode) < 0)
332 goto give_sigsegv;
333 }
334 else {
335 /* Set up the following code on the stack:
336 * setlos #__NR_sigreturn,gr7
337 * tira gr0,0
338 */
339 if (__put_user((void (*)(void))frame->retcode, &frame->pretcode) ||
340 __put_user(0x8efc0000|__NR_sigreturn, &frame->retcode[0]) ||
341 __put_user(0xc0700000, &frame->retcode[1]))
342 goto give_sigsegv;
343
344 flush_icache_range((unsigned long) frame->retcode,
345 (unsigned long) (frame->retcode + 2));
346 }
347
348 /* set up registers for signal handler */
David Howellsfef2b582006-01-06 00:11:45 -0800349 __frame->sp = (unsigned long) frame;
350 __frame->lr = (unsigned long) &frame->retcode;
351 __frame->gr8 = sig;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
353 if (get_personality & FDPIC_FUNCPTRS) {
354 struct fdpic_func_descriptor __user *funcptr =
355 (struct fdpic_func_descriptor *) ka->sa.sa_handler;
David Howellsfef2b582006-01-06 00:11:45 -0800356 __get_user(__frame->pc, &funcptr->text);
357 __get_user(__frame->gr15, &funcptr->GOT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 } else {
David Howellsfef2b582006-01-06 00:11:45 -0800359 __frame->pc = (unsigned long) ka->sa.sa_handler;
360 __frame->gr15 = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 }
362
363 set_fs(USER_DS);
364
David Howells8efc0ab2006-01-06 00:11:44 -0800365 /* the tracer may want to single-step inside the handler */
366 if (test_thread_flag(TIF_SINGLESTEP))
367 ptrace_notify(SIGTRAP);
368
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369#if DEBUG_SIG
370 printk("SIG deliver %d (%s:%d): sp=%p pc=%lx ra=%p\n",
David Howellsfef2b582006-01-06 00:11:45 -0800371 sig, current->comm, current->pid, frame, __frame->pc,
David Howells8efc0ab2006-01-06 00:11:44 -0800372 frame->pretcode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373#endif
374
David Howells8efc0ab2006-01-06 00:11:44 -0800375 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376
377give_sigsegv:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 force_sig(SIGSEGV, current);
David Howells8efc0ab2006-01-06 00:11:44 -0800379 return 0;
380
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381} /* end setup_frame() */
382
383/*****************************************************************************/
384/*
385 *
386 */
David Howells8efc0ab2006-01-06 00:11:44 -0800387static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
David Howellsfef2b582006-01-06 00:11:45 -0800388 sigset_t *set)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389{
390 struct rt_sigframe __user *frame;
391 int rsig;
392
David Howellsfef2b582006-01-06 00:11:45 -0800393 frame = get_sigframe(ka, sizeof(*frame));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394
395 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
396 goto give_sigsegv;
397
398 rsig = sig;
399 if (sig < 32 &&
400 __current_thread_info->exec_domain &&
401 __current_thread_info->exec_domain->signal_invmap)
402 rsig = __current_thread_info->exec_domain->signal_invmap[sig];
403
404 if (__put_user(rsig, &frame->sig) ||
405 __put_user(&frame->info, &frame->pinfo) ||
406 __put_user(&frame->uc, &frame->puc))
407 goto give_sigsegv;
408
409 if (copy_siginfo_to_user(&frame->info, info))
410 goto give_sigsegv;
411
412 /* Create the ucontext. */
413 if (__put_user(0, &frame->uc.uc_flags) ||
414 __put_user(0, &frame->uc.uc_link) ||
415 __put_user((void*)current->sas_ss_sp, &frame->uc.uc_stack.ss_sp) ||
David Howellsfef2b582006-01-06 00:11:45 -0800416 __put_user(sas_ss_flags(__frame->sp), &frame->uc.uc_stack.ss_flags) ||
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417 __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size))
418 goto give_sigsegv;
419
420 if (setup_sigcontext(&frame->uc.uc_mcontext, set->sig[0]))
421 goto give_sigsegv;
422
423 if (__copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)))
424 goto give_sigsegv;
425
426 /* Set up to return from userspace. If provided, use a stub
427 * already in userspace. */
428 if (ka->sa.sa_flags & SA_RESTORER) {
429 if (__put_user(ka->sa.sa_restorer, &frame->pretcode))
430 goto give_sigsegv;
431 }
432 else {
433 /* Set up the following code on the stack:
434 * setlos #__NR_sigreturn,gr7
435 * tira gr0,0
436 */
437 if (__put_user((void (*)(void))frame->retcode, &frame->pretcode) ||
438 __put_user(0x8efc0000|__NR_rt_sigreturn, &frame->retcode[0]) ||
439 __put_user(0xc0700000, &frame->retcode[1]))
440 goto give_sigsegv;
441
442 flush_icache_range((unsigned long) frame->retcode,
443 (unsigned long) (frame->retcode + 2));
444 }
445
446 /* Set up registers for signal handler */
David Howellsfef2b582006-01-06 00:11:45 -0800447 __frame->sp = (unsigned long) frame;
448 __frame->lr = (unsigned long) &frame->retcode;
449 __frame->gr8 = sig;
450 __frame->gr9 = (unsigned long) &frame->info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451
452 if (get_personality & FDPIC_FUNCPTRS) {
453 struct fdpic_func_descriptor *funcptr =
454 (struct fdpic_func_descriptor __user *) ka->sa.sa_handler;
David Howellsfef2b582006-01-06 00:11:45 -0800455 __get_user(__frame->pc, &funcptr->text);
456 __get_user(__frame->gr15, &funcptr->GOT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 } else {
David Howellsfef2b582006-01-06 00:11:45 -0800458 __frame->pc = (unsigned long) ka->sa.sa_handler;
459 __frame->gr15 = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 }
461
462 set_fs(USER_DS);
463
David Howells8efc0ab2006-01-06 00:11:44 -0800464 /* the tracer may want to single-step inside the handler */
465 if (test_thread_flag(TIF_SINGLESTEP))
466 ptrace_notify(SIGTRAP);
467
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468#if DEBUG_SIG
469 printk("SIG deliver %d (%s:%d): sp=%p pc=%lx ra=%p\n",
David Howellsfef2b582006-01-06 00:11:45 -0800470 sig, current->comm, current->pid, frame, __frame->pc,
David Howells8efc0ab2006-01-06 00:11:44 -0800471 frame->pretcode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472#endif
473
David Howells8efc0ab2006-01-06 00:11:44 -0800474 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475
476give_sigsegv:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 force_sig(SIGSEGV, current);
David Howells8efc0ab2006-01-06 00:11:44 -0800478 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
480} /* end setup_rt_frame() */
481
482/*****************************************************************************/
483/*
484 * OK, we're invoking a handler
485 */
David Howells8efc0ab2006-01-06 00:11:44 -0800486static int handle_signal(unsigned long sig, siginfo_t *info,
David Howellsfef2b582006-01-06 00:11:45 -0800487 struct k_sigaction *ka, sigset_t *oldset)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488{
David Howells8efc0ab2006-01-06 00:11:44 -0800489 int ret;
490
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 /* Are we from a system call? */
David Howellsfef2b582006-01-06 00:11:45 -0800492 if (in_syscall(__frame)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 /* If so, check system call restarting.. */
David Howellsfef2b582006-01-06 00:11:45 -0800494 switch (__frame->gr8) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 case -ERESTART_RESTARTBLOCK:
496 case -ERESTARTNOHAND:
David Howellsfef2b582006-01-06 00:11:45 -0800497 __frame->gr8 = -EINTR;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 break;
499
500 case -ERESTARTSYS:
501 if (!(ka->sa.sa_flags & SA_RESTART)) {
David Howellsfef2b582006-01-06 00:11:45 -0800502 __frame->gr8 = -EINTR;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 break;
504 }
David Howells8efc0ab2006-01-06 00:11:44 -0800505
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 /* fallthrough */
507 case -ERESTARTNOINTR:
David Howellsfef2b582006-01-06 00:11:45 -0800508 __frame->gr8 = __frame->orig_gr8;
509 __frame->pc -= 4;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 }
511 }
512
513 /* Set up the stack frame */
514 if (ka->sa.sa_flags & SA_SIGINFO)
David Howellsfef2b582006-01-06 00:11:45 -0800515 ret = setup_rt_frame(sig, ka, info, oldset);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 else
David Howellsfef2b582006-01-06 00:11:45 -0800517 ret = setup_frame(sig, ka, oldset);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518
David Howells8efc0ab2006-01-06 00:11:44 -0800519 if (ret) {
520 spin_lock_irq(&current->sighand->siglock);
521 sigorsets(&current->blocked, &current->blocked,
522 &ka->sa.sa_mask);
523 if (!(ka->sa.sa_flags & SA_NODEFER))
524 sigaddset(&current->blocked, sig);
525 recalc_sigpending();
526 spin_unlock_irq(&current->sighand->siglock);
527 }
528
529 return ret;
530
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531} /* end handle_signal() */
532
533/*****************************************************************************/
534/*
535 * Note that 'init' is a special process: it doesn't get signals it doesn't
536 * want to handle. Thus you cannot kill init even with a SIGKILL even by
537 * mistake.
538 */
David Howellsfef2b582006-01-06 00:11:45 -0800539static int do_signal(sigset_t *oldset)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540{
541 struct k_sigaction ka;
542 siginfo_t info;
543 int signr;
544
545 /*
546 * We want the common case to go fast, which
547 * is why we may in certain cases get here from
548 * kernel mode. Just return without doing anything
549 * if so.
550 */
David Howellsfef2b582006-01-06 00:11:45 -0800551 if (!user_mode(__frame))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 return 1;
553
Christoph Lameter3e1d1d22005-06-24 23:13:50 -0700554 if (try_to_freeze())
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 goto no_signal;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556
557 if (!oldset)
558 oldset = &current->blocked;
559
David Howellsfef2b582006-01-06 00:11:45 -0800560 signr = get_signal_to_deliver(&info, &ka, __frame, NULL);
David Howells8efc0ab2006-01-06 00:11:44 -0800561 if (signr > 0)
David Howellsfef2b582006-01-06 00:11:45 -0800562 return handle_signal(signr, &info, &ka, oldset);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563
David Howells8efc0ab2006-01-06 00:11:44 -0800564no_signal:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 /* Did we come from a system call? */
David Howellsfef2b582006-01-06 00:11:45 -0800566 if (__frame->syscallno >= 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 /* Restart the system call - no handlers present */
David Howellsfef2b582006-01-06 00:11:45 -0800568 if (__frame->gr8 == -ERESTARTNOHAND ||
569 __frame->gr8 == -ERESTARTSYS ||
570 __frame->gr8 == -ERESTARTNOINTR) {
571 __frame->gr8 = __frame->orig_gr8;
572 __frame->pc -= 4;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 }
574
David Howellsfef2b582006-01-06 00:11:45 -0800575 if (__frame->gr8 == -ERESTART_RESTARTBLOCK){
576 __frame->gr8 = __NR_restart_syscall;
577 __frame->pc -= 4;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 }
579 }
580
581 return 0;
David Howells8efc0ab2006-01-06 00:11:44 -0800582
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583} /* end do_signal() */
584
585/*****************************************************************************/
586/*
587 * notification of userspace execution resumption
588 * - triggered by current->work.notify_resume
589 */
590asmlinkage void do_notify_resume(__u32 thread_info_flags)
591{
592 /* pending single-step? */
593 if (thread_info_flags & _TIF_SINGLESTEP)
594 clear_thread_flag(TIF_SINGLESTEP);
595
596 /* deal with pending signal delivery */
597 if (thread_info_flags & _TIF_SIGPENDING)
David Howellsfef2b582006-01-06 00:11:45 -0800598 do_signal(NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599
600} /* end do_notify_resume() */