aboutsummaryrefslogtreecommitdiffstats
path: root/arch/c6x
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2013-10-06 17:09:48 -0400
committerRichard Weinberger <richard@sigma-star.at>2014-08-06 07:02:12 -0400
commite19c025bc9a184ed9c5daf06ffb89abc81d1696a (patch)
tree5249cc6e3342fcee8c4acc2f05af6f3956349d62 /arch/c6x
parent1270cff147a39f7da5b25225dca6ca3132ca6130 (diff)
c6x: Use get_signal() signal_setup_done()
Use the more generic functions get_signal() signal_setup_done() for signal delivery. Tested-by: Mark Salter <msalter@redhat.com> Acked-by: Mark Salter <msalter@redhat.com> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/c6x')
-rw-r--r--arch/c6x/kernel/signal.c43
1 files changed, 18 insertions, 25 deletions
diff --git a/arch/c6x/kernel/signal.c b/arch/c6x/kernel/signal.c
index 3998b24e26f2..8bf9aad67cee 100644
--- a/arch/c6x/kernel/signal.c
+++ b/arch/c6x/kernel/signal.c
@@ -146,21 +146,21 @@ static inline void __user *get_sigframe(struct k_sigaction *ka,
146 return (void __user *)((sp - framesize) & ~7); 146 return (void __user *)((sp - framesize) & ~7);
147} 147}
148 148
149static int setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info, 149static int setup_rt_frame(struct ksignal *ksig, sigset_t *set,
150 sigset_t *set, struct pt_regs *regs) 150 struct pt_regs *regs)
151{ 151{
152 struct rt_sigframe __user *frame; 152 struct rt_sigframe __user *frame;
153 unsigned long __user *retcode; 153 unsigned long __user *retcode;
154 int err = 0; 154 int err = 0;
155 155
156 frame = get_sigframe(ka, regs, sizeof(*frame)); 156 frame = get_sigframe(&ksig->ka, regs, sizeof(*frame));
157 157
158 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) 158 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
159 goto segv_and_exit; 159 return -EFAULT;
160 160
161 err |= __put_user(&frame->info, &frame->pinfo); 161 err |= __put_user(&frame->info, &frame->pinfo);
162 err |= __put_user(&frame->uc, &frame->puc); 162 err |= __put_user(&frame->uc, &frame->puc);
163 err |= copy_siginfo_to_user(&frame->info, info); 163 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
164 164
165 /* Clear all the bits of the ucontext we don't use. */ 165 /* Clear all the bits of the ucontext we don't use. */
166 err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext)); 166 err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext));
@@ -188,7 +188,7 @@ static int setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info,
188#undef COPY 188#undef COPY
189 189
190 if (err) 190 if (err)
191 goto segv_and_exit; 191 return -EFAULT;
192 192
193 flush_icache_range((unsigned long) &frame->retcode, 193 flush_icache_range((unsigned long) &frame->retcode,
194 (unsigned long) &frame->retcode + RETCODE_SIZE); 194 (unsigned long) &frame->retcode + RETCODE_SIZE);
@@ -198,10 +198,10 @@ static int setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info,
198 /* Change user context to branch to signal handler */ 198 /* Change user context to branch to signal handler */
199 regs->sp = (unsigned long) frame - 8; 199 regs->sp = (unsigned long) frame - 8;
200 regs->b3 = (unsigned long) retcode; 200 regs->b3 = (unsigned long) retcode;
201 regs->pc = (unsigned long) ka->sa.sa_handler; 201 regs->pc = (unsigned long) ksig->ka.sa.sa_handler;
202 202
203 /* Give the signal number to the handler */ 203 /* Give the signal number to the handler */
204 regs->a4 = signr; 204 regs->a4 = ksig->sig;
205 205
206 /* 206 /*
207 * For realtime signals we must also set the second and third 207 * For realtime signals we must also set the second and third
@@ -212,10 +212,6 @@ static int setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info,
212 regs->a6 = (unsigned long)&frame->uc; 212 regs->a6 = (unsigned long)&frame->uc;
213 213
214 return 0; 214 return 0;
215
216segv_and_exit:
217 force_sigsegv(signr, current);
218 return -EFAULT;
219} 215}
220 216
221static inline void 217static inline void
@@ -245,10 +241,11 @@ do_restart:
245/* 241/*
246 * handle the actual delivery of a signal to userspace 242 * handle the actual delivery of a signal to userspace
247 */ 243 */
248static void handle_signal(int sig, 244static void handle_signal(struct ksignal *ksig, struct pt_regs *regs,
249 siginfo_t *info, struct k_sigaction *ka, 245 int syscall)
250 struct pt_regs *regs, int syscall)
251{ 246{
247 int ret;
248
252 /* Are we from a system call? */ 249 /* Are we from a system call? */
253 if (syscall) { 250 if (syscall) {
254 /* If so, check system call restarting.. */ 251 /* If so, check system call restarting.. */
@@ -259,7 +256,7 @@ static void handle_signal(int sig,
259 break; 256 break;
260 257
261 case -ERESTARTSYS: 258 case -ERESTARTSYS:
262 if (!(ka->sa.sa_flags & SA_RESTART)) { 259 if (!(ksig->ka.sa.sa_flags & SA_RESTART)) {
263 regs->a4 = -EINTR; 260 regs->a4 = -EINTR;
264 break; 261 break;
265 } 262 }
@@ -272,9 +269,8 @@ static void handle_signal(int sig,
272 } 269 }
273 270
274 /* Set up the stack frame */ 271 /* Set up the stack frame */
275 if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs) < 0) 272 ret = setup_rt_frame(ksig, sigmask_to_save(), regs);
276 return; 273 signal_setup_done(ret, ksig, 0);
277 signal_delivered(sig, info, ka, regs, 0);
278} 274}
279 275
280/* 276/*
@@ -282,18 +278,15 @@ static void handle_signal(int sig,
282 */ 278 */
283static void do_signal(struct pt_regs *regs, int syscall) 279static void do_signal(struct pt_regs *regs, int syscall)
284{ 280{
285 struct k_sigaction ka; 281 struct ksignal ksig;
286 siginfo_t info;
287 int signr;
288 282
289 /* we want the common case to go fast, which is why we may in certain 283 /* we want the common case to go fast, which is why we may in certain
290 * cases get here from kernel mode */ 284 * cases get here from kernel mode */
291 if (!user_mode(regs)) 285 if (!user_mode(regs))
292 return; 286 return;
293 287
294 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 288 if (get_signal(&ksig)) {
295 if (signr > 0) { 289 handle_signal(&ksig, regs, syscall);
296 handle_signal(signr, &info, &ka, regs, syscall);
297 return; 290 return;
298 } 291 }
299 292