blob: 864c2f0d497bfa62800e4168cac94215bff4d128 [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/kernel.h>
17#include <linux/signal.h>
18#include <linux/errno.h>
19#include <linux/wait.h>
20#include <linux/ptrace.h>
21#include <linux/unistd.h>
22#include <linux/personality.h>
Nigel Cunningham7dfb7102006-12-06 20:34:23 -080023#include <linux/freezer.h>
David Howells4a3b9892009-06-11 13:05:24 +010024#include <linux/tracehook.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#include <asm/ucontext.h>
26#include <asm/uaccess.h>
27#include <asm/cacheflush.h>
28
29#define DEBUG_SIG 0
30
Linus Torvalds1da177e2005-04-16 15:20:36 -070031struct fdpic_func_descriptor {
32 unsigned long text;
33 unsigned long GOT;
34};
35
Linus Torvalds1da177e2005-04-16 15:20:36 -070036/*
37 * Atomically swap in the new signal mask, and wait for a signal.
38 */
39asmlinkage int sys_sigsuspend(int history0, int history1, old_sigset_t mask)
40{
Al Viro68f3f162012-05-21 21:42:32 -040041 sigset_t blocked;
42 siginitset(&blocked, mask);
43 return sigsuspend(&blocked);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044}
45
46asmlinkage int sys_sigaction(int sig,
47 const struct old_sigaction __user *act,
48 struct old_sigaction __user *oact)
49{
50 struct k_sigaction new_ka, old_ka;
51 int ret;
52
53 if (act) {
54 old_sigset_t mask;
55 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
56 __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
Al Virof0c22cd2012-04-22 17:20:02 -040057 __get_user(new_ka.sa.sa_restorer, &act->sa_restorer) ||
58 __get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
59 __get_user(mask, &act->sa_mask))
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 return -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 siginitset(&new_ka.sa.sa_mask, mask);
62 }
63
64 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
65
66 if (!ret && oact) {
67 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
68 __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
Al Virof0c22cd2012-04-22 17:20:02 -040069 __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer) ||
70 __put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
71 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask))
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 return -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 }
74
75 return ret;
76}
77
78asmlinkage
79int sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss)
80{
81 return do_sigaltstack(uss, uoss, __frame->sp);
82}
83
84
85/*
86 * Do a signal return; undo the signal stack.
87 */
88
89struct sigframe
90{
Al Viro9e4d11f2006-06-23 02:04:04 -070091 __sigrestore_t pretcode;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 int sig;
93 struct sigcontext sc;
94 unsigned long extramask[_NSIG_WORDS-1];
95 uint32_t retcode[2];
96};
97
98struct rt_sigframe
99{
Al Viro9e4d11f2006-06-23 02:04:04 -0700100 __sigrestore_t pretcode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 int sig;
Al Viro9e4d11f2006-06-23 02:04:04 -0700102 struct siginfo __user *pinfo;
103 void __user *puc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 struct siginfo info;
105 struct ucontext uc;
106 uint32_t retcode[2];
107};
108
109static int restore_sigcontext(struct sigcontext __user *sc, int *_gr8)
110{
111 struct user_context *user = current->thread.user;
112 unsigned long tbr, psr;
113
Al Viro20cd5142010-09-20 15:13:04 +0100114 /* Always make any pending restarted system calls return -EINTR */
115 current_thread_info()->restart_block.fn = do_no_restart_syscall;
116
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 tbr = user->i.tbr;
118 psr = user->i.psr;
119 if (copy_from_user(user, &sc->sc_context, sizeof(sc->sc_context)))
120 goto badframe;
121 user->i.tbr = tbr;
122 user->i.psr = psr;
123
124 restore_user_regs(user);
125
126 user->i.syscallno = -1; /* disable syscall checks */
127
128 *_gr8 = user->i.gr[8];
129 return 0;
130
131 badframe:
132 return 1;
133}
134
135asmlinkage int sys_sigreturn(void)
136{
137 struct sigframe __user *frame = (struct sigframe __user *) __frame->sp;
138 sigset_t set;
139 int gr8;
140
141 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
142 goto badframe;
143 if (__get_user(set.sig[0], &frame->sc.sc_oldmask))
144 goto badframe;
145
146 if (_NSIG_WORDS > 1 &&
147 __copy_from_user(&set.sig[1], &frame->extramask, sizeof(frame->extramask)))
148 goto badframe;
149
Matt Fleming7ebe0c52012-05-11 10:58:52 +1000150 set_current_blocked(&set);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151
152 if (restore_sigcontext(&frame->sc, &gr8))
153 goto badframe;
154 return gr8;
155
156 badframe:
157 force_sig(SIGSEGV, current);
158 return 0;
159}
160
161asmlinkage int sys_rt_sigreturn(void)
162{
163 struct rt_sigframe __user *frame = (struct rt_sigframe __user *) __frame->sp;
164 sigset_t set;
165 int gr8;
166
167 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
168 goto badframe;
169 if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
170 goto badframe;
171
Matt Fleming7ebe0c52012-05-11 10:58:52 +1000172 set_current_blocked(&set);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
174 if (restore_sigcontext(&frame->uc.uc_mcontext, &gr8))
175 goto badframe;
176
177 if (do_sigaltstack(&frame->uc.uc_stack, NULL, __frame->sp) == -EFAULT)
178 goto badframe;
179
180 return gr8;
181
182badframe:
183 force_sig(SIGSEGV, current);
184 return 0;
185}
186
187/*
188 * Set up a signal frame
189 */
190static int setup_sigcontext(struct sigcontext __user *sc, unsigned long mask)
191{
192 save_user_regs(current->thread.user);
193
194 if (copy_to_user(&sc->sc_context, current->thread.user, sizeof(sc->sc_context)) != 0)
195 goto badframe;
196
197 /* non-iBCS2 extensions.. */
198 if (__put_user(mask, &sc->sc_oldmask) < 0)
199 goto badframe;
200
201 return 0;
202
203 badframe:
204 return 1;
205}
206
207/*****************************************************************************/
208/*
209 * Determine which stack to use..
210 */
211static inline void __user *get_sigframe(struct k_sigaction *ka,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 size_t frame_size)
213{
214 unsigned long sp;
215
216 /* Default to using normal stack */
David Howellsfef2b582006-01-06 00:11:45 -0800217 sp = __frame->sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
219 /* This is the X/Open sanctioned signal stack switching. */
220 if (ka->sa.sa_flags & SA_ONSTACK) {
Laurent MEYERd09042d2006-06-23 02:05:36 -0700221 if (! sas_ss_flags(sp))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 sp = current->sas_ss_sp + current->sas_ss_size;
223 }
224
225 return (void __user *) ((sp - frame_size) & ~7UL);
David Howellsfef2b582006-01-06 00:11:45 -0800226
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227} /* end get_sigframe() */
228
229/*****************************************************************************/
230/*
231 *
232 */
David Howellsfef2b582006-01-06 00:11:45 -0800233static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234{
235 struct sigframe __user *frame;
236 int rsig;
237
Al Viro5f4ad042010-09-20 15:13:09 +0100238 set_fs(USER_DS);
239
David Howellsfef2b582006-01-06 00:11:45 -0800240 frame = get_sigframe(ka, sizeof(*frame));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241
242 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
243 goto give_sigsegv;
244
245 rsig = sig;
246 if (sig < 32 &&
247 __current_thread_info->exec_domain &&
248 __current_thread_info->exec_domain->signal_invmap)
249 rsig = __current_thread_info->exec_domain->signal_invmap[sig];
250
251 if (__put_user(rsig, &frame->sig) < 0)
252 goto give_sigsegv;
253
254 if (setup_sigcontext(&frame->sc, set->sig[0]))
255 goto give_sigsegv;
256
257 if (_NSIG_WORDS > 1) {
258 if (__copy_to_user(frame->extramask, &set->sig[1],
259 sizeof(frame->extramask)))
260 goto give_sigsegv;
261 }
262
263 /* Set up to return from userspace. If provided, use a stub
264 * already in userspace. */
265 if (ka->sa.sa_flags & SA_RESTORER) {
266 if (__put_user(ka->sa.sa_restorer, &frame->pretcode) < 0)
267 goto give_sigsegv;
268 }
269 else {
270 /* Set up the following code on the stack:
271 * setlos #__NR_sigreturn,gr7
272 * tira gr0,0
273 */
Al Viro9e4d11f2006-06-23 02:04:04 -0700274 if (__put_user((__sigrestore_t)frame->retcode, &frame->pretcode) ||
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 __put_user(0x8efc0000|__NR_sigreturn, &frame->retcode[0]) ||
276 __put_user(0xc0700000, &frame->retcode[1]))
277 goto give_sigsegv;
278
279 flush_icache_range((unsigned long) frame->retcode,
280 (unsigned long) (frame->retcode + 2));
281 }
282
Al Viro5f4ad042010-09-20 15:13:09 +0100283 /* Set up registers for the signal handler */
WANG Congecd0fa92008-04-29 00:59:15 -0700284 if (current->personality & FDPIC_FUNCPTRS) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 struct fdpic_func_descriptor __user *funcptr =
Al Viro9e4d11f2006-06-23 02:04:04 -0700286 (struct fdpic_func_descriptor __user *) ka->sa.sa_handler;
Al Viro5f4ad042010-09-20 15:13:09 +0100287 struct fdpic_func_descriptor desc;
288 if (copy_from_user(&desc, funcptr, sizeof(desc)))
289 goto give_sigsegv;
290 __frame->pc = desc.text;
291 __frame->gr15 = desc.GOT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 } else {
David Howellsfef2b582006-01-06 00:11:45 -0800293 __frame->pc = (unsigned long) ka->sa.sa_handler;
294 __frame->gr15 = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 }
296
Al Viro5f4ad042010-09-20 15:13:09 +0100297 __frame->sp = (unsigned long) frame;
298 __frame->lr = (unsigned long) &frame->retcode;
299 __frame->gr8 = sig;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300
David Howells8efc0ab2006-01-06 00:11:44 -0800301 /* the tracer may want to single-step inside the handler */
302 if (test_thread_flag(TIF_SINGLESTEP))
303 ptrace_notify(SIGTRAP);
304
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305#if DEBUG_SIG
306 printk("SIG deliver %d (%s:%d): sp=%p pc=%lx ra=%p\n",
David Howellsfef2b582006-01-06 00:11:45 -0800307 sig, current->comm, current->pid, frame, __frame->pc,
David Howells8efc0ab2006-01-06 00:11:44 -0800308 frame->pretcode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309#endif
310
David Howellsa411aee2006-01-18 17:43:59 -0800311 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312
313give_sigsegv:
Al Viroad0acab2010-09-20 15:13:14 +0100314 force_sigsegv(sig, current);
David Howellsa411aee2006-01-18 17:43:59 -0800315 return -EFAULT;
David Howells8efc0ab2006-01-06 00:11:44 -0800316
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317} /* end setup_frame() */
318
319/*****************************************************************************/
320/*
321 *
322 */
David Howells8efc0ab2006-01-06 00:11:44 -0800323static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
David Howellsfef2b582006-01-06 00:11:45 -0800324 sigset_t *set)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325{
326 struct rt_sigframe __user *frame;
327 int rsig;
328
Al Viro5f4ad042010-09-20 15:13:09 +0100329 set_fs(USER_DS);
330
David Howellsfef2b582006-01-06 00:11:45 -0800331 frame = get_sigframe(ka, sizeof(*frame));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332
333 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
334 goto give_sigsegv;
335
336 rsig = sig;
337 if (sig < 32 &&
338 __current_thread_info->exec_domain &&
339 __current_thread_info->exec_domain->signal_invmap)
340 rsig = __current_thread_info->exec_domain->signal_invmap[sig];
341
342 if (__put_user(rsig, &frame->sig) ||
343 __put_user(&frame->info, &frame->pinfo) ||
344 __put_user(&frame->uc, &frame->puc))
345 goto give_sigsegv;
346
347 if (copy_siginfo_to_user(&frame->info, info))
348 goto give_sigsegv;
349
350 /* Create the ucontext. */
351 if (__put_user(0, &frame->uc.uc_flags) ||
Al Viro9e4d11f2006-06-23 02:04:04 -0700352 __put_user(NULL, &frame->uc.uc_link) ||
353 __put_user((void __user *)current->sas_ss_sp, &frame->uc.uc_stack.ss_sp) ||
David Howellsfef2b582006-01-06 00:11:45 -0800354 __put_user(sas_ss_flags(__frame->sp), &frame->uc.uc_stack.ss_flags) ||
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size))
356 goto give_sigsegv;
357
358 if (setup_sigcontext(&frame->uc.uc_mcontext, set->sig[0]))
359 goto give_sigsegv;
360
361 if (__copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)))
362 goto give_sigsegv;
363
364 /* Set up to return from userspace. If provided, use a stub
365 * already in userspace. */
366 if (ka->sa.sa_flags & SA_RESTORER) {
367 if (__put_user(ka->sa.sa_restorer, &frame->pretcode))
368 goto give_sigsegv;
369 }
370 else {
371 /* Set up the following code on the stack:
372 * setlos #__NR_sigreturn,gr7
373 * tira gr0,0
374 */
Al Viro9e4d11f2006-06-23 02:04:04 -0700375 if (__put_user((__sigrestore_t)frame->retcode, &frame->pretcode) ||
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 __put_user(0x8efc0000|__NR_rt_sigreturn, &frame->retcode[0]) ||
377 __put_user(0xc0700000, &frame->retcode[1]))
378 goto give_sigsegv;
379
380 flush_icache_range((unsigned long) frame->retcode,
381 (unsigned long) (frame->retcode + 2));
382 }
383
384 /* Set up registers for signal handler */
WANG Congecd0fa92008-04-29 00:59:15 -0700385 if (current->personality & FDPIC_FUNCPTRS) {
Al Viro9e4d11f2006-06-23 02:04:04 -0700386 struct fdpic_func_descriptor __user *funcptr =
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 (struct fdpic_func_descriptor __user *) ka->sa.sa_handler;
Al Viro5f4ad042010-09-20 15:13:09 +0100388 struct fdpic_func_descriptor desc;
389 if (copy_from_user(&desc, funcptr, sizeof(desc)))
390 goto give_sigsegv;
391 __frame->pc = desc.text;
392 __frame->gr15 = desc.GOT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 } else {
David Howellsfef2b582006-01-06 00:11:45 -0800394 __frame->pc = (unsigned long) ka->sa.sa_handler;
395 __frame->gr15 = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396 }
397
Al Viro5f4ad042010-09-20 15:13:09 +0100398 __frame->sp = (unsigned long) frame;
399 __frame->lr = (unsigned long) &frame->retcode;
400 __frame->gr8 = sig;
401 __frame->gr9 = (unsigned long) &frame->info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402
David Howells8efc0ab2006-01-06 00:11:44 -0800403 /* the tracer may want to single-step inside the handler */
404 if (test_thread_flag(TIF_SINGLESTEP))
405 ptrace_notify(SIGTRAP);
406
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407#if DEBUG_SIG
408 printk("SIG deliver %d (%s:%d): sp=%p pc=%lx ra=%p\n",
David Howellsfef2b582006-01-06 00:11:45 -0800409 sig, current->comm, current->pid, frame, __frame->pc,
David Howells8efc0ab2006-01-06 00:11:44 -0800410 frame->pretcode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411#endif
412
David Howellsa411aee2006-01-18 17:43:59 -0800413 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414
415give_sigsegv:
Al Viroad0acab2010-09-20 15:13:14 +0100416 force_sigsegv(sig, current);
David Howellsa411aee2006-01-18 17:43:59 -0800417 return -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418
419} /* end setup_rt_frame() */
420
421/*****************************************************************************/
422/*
423 * OK, we're invoking a handler
424 */
Al Viroa610d6e2012-05-21 23:42:15 -0400425static void handle_signal(unsigned long sig, siginfo_t *info,
Al Virob7f9a112012-05-02 09:59:21 -0400426 struct k_sigaction *ka)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427{
Al Virob7f9a112012-05-02 09:59:21 -0400428 sigset_t *oldset = sigmask_to_save();
David Howells8efc0ab2006-01-06 00:11:44 -0800429 int ret;
430
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 /* Are we from a system call? */
Al Viroed1cde62010-09-20 15:13:25 +0100432 if (__frame->syscallno != -1) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 /* If so, check system call restarting.. */
David Howellsfef2b582006-01-06 00:11:45 -0800434 switch (__frame->gr8) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 case -ERESTART_RESTARTBLOCK:
436 case -ERESTARTNOHAND:
David Howellsfef2b582006-01-06 00:11:45 -0800437 __frame->gr8 = -EINTR;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 break;
439
440 case -ERESTARTSYS:
441 if (!(ka->sa.sa_flags & SA_RESTART)) {
David Howellsfef2b582006-01-06 00:11:45 -0800442 __frame->gr8 = -EINTR;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 break;
444 }
David Howells8efc0ab2006-01-06 00:11:44 -0800445
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 /* fallthrough */
447 case -ERESTARTNOINTR:
David Howellsfef2b582006-01-06 00:11:45 -0800448 __frame->gr8 = __frame->orig_gr8;
449 __frame->pc -= 4;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 }
Al Viroed1cde62010-09-20 15:13:25 +0100451 __frame->syscallno = -1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 }
453
454 /* Set up the stack frame */
455 if (ka->sa.sa_flags & SA_SIGINFO)
David Howellsfef2b582006-01-06 00:11:45 -0800456 ret = setup_rt_frame(sig, ka, info, oldset);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 else
David Howellsfef2b582006-01-06 00:11:45 -0800458 ret = setup_frame(sig, ka, oldset);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459
Al Viroa610d6e2012-05-21 23:42:15 -0400460 if (ret)
461 return;
David Howells8efc0ab2006-01-06 00:11:44 -0800462
Al Viroefee9842012-04-28 02:04:15 -0400463 signal_delivered(sig, info, ka, __frame,
Al Viroa610d6e2012-05-21 23:42:15 -0400464 test_thread_flag(TIF_SINGLESTEP));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465} /* end handle_signal() */
466
467/*****************************************************************************/
468/*
469 * Note that 'init' is a special process: it doesn't get signals it doesn't
470 * want to handle. Thus you cannot kill init even with a SIGKILL even by
471 * mistake.
472 */
David Howellsa411aee2006-01-18 17:43:59 -0800473static void do_signal(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474{
475 struct k_sigaction ka;
476 siginfo_t info;
477 int signr;
478
David Howellsfef2b582006-01-06 00:11:45 -0800479 signr = get_signal_to_deliver(&info, &ka, __frame, NULL);
David Howellsa411aee2006-01-18 17:43:59 -0800480 if (signr > 0) {
Al Viroa610d6e2012-05-21 23:42:15 -0400481 handle_signal(signr, &info, &ka);
David Howellsa411aee2006-01-18 17:43:59 -0800482 return;
483 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 /* Did we come from a system call? */
Roel Kluinc896a2e2009-10-26 16:50:23 -0700486 if (__frame->syscallno != -1) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 /* Restart the system call - no handlers present */
David Howellsa411aee2006-01-18 17:43:59 -0800488 switch (__frame->gr8) {
489 case -ERESTARTNOHAND:
490 case -ERESTARTSYS:
491 case -ERESTARTNOINTR:
David Howellsfef2b582006-01-06 00:11:45 -0800492 __frame->gr8 = __frame->orig_gr8;
493 __frame->pc -= 4;
David Howellsa411aee2006-01-18 17:43:59 -0800494 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495
David Howellsa411aee2006-01-18 17:43:59 -0800496 case -ERESTART_RESTARTBLOCK:
Al Viro44c7aff2010-09-20 15:13:19 +0100497 __frame->gr7 = __NR_restart_syscall;
David Howellsfef2b582006-01-06 00:11:45 -0800498 __frame->pc -= 4;
David Howellsa411aee2006-01-18 17:43:59 -0800499 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 }
Al Viroed1cde62010-09-20 15:13:25 +0100501 __frame->syscallno = -1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 }
503
David Howellsa411aee2006-01-18 17:43:59 -0800504 /* if there's no signal to deliver, we just put the saved sigmask
505 * back */
Al Viro51a7b442012-05-21 23:33:55 -0400506 restore_saved_sigmask();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507} /* end do_signal() */
508
509/*****************************************************************************/
510/*
511 * notification of userspace execution resumption
David Howellsa411aee2006-01-18 17:43:59 -0800512 * - triggered by the TIF_WORK_MASK flags
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 */
514asmlinkage void do_notify_resume(__u32 thread_info_flags)
515{
516 /* pending single-step? */
517 if (thread_info_flags & _TIF_SINGLESTEP)
518 clear_thread_flag(TIF_SINGLESTEP);
519
520 /* deal with pending signal delivery */
Geert Uytterhoevena3936242012-06-02 13:08:39 +0200521 if (thread_info_flags & _TIF_SIGPENDING)
David Howellsa411aee2006-01-18 17:43:59 -0800522 do_signal();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523
David Howellsb7bab882009-06-11 13:05:14 +0100524 /* deal with notification on about to resume userspace execution */
525 if (thread_info_flags & _TIF_NOTIFY_RESUME) {
526 clear_thread_flag(TIF_NOTIFY_RESUME);
David Howells4a3b9892009-06-11 13:05:24 +0100527 tracehook_notify_resume(__frame);
David Howellsb7bab882009-06-11 13:05:14 +0100528 }
529
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530} /* end do_notify_resume() */