diff options
author | Vineet Gupta <vgupta@synopsys.com> | 2013-01-18 04:42:19 -0500 |
---|---|---|
committer | Vineet Gupta <vgupta@synopsys.com> | 2013-02-15 12:33:30 -0500 |
commit | c3581039b6c51a778a70accec53a9bb7ad9a4d32 (patch) | |
tree | 6816e82f1a59fe3d4fbf8c291d3f52598531c50c /arch/arc | |
parent | d8005e6b95268cbb50db3773d5f180c32a9434fe (diff) |
ARC: Signal handling
Includes following fixes courtesy review by Al-Viro
* Tracer poke to Callee-regs were lost
Before going off into do_signal( ) we save the user-mode callee regs
(as they are not saved by default as part of pt_regs). This is to make
sure that that a Tracer (if tracing related signal) is able to do likes
of PEEKUSR(callee-reg).
However in return path we were simply discarding the user-mode callee
regs, which would break a POKEUSR(callee-reg) from a tracer.
* Issue related to multiple syscall restarts are addressed in next patch
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Acked-by: Jonas Bonn <jonas@southpole.se>
Diffstat (limited to 'arch/arc')
-rw-r--r-- | arch/arc/Kconfig | 1 | ||||
-rw-r--r-- | arch/arc/include/asm/entry.h | 35 | ||||
-rw-r--r-- | arch/arc/include/asm/sigcontext.h | 22 | ||||
-rw-r--r-- | arch/arc/include/asm/signal.h | 27 | ||||
-rw-r--r-- | arch/arc/kernel/entry.S | 11 | ||||
-rw-r--r-- | arch/arc/kernel/signal.c | 356 |
6 files changed, 449 insertions, 3 deletions
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index a4e9806ace23..756beffd20cb 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig | |||
@@ -20,6 +20,7 @@ config ARC | |||
20 | select GENERIC_KERNEL_EXECVE | 20 | select GENERIC_KERNEL_EXECVE |
21 | select GENERIC_KERNEL_THREAD | 21 | select GENERIC_KERNEL_THREAD |
22 | select GENERIC_PENDING_IRQ if SMP | 22 | select GENERIC_PENDING_IRQ if SMP |
23 | select GENERIC_SIGALTSTACK | ||
23 | select GENERIC_SMP_IDLE_THREAD | 24 | select GENERIC_SMP_IDLE_THREAD |
24 | select HAVE_GENERIC_HARDIRQS | 25 | select HAVE_GENERIC_HARDIRQS |
25 | select MODULES_USE_ELF_RELA | 26 | select MODULES_USE_ELF_RELA |
diff --git a/arch/arc/include/asm/entry.h b/arch/arc/include/asm/entry.h index 63705b12d911..6b42bf5c45ec 100644 --- a/arch/arc/include/asm/entry.h +++ b/arch/arc/include/asm/entry.h | |||
@@ -166,6 +166,41 @@ | |||
166 | .endm | 166 | .endm |
167 | 167 | ||
168 | /*-------------------------------------------------------------- | 168 | /*-------------------------------------------------------------- |
169 | * RESTORE_CALLEE_SAVED_USER: | ||
170 | * This is called after do_signal where tracer might have changed callee regs | ||
171 | * thus we need to restore the reg file. | ||
172 | * Special case handling is required for r25 in case it is used by kernel | ||
173 | * for caching task ptr. Ptrace would have modified on-kernel-stack value of | ||
174 | * r25, which needs to be shoved back into task->thread.user_r25 where from | ||
175 | * Low level exception/ISR return code will retrieve to populate with rest of | ||
176 | * callee reg-file. | ||
177 | *-------------------------------------------------------------*/ | ||
178 | .macro RESTORE_CALLEE_SAVED_USER | ||
179 | |||
180 | add sp, sp, 4 /* skip "callee_regs->stack_place_holder" */ | ||
181 | |||
182 | #ifdef CONFIG_ARC_CURR_IN_REG | ||
183 | ld.ab r12, [sp, 4] | ||
184 | st r12, [r25, TASK_THREAD + THREAD_USER_R25] | ||
185 | #else | ||
186 | ld.ab r25, [sp, 4] | ||
187 | #endif | ||
188 | |||
189 | ld.ab r24, [sp, 4] | ||
190 | ld.ab r23, [sp, 4] | ||
191 | ld.ab r22, [sp, 4] | ||
192 | ld.ab r21, [sp, 4] | ||
193 | ld.ab r20, [sp, 4] | ||
194 | ld.ab r19, [sp, 4] | ||
195 | ld.ab r18, [sp, 4] | ||
196 | ld.ab r17, [sp, 4] | ||
197 | ld.ab r16, [sp, 4] | ||
198 | ld.ab r15, [sp, 4] | ||
199 | ld.ab r14, [sp, 4] | ||
200 | ld.ab r13, [sp, 4] | ||
201 | .endm | ||
202 | |||
203 | /*-------------------------------------------------------------- | ||
169 | * Super FAST Restore callee saved regs by simply re-adjusting SP | 204 | * Super FAST Restore callee saved regs by simply re-adjusting SP |
170 | *-------------------------------------------------------------*/ | 205 | *-------------------------------------------------------------*/ |
171 | .macro DISCARD_CALLEE_SAVED_USER | 206 | .macro DISCARD_CALLEE_SAVED_USER |
diff --git a/arch/arc/include/asm/sigcontext.h b/arch/arc/include/asm/sigcontext.h new file mode 100644 index 000000000000..9678a11fc158 --- /dev/null +++ b/arch/arc/include/asm/sigcontext.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | */ | ||
8 | |||
9 | #ifndef _ASM_ARC_SIGCONTEXT_H | ||
10 | #define _ASM_ARC_SIGCONTEXT_H | ||
11 | |||
12 | #include <asm/ptrace.h> | ||
13 | |||
14 | /* | ||
15 | * Signal context structure - contains all info to do with the state | ||
16 | * before the signal handler was invoked. | ||
17 | */ | ||
18 | struct sigcontext { | ||
19 | struct user_regs_struct regs; | ||
20 | }; | ||
21 | |||
22 | #endif /* _ASM_ARC_SIGCONTEXT_H */ | ||
diff --git a/arch/arc/include/asm/signal.h b/arch/arc/include/asm/signal.h new file mode 100644 index 000000000000..fad62f7f42d6 --- /dev/null +++ b/arch/arc/include/asm/signal.h | |||
@@ -0,0 +1,27 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * Amit Bhor, Sameer Dhavale: Codito Technologies 2004 | ||
9 | */ | ||
10 | |||
11 | #ifndef _ASM_ARC_SIGNAL_H | ||
12 | #define _ASM_ARC_SIGNAL_H | ||
13 | |||
14 | /* | ||
15 | * This is much needed for ARC sigreturn optimization. | ||
16 | * This allows uClibc to piggback the addr of a sigreturn stub in sigaction, | ||
17 | * which allows sigreturn based re-entry into kernel after handling signal. | ||
18 | * W/o this kernel needs to "synthesize" the sigreturn trampoline on user | ||
19 | * mode stack which in turn forces the following: | ||
20 | * -TLB Flush (after making the stack page executable) | ||
21 | * -Cache line Flush (to make I/D Cache lines coherent) | ||
22 | */ | ||
23 | #define SA_RESTORER 0x04000000 | ||
24 | |||
25 | #include <asm-generic/signal.h> | ||
26 | |||
27 | #endif /* _ASM_ARC_SIGNAL_H */ | ||
diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S index ed08ac14fbc4..d625b77c14bd 100644 --- a/arch/arc/kernel/entry.S +++ b/arch/arc/kernel/entry.S | |||
@@ -470,7 +470,11 @@ resume_user_mode_begin: | |||
470 | 470 | ||
471 | bbit0 r9, TIF_SIGPENDING, .Lchk_notify_resume | 471 | bbit0 r9, TIF_SIGPENDING, .Lchk_notify_resume |
472 | 472 | ||
473 | ; save CALLEE Regs. | 473 | ; Normal Trap/IRQ entry only saves Scratch (caller-saved) regs |
474 | ; in pt_reg since the "C" ABI (kernel code) will automatically | ||
475 | ; save/restore callee-saved regs. | ||
476 | ; | ||
477 | ; However, here we need to explicitly save callee regs because | ||
474 | ; (i) If this signal causes coredump - full regfile needed | 478 | ; (i) If this signal causes coredump - full regfile needed |
475 | ; (ii) If signal is SIGTRAP/SIGSTOP, task is being traced thus | 479 | ; (ii) If signal is SIGTRAP/SIGSTOP, task is being traced thus |
476 | ; tracer might call PEEKUSR(CALLEE reg) | 480 | ; tracer might call PEEKUSR(CALLEE reg) |
@@ -484,8 +488,9 @@ resume_user_mode_begin: | |||
484 | 488 | ||
485 | bl @do_signal | 489 | bl @do_signal |
486 | 490 | ||
487 | ; unwind SP for cheap discard of Callee saved Regs | 491 | ; Ideally we want to discard the Callee reg above, however if this was |
488 | DISCARD_CALLEE_SAVED_USER | 492 | ; a tracing signal, tracer could have done a POKEUSR(CALLEE reg) |
493 | RESTORE_CALLEE_SAVED_USER | ||
489 | 494 | ||
490 | b resume_user_mode_begin ; loop back to start of U mode ret | 495 | b resume_user_mode_begin ; loop back to start of U mode ret |
491 | 496 | ||
diff --git a/arch/arc/kernel/signal.c b/arch/arc/kernel/signal.c new file mode 100644 index 000000000000..ab8ed5a55461 --- /dev/null +++ b/arch/arc/kernel/signal.c | |||
@@ -0,0 +1,356 @@ | |||
1 | /* | ||
2 | * Signal Handling for ARC | ||
3 | * | ||
4 | * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * vineetg: Jan 2010 (Restarting of timer related syscalls) | ||
11 | * | ||
12 | * vineetg: Nov 2009 (Everything needed for TIF_RESTORE_SIGMASK) | ||
13 | * -do_signal() supports TIF_RESTORE_SIGMASK | ||
14 | * -do_signal() no loner needs oldset, required by OLD sys_sigsuspend | ||
15 | * -sys_rt_sigsuspend() now comes from generic code, so discard arch implemen | ||
16 | * -sys_sigsuspend() no longer needs to fudge ptregs, hence that arg removed | ||
17 | * -sys_sigsuspend() no longer loops for do_signal(), sets TIF_xxx and leaves | ||
18 | * the job to do_signal() | ||
19 | * | ||
20 | * vineetg: July 2009 | ||
21 | * -Modified Code to support the uClibc provided userland sigreturn stub | ||
22 | * to avoid kernel synthesing it on user stack at runtime, costing TLB | ||
23 | * probes and Cache line flushes. | ||
24 | * | ||
25 | * vineetg: July 2009 | ||
26 | * -In stash_usr_regs( ) and restore_usr_regs( ), save/restore of user regs | ||
27 | * in done in block copy rather than one word at a time. | ||
28 | * This saves around 2K of code and improves LMBench lat_sig <catch> | ||
29 | * | ||
30 | * rajeshwarr: Feb 2009 | ||
31 | * - Support for Realtime Signals | ||
32 | * | ||
33 | * vineetg: Aug 11th 2008: Bug #94183 | ||
34 | * -ViXS were still seeing crashes when using insmod to load drivers. | ||
35 | * It turned out that the code to change Execute permssions for TLB entries | ||
36 | * of user was not guarded for interrupts (mod_tlb_permission) | ||
37 | * This was cauing TLB entries to be overwritten on unrelated indexes | ||
38 | * | ||
39 | * Vineetg: July 15th 2008: Bug #94183 | ||
40 | * -Exception happens in Delay slot of a JMP, and before user space resumes, | ||
41 | * Signal is delivered (Ctrl + C) = >SIGINT. | ||
42 | * setup_frame( ) sets up PC,SP,BLINK to enable user space signal handler | ||
43 | * to run, but doesn't clear the Delay slot bit from status32. As a result, | ||
44 | * on resuming user mode, signal handler branches off to BTA of orig JMP | ||
45 | * -FIX: clear the DE bit from status32 in setup_frame( ) | ||
46 | * | ||
47 | * Rahul Trivedi, Kanika Nema: Codito Technologies 2004 | ||
48 | */ | ||
49 | |||
50 | #include <linux/signal.h> | ||
51 | #include <linux/ptrace.h> | ||
52 | #include <linux/personality.h> | ||
53 | #include <linux/uaccess.h> | ||
54 | #include <linux/syscalls.h> | ||
55 | #include <linux/tracehook.h> | ||
56 | #include <asm/ucontext.h> | ||
57 | |||
58 | struct rt_sigframe { | ||
59 | struct siginfo info; | ||
60 | struct ucontext uc; | ||
61 | #define MAGIC_SIGALTSTK 0x07302004 | ||
62 | unsigned int sigret_magic; | ||
63 | }; | ||
64 | |||
65 | static int | ||
66 | stash_usr_regs(struct rt_sigframe __user *sf, struct pt_regs *regs, | ||
67 | sigset_t *set) | ||
68 | { | ||
69 | int err; | ||
70 | err = __copy_to_user(&(sf->uc.uc_mcontext.regs), regs, | ||
71 | sizeof(sf->uc.uc_mcontext.regs.scratch)); | ||
72 | err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(sigset_t)); | ||
73 | |||
74 | return err; | ||
75 | } | ||
76 | |||
77 | static int restore_usr_regs(struct pt_regs *regs, struct rt_sigframe __user *sf) | ||
78 | { | ||
79 | sigset_t set; | ||
80 | int err; | ||
81 | |||
82 | err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set)); | ||
83 | if (!err) | ||
84 | set_current_blocked(&set); | ||
85 | |||
86 | err |= __copy_from_user(regs, &(sf->uc.uc_mcontext.regs), | ||
87 | sizeof(sf->uc.uc_mcontext.regs.scratch)); | ||
88 | |||
89 | return err; | ||
90 | } | ||
91 | |||
92 | static inline int is_do_ss_needed(unsigned int magic) | ||
93 | { | ||
94 | if (MAGIC_SIGALTSTK == magic) | ||
95 | return 1; | ||
96 | else | ||
97 | return 0; | ||
98 | } | ||
99 | |||
100 | SYSCALL_DEFINE0(rt_sigreturn) | ||
101 | { | ||
102 | struct rt_sigframe __user *sf; | ||
103 | unsigned int magic; | ||
104 | int err; | ||
105 | struct pt_regs *regs = current_pt_regs(); | ||
106 | |||
107 | /* Always make any pending restarted system calls return -EINTR */ | ||
108 | current_thread_info()->restart_block.fn = do_no_restart_syscall; | ||
109 | |||
110 | /* Since we stacked the signal on a word boundary, | ||
111 | * then 'sp' should be word aligned here. If it's | ||
112 | * not, then the user is trying to mess with us. | ||
113 | */ | ||
114 | if (regs->sp & 3) | ||
115 | goto badframe; | ||
116 | |||
117 | sf = (struct rt_sigframe __force __user *)(regs->sp); | ||
118 | |||
119 | if (!access_ok(VERIFY_READ, sf, sizeof(*sf))) | ||
120 | goto badframe; | ||
121 | |||
122 | err = restore_usr_regs(regs, sf); | ||
123 | err |= __get_user(magic, &sf->sigret_magic); | ||
124 | if (err) | ||
125 | goto badframe; | ||
126 | |||
127 | if (unlikely(is_do_ss_needed(magic))) | ||
128 | if (restore_altstack(&sf->uc.uc_stack)) | ||
129 | goto badframe; | ||
130 | |||
131 | return regs->r0; | ||
132 | |||
133 | badframe: | ||
134 | force_sig(SIGSEGV, current); | ||
135 | return 0; | ||
136 | } | ||
137 | |||
138 | /* | ||
139 | * Determine which stack to use.. | ||
140 | */ | ||
141 | static inline void __user *get_sigframe(struct k_sigaction *ka, | ||
142 | struct pt_regs *regs, | ||
143 | unsigned long framesize) | ||
144 | { | ||
145 | unsigned long sp = regs->sp; | ||
146 | void __user *frame; | ||
147 | |||
148 | /* This is the X/Open sanctioned signal stack switching */ | ||
149 | if ((ka->sa.sa_flags & SA_ONSTACK) && !sas_ss_flags(sp)) | ||
150 | sp = current->sas_ss_sp + current->sas_ss_size; | ||
151 | |||
152 | /* No matter what happens, 'sp' must be word | ||
153 | * aligned otherwise nasty things could happen | ||
154 | */ | ||
155 | |||
156 | /* ATPCS B01 mandates 8-byte alignment */ | ||
157 | frame = (void __user *)((sp - framesize) & ~7); | ||
158 | |||
159 | /* Check that we can actually write to the signal frame */ | ||
160 | if (!access_ok(VERIFY_WRITE, frame, framesize)) | ||
161 | frame = NULL; | ||
162 | |||
163 | return frame; | ||
164 | } | ||
165 | |||
166 | /* | ||
167 | * translate the signal | ||
168 | */ | ||
169 | static inline int map_sig(int sig) | ||
170 | { | ||
171 | struct thread_info *thread = current_thread_info(); | ||
172 | if (thread->exec_domain && thread->exec_domain->signal_invmap | ||
173 | && sig < 32) | ||
174 | sig = thread->exec_domain->signal_invmap[sig]; | ||
175 | return sig; | ||
176 | } | ||
177 | |||
178 | static int | ||
179 | setup_rt_frame(int signo, struct k_sigaction *ka, siginfo_t *info, | ||
180 | sigset_t *set, struct pt_regs *regs) | ||
181 | { | ||
182 | struct rt_sigframe __user *sf; | ||
183 | unsigned int magic = 0; | ||
184 | int err = 0; | ||
185 | |||
186 | sf = get_sigframe(ka, regs, sizeof(struct rt_sigframe)); | ||
187 | if (!sf) | ||
188 | return 1; | ||
189 | |||
190 | /* | ||
191 | * SA_SIGINFO requires 3 args to signal handler: | ||
192 | * #1: sig-no (common to any handler) | ||
193 | * #2: struct siginfo | ||
194 | * #3: struct ucontext (completely populated) | ||
195 | */ | ||
196 | if (unlikely(ka->sa.sa_flags & SA_SIGINFO)) { | ||
197 | err |= copy_siginfo_to_user(&sf->info, info); | ||
198 | err |= __put_user(0, &sf->uc.uc_flags); | ||
199 | err |= __put_user(NULL, &sf->uc.uc_link); | ||
200 | err |= __save_altstack(&sf->uc.uc_stack, regs->sp); | ||
201 | |||
202 | /* setup args 2 and 3 for user mode handler */ | ||
203 | regs->r1 = (unsigned long)&sf->info; | ||
204 | regs->r2 = (unsigned long)&sf->uc; | ||
205 | |||
206 | /* | ||
207 | * small optim to avoid unconditonally calling do_sigaltstack | ||
208 | * in sigreturn path, now that we only have rt_sigreturn | ||
209 | */ | ||
210 | magic = MAGIC_SIGALTSTK; | ||
211 | } | ||
212 | |||
213 | /* | ||
214 | * w/o SA_SIGINFO, struct ucontext is partially populated (only | ||
215 | * uc_mcontext/uc_sigmask) for kernel's normal user state preservation | ||
216 | * during signal handler execution. This works for SA_SIGINFO as well | ||
217 | * although the semantics are now overloaded (the same reg state can be | ||
218 | * inspected by userland: but are they allowed to fiddle with it ? | ||
219 | */ | ||
220 | err |= stash_usr_regs(sf, regs, set); | ||
221 | err |= __put_user(magic, &sf->sigret_magic); | ||
222 | if (err) | ||
223 | return err; | ||
224 | |||
225 | /* #1 arg to the user Signal handler */ | ||
226 | regs->r0 = map_sig(signo); | ||
227 | |||
228 | /* setup PC of user space signal handler */ | ||
229 | regs->ret = (unsigned long)ka->sa.sa_handler; | ||
230 | |||
231 | /* | ||
232 | * handler returns using sigreturn stub provided already by userpsace | ||
233 | */ | ||
234 | BUG_ON(!(ka->sa.sa_flags & SA_RESTORER)); | ||
235 | regs->blink = (unsigned long)ka->sa.sa_restorer; | ||
236 | |||
237 | /* User Stack for signal handler will be above the frame just carved */ | ||
238 | regs->sp = (unsigned long)sf; | ||
239 | |||
240 | /* | ||
241 | * Bug 94183, Clear the DE bit, so that when signal handler | ||
242 | * starts to run, it doesn't use BTA | ||
243 | */ | ||
244 | regs->status32 &= ~STATUS_DE_MASK; | ||
245 | regs->status32 |= STATUS_L_MASK; | ||
246 | |||
247 | return err; | ||
248 | } | ||
249 | |||
250 | static void arc_restart_syscall(struct k_sigaction *ka, struct pt_regs *regs) | ||
251 | { | ||
252 | switch (regs->r0) { | ||
253 | case -ERESTART_RESTARTBLOCK: | ||
254 | case -ERESTARTNOHAND: | ||
255 | /* | ||
256 | * ERESTARTNOHAND means that the syscall should | ||
257 | * only be restarted if there was no handler for | ||
258 | * the signal, and since we only get here if there | ||
259 | * is a handler, we don't restart | ||
260 | */ | ||
261 | regs->r0 = -EINTR; /* ERESTART_xxx is internal */ | ||
262 | break; | ||
263 | |||
264 | case -ERESTARTSYS: | ||
265 | /* | ||
266 | * ERESTARTSYS means to restart the syscall if | ||
267 | * there is no handler or the handler was | ||
268 | * registered with SA_RESTART | ||
269 | */ | ||
270 | if (!(ka->sa.sa_flags & SA_RESTART)) { | ||
271 | regs->r0 = -EINTR; | ||
272 | break; | ||
273 | } | ||
274 | /* fallthrough */ | ||
275 | |||
276 | case -ERESTARTNOINTR: | ||
277 | /* | ||
278 | * ERESTARTNOINTR means that the syscall should | ||
279 | * be called again after the signal handler returns. | ||
280 | * Setup reg state just as it was before doing the trap | ||
281 | * r0 has been clobbered with sys call ret code thus it | ||
282 | * needs to be reloaded with orig first arg to syscall | ||
283 | * in orig_r0. Rest of relevant reg-file: | ||
284 | * r8 (syscall num) and (r1 - r7) will be reset to | ||
285 | * their orig user space value when we ret from kernel | ||
286 | */ | ||
287 | regs->r0 = regs->orig_r0; | ||
288 | regs->ret -= 4; | ||
289 | break; | ||
290 | } | ||
291 | } | ||
292 | |||
293 | /* | ||
294 | * OK, we're invoking a handler | ||
295 | */ | ||
296 | static void | ||
297 | handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, | ||
298 | struct pt_regs *regs) | ||
299 | { | ||
300 | sigset_t *oldset = sigmask_to_save(); | ||
301 | int ret; | ||
302 | |||
303 | /* Set up the stack frame */ | ||
304 | ret = setup_rt_frame(sig, ka, info, oldset, regs); | ||
305 | |||
306 | if (ret) | ||
307 | force_sigsegv(sig, current); | ||
308 | else | ||
309 | signal_delivered(sig, info, ka, regs, 0); | ||
310 | } | ||
311 | |||
312 | void do_signal(struct pt_regs *regs) | ||
313 | { | ||
314 | struct k_sigaction ka; | ||
315 | siginfo_t info; | ||
316 | int signr; | ||
317 | int restart_scall; | ||
318 | |||
319 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | ||
320 | |||
321 | /* Are we from a system call? */ | ||
322 | restart_scall = in_syscall(regs); | ||
323 | |||
324 | if (signr > 0) { | ||
325 | if (restart_scall) | ||
326 | arc_restart_syscall(&ka, regs); | ||
327 | |||
328 | handle_signal(signr, &ka, &info, regs); | ||
329 | return; | ||
330 | } | ||
331 | |||
332 | if (restart_scall) { | ||
333 | /* No handler for syscall: restart it */ | ||
334 | if (regs->r0 == -ERESTARTNOHAND || | ||
335 | regs->r0 == -ERESTARTSYS || regs->r0 == -ERESTARTNOINTR) { | ||
336 | regs->r0 = regs->orig_r0; | ||
337 | regs->ret -= 4; | ||
338 | } else if (regs->r0 == -ERESTART_RESTARTBLOCK) { | ||
339 | regs->r8 = __NR_restart_syscall; | ||
340 | regs->ret -= 4; | ||
341 | } | ||
342 | } | ||
343 | |||
344 | /* If there's no signal to deliver, restore the saved sigmask back */ | ||
345 | restore_saved_sigmask(); | ||
346 | } | ||
347 | |||
348 | void do_notify_resume(struct pt_regs *regs) | ||
349 | { | ||
350 | /* | ||
351 | * ASM glue gaurantees that this is only called when returning to | ||
352 | * user mode | ||
353 | */ | ||
354 | if (test_and_clear_thread_flag(TIF_NOTIFY_RESUME)) | ||
355 | tracehook_notify_resume(regs); | ||
356 | } | ||