aboutsummaryrefslogtreecommitdiffstats
path: root/arch/cris/arch-v10
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2013-10-07 06:56:24 -0400
committerRichard Weinberger <richard@sigma-star.at>2014-08-06 07:02:13 -0400
commitfa0197722eb7559a6a9733881bbb8d9e76364f33 (patch)
treebd7f998a6f8038a93215a2522669abc7d65577ff /arch/cris/arch-v10
parente19c025bc9a184ed9c5daf06ffb89abc81d1696a (diff)
cris: Use get_signal() signal_setup_done()
Use the more generic functions get_signal() signal_setup_done() for signal delivery. Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/cris/arch-v10')
-rw-r--r--arch/cris/arch-v10/kernel/signal.c79
1 files changed, 33 insertions, 46 deletions
diff --git a/arch/cris/arch-v10/kernel/signal.c b/arch/cris/arch-v10/kernel/signal.c
index 61ce6273a895..12aac1fb48df 100644
--- a/arch/cris/arch-v10/kernel/signal.c
+++ b/arch/cris/arch-v10/kernel/signal.c
@@ -228,33 +228,33 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)
228 * user-mode trampoline. 228 * user-mode trampoline.
229 */ 229 */
230 230
231static int setup_frame(int sig, struct k_sigaction *ka, 231static int setup_frame(struct ksignal *ksig, sigset_t *set,
232 sigset_t *set, struct pt_regs *regs) 232 struct pt_regs *regs)
233{ 233{
234 struct sigframe __user *frame; 234 struct sigframe __user *frame;
235 unsigned long return_ip; 235 unsigned long return_ip;
236 int err = 0; 236 int err = 0;
237 237
238 frame = get_sigframe(ka, regs, sizeof(*frame)); 238 frame = get_sigframe(&ksig->ka, regs, sizeof(*frame));
239 239
240 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) 240 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
241 goto give_sigsegv; 241 return -EFAULT;
242 242
243 err |= setup_sigcontext(&frame->sc, regs, set->sig[0]); 243 err |= setup_sigcontext(&frame->sc, regs, set->sig[0]);
244 if (err) 244 if (err)
245 goto give_sigsegv; 245 return -EFAULT;
246 246
247 if (_NSIG_WORDS > 1) { 247 if (_NSIG_WORDS > 1) {
248 err |= __copy_to_user(frame->extramask, &set->sig[1], 248 err |= __copy_to_user(frame->extramask, &set->sig[1],
249 sizeof(frame->extramask)); 249 sizeof(frame->extramask));
250 } 250 }
251 if (err) 251 if (err)
252 goto give_sigsegv; 252 return -EFAULT;
253 253
254 /* Set up to return from userspace. If provided, use a stub 254 /* Set up to return from userspace. If provided, use a stub
255 already in userspace. */ 255 already in userspace. */
256 if (ka->sa.sa_flags & SA_RESTORER) { 256 if (ksig->ka.sa.sa_flags & SA_RESTORER) {
257 return_ip = (unsigned long)ka->sa.sa_restorer; 257 return_ip = (unsigned long)ksig->ka.sa.sa_restorer;
258 } else { 258 } else {
259 /* trampoline - the desired return ip is the retcode itself */ 259 /* trampoline - the desired return ip is the retcode itself */
260 return_ip = (unsigned long)&frame->retcode; 260 return_ip = (unsigned long)&frame->retcode;
@@ -265,42 +265,38 @@ static int setup_frame(int sig, struct k_sigaction *ka,
265 } 265 }
266 266
267 if (err) 267 if (err)
268 goto give_sigsegv; 268 return -EFAULT;
269 269
270 /* Set up registers for signal handler */ 270 /* Set up registers for signal handler */
271 271
272 regs->irp = (unsigned long) ka->sa.sa_handler; /* what we enter NOW */ 272 regs->irp = (unsigned long) ksig->ka.sa.sa_handler; /* what we enter NOW */
273 regs->srp = return_ip; /* what we enter LATER */ 273 regs->srp = return_ip; /* what we enter LATER */
274 regs->r10 = sig; /* first argument is signo */ 274 regs->r10 = ksig->sig; /* first argument is signo */
275 275
276 /* actually move the usp to reflect the stacked frame */ 276 /* actually move the usp to reflect the stacked frame */
277 277
278 wrusp((unsigned long)frame); 278 wrusp((unsigned long)frame);
279 279
280 return 0; 280 return 0;
281
282give_sigsegv:
283 force_sigsegv(sig, current);
284 return -EFAULT;
285} 281}
286 282
287static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, 283static int setup_rt_frame(struct ksignal *ksig, sigset_t *set,
288 sigset_t *set, struct pt_regs *regs) 284 struct pt_regs *regs)
289{ 285{
290 struct rt_sigframe __user *frame; 286 struct rt_sigframe __user *frame;
291 unsigned long return_ip; 287 unsigned long return_ip;
292 int err = 0; 288 int err = 0;
293 289
294 frame = get_sigframe(ka, regs, sizeof(*frame)); 290 frame = get_sigframe(&ksig->ka, regs, sizeof(*frame));
295 291
296 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) 292 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
297 goto give_sigsegv; 293 return -EFAULT;
298 294
299 err |= __put_user(&frame->info, &frame->pinfo); 295 err |= __put_user(&frame->info, &frame->pinfo);
300 err |= __put_user(&frame->uc, &frame->puc); 296 err |= __put_user(&frame->uc, &frame->puc);
301 err |= copy_siginfo_to_user(&frame->info, info); 297 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
302 if (err) 298 if (err)
303 goto give_sigsegv; 299 return -EFAULT;
304 300
305 /* Clear all the bits of the ucontext we don't use. */ 301 /* Clear all the bits of the ucontext we don't use. */
306 err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext)); 302 err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext));
@@ -312,12 +308,12 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
312 err |= __save_altstack(&frame->uc.uc_stack, rdusp()); 308 err |= __save_altstack(&frame->uc.uc_stack, rdusp());
313 309
314 if (err) 310 if (err)
315 goto give_sigsegv; 311 return -EFAULT;
316 312
317 /* Set up to return from userspace. If provided, use a stub 313 /* Set up to return from userspace. If provided, use a stub
318 already in userspace. */ 314 already in userspace. */
319 if (ka->sa.sa_flags & SA_RESTORER) { 315 if (ksig->ka.sa.sa_flags & SA_RESTORER) {
320 return_ip = (unsigned long)ka->sa.sa_restorer; 316 return_ip = (unsigned long)ksig->ka.sa.sa_restorer;
321 } else { 317 } else {
322 /* trampoline - the desired return ip is the retcode itself */ 318 /* trampoline - the desired return ip is the retcode itself */
323 return_ip = (unsigned long)&frame->retcode; 319 return_ip = (unsigned long)&frame->retcode;
@@ -329,18 +325,18 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
329 } 325 }
330 326
331 if (err) 327 if (err)
332 goto give_sigsegv; 328 return -EFAULT;
333 329
334 /* TODO what is the current->exec_domain stuff and invmap ? */ 330 /* TODO what is the current->exec_domain stuff and invmap ? */
335 331
336 /* Set up registers for signal handler */ 332 /* Set up registers for signal handler */
337 333
338 /* What we enter NOW */ 334 /* What we enter NOW */
339 regs->irp = (unsigned long) ka->sa.sa_handler; 335 regs->irp = (unsigned long) ksig->ka.sa.sa_handler;
340 /* What we enter LATER */ 336 /* What we enter LATER */
341 regs->srp = return_ip; 337 regs->srp = return_ip;
342 /* First argument is signo */ 338 /* First argument is signo */
343 regs->r10 = sig; 339 regs->r10 = ksig->sig;
344 /* Second argument is (siginfo_t *) */ 340 /* Second argument is (siginfo_t *) */
345 regs->r11 = (unsigned long)&frame->info; 341 regs->r11 = (unsigned long)&frame->info;
346 /* Third argument is unused */ 342 /* Third argument is unused */
@@ -350,19 +346,14 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
350 wrusp((unsigned long)frame); 346 wrusp((unsigned long)frame);
351 347
352 return 0; 348 return 0;
353
354give_sigsegv:
355 force_sigsegv(sig, current);
356 return -EFAULT;
357} 349}
358 350
359/* 351/*
360 * OK, we're invoking a handler 352 * OK, we're invoking a handler
361 */ 353 */
362 354
363static inline void handle_signal(int canrestart, unsigned long sig, 355static inline void handle_signal(int canrestart, struct ksignal *ksig,
364 siginfo_t *info, struct k_sigaction *ka, 356 struct pt_regs *regs)
365 struct pt_regs *regs)
366{ 357{
367 sigset_t *oldset = sigmask_to_save(); 358 sigset_t *oldset = sigmask_to_save();
368 int ret; 359 int ret;
@@ -383,7 +374,7 @@ static inline void handle_signal(int canrestart, unsigned long sig,
383 /* ERESTARTSYS means to restart the syscall if 374 /* ERESTARTSYS means to restart the syscall if
384 * there is no handler or the handler was 375 * there is no handler or the handler was
385 * registered with SA_RESTART */ 376 * registered with SA_RESTART */
386 if (!(ka->sa.sa_flags & SA_RESTART)) { 377 if (!(ksig->ka.sa.sa_flags & SA_RESTART)) {
387 regs->r10 = -EINTR; 378 regs->r10 = -EINTR;
388 break; 379 break;
389 } 380 }
@@ -396,13 +387,12 @@ static inline void handle_signal(int canrestart, unsigned long sig,
396 } 387 }
397 388
398 /* Set up the stack frame */ 389 /* Set up the stack frame */
399 if (ka->sa.sa_flags & SA_SIGINFO) 390 if (ksig->ka.sa.sa_flags & SA_SIGINFO)
400 ret = setup_rt_frame(sig, ka, info, oldset, regs); 391 ret = setup_rt_frame(ksig, oldset, regs);
401 else 392 else
402 ret = setup_frame(sig, ka, oldset, regs); 393 ret = setup_frame(ksig, oldset, regs);
403 394
404 if (ret == 0) 395 signal_setup_done(ret, ksig, 0);
405 signal_delivered(sig, info, ka, regs, 0);
406} 396}
407 397
408/* 398/*
@@ -419,9 +409,7 @@ static inline void handle_signal(int canrestart, unsigned long sig,
419 409
420void do_signal(int canrestart, struct pt_regs *regs) 410void do_signal(int canrestart, struct pt_regs *regs)
421{ 411{
422 siginfo_t info; 412 struct ksignal ksig;
423 int signr;
424 struct k_sigaction ka;
425 413
426 /* 414 /*
427 * We want the common case to go fast, which 415 * We want the common case to go fast, which
@@ -432,10 +420,9 @@ void do_signal(int canrestart, struct pt_regs *regs)
432 if (!user_mode(regs)) 420 if (!user_mode(regs))
433 return; 421 return;
434 422
435 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 423 if (get_signal(&ksig)) {
436 if (signr > 0) {
437 /* Whee! Actually deliver the signal. */ 424 /* Whee! Actually deliver the signal. */
438 handle_signal(canrestart, signr, &info, &ka, regs); 425 handle_signal(canrestart, &ksig, regs);
439 return; 426 return;
440 } 427 }
441 428