aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2013-10-06 16:25:42 -0400
committerRichard Weinberger <richard@sigma-star.at>2014-08-06 07:03:08 -0400
commit81d103bf80678669c56658185e758fc3f9845d71 (patch)
tree0d72c700ebdebc6547ea3bfc5cfa2e63b075a974 /arch/mips/kernel
parent9c53c7ec14a5738ae3117d7d71b7abf630526c9f (diff)
mips: 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/mips/kernel')
-rw-r--r--arch/mips/kernel/signal-common.h2
-rw-r--r--arch/mips/kernel/signal.c66
-rw-r--r--arch/mips/kernel/signal32.c39
-rw-r--r--arch/mips/kernel/signal_n32.c20
4 files changed, 49 insertions, 78 deletions
diff --git a/arch/mips/kernel/signal-common.h b/arch/mips/kernel/signal-common.h
index 9c60d09e62a7..06805e09bcd3 100644
--- a/arch/mips/kernel/signal-common.h
+++ b/arch/mips/kernel/signal-common.h
@@ -22,7 +22,7 @@
22/* 22/*
23 * Determine which stack to use.. 23 * Determine which stack to use..
24 */ 24 */
25extern void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, 25extern void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
26 size_t frame_size); 26 size_t frame_size);
27/* Check and clear pending FPU exceptions in saved CSR */ 27/* Check and clear pending FPU exceptions in saved CSR */
28extern int fpcsr_pending(unsigned int __user *fpcsr); 28extern int fpcsr_pending(unsigned int __user *fpcsr);
diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
index 9e60d117e41e..da4baac8652c 100644
--- a/arch/mips/kernel/signal.c
+++ b/arch/mips/kernel/signal.c
@@ -428,20 +428,20 @@ badframe:
428} 428}
429 429
430#ifdef CONFIG_TRAD_SIGNALS 430#ifdef CONFIG_TRAD_SIGNALS
431static int setup_frame(void *sig_return, struct k_sigaction *ka, 431static int setup_frame(void *sig_return, struct ksignal *ksig,
432 struct pt_regs *regs, int signr, sigset_t *set) 432 struct pt_regs *regs, sigset_t *set)
433{ 433{
434 struct sigframe __user *frame; 434 struct sigframe __user *frame;
435 int err = 0; 435 int err = 0;
436 436
437 frame = get_sigframe(ka, regs, sizeof(*frame)); 437 frame = get_sigframe(&ksig->ka, regs, sizeof(*frame));
438 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) 438 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
439 goto give_sigsegv; 439 return -EFAULT;
440 440
441 err |= setup_sigcontext(regs, &frame->sf_sc); 441 err |= setup_sigcontext(regs, &frame->sf_sc);
442 err |= __copy_to_user(&frame->sf_mask, set, sizeof(*set)); 442 err |= __copy_to_user(&frame->sf_mask, set, sizeof(*set));
443 if (err) 443 if (err)
444 goto give_sigsegv; 444 return -EFAULT;
445 445
446 /* 446 /*
447 * Arguments to signal handler: 447 * Arguments to signal handler:
@@ -453,37 +453,32 @@ static int setup_frame(void *sig_return, struct k_sigaction *ka,
453 * $25 and c0_epc point to the signal handler, $29 points to the 453 * $25 and c0_epc point to the signal handler, $29 points to the
454 * struct sigframe. 454 * struct sigframe.
455 */ 455 */
456 regs->regs[ 4] = signr; 456 regs->regs[ 4] = ksig->sig;
457 regs->regs[ 5] = 0; 457 regs->regs[ 5] = 0;
458 regs->regs[ 6] = (unsigned long) &frame->sf_sc; 458 regs->regs[ 6] = (unsigned long) &frame->sf_sc;
459 regs->regs[29] = (unsigned long) frame; 459 regs->regs[29] = (unsigned long) frame;
460 regs->regs[31] = (unsigned long) sig_return; 460 regs->regs[31] = (unsigned long) sig_return;
461 regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler; 461 regs->cp0_epc = regs->regs[25] = (unsigned long) ksig->ka.sa.sa_handler;
462 462
463 DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n", 463 DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n",
464 current->comm, current->pid, 464 current->comm, current->pid,
465 frame, regs->cp0_epc, regs->regs[31]); 465 frame, regs->cp0_epc, regs->regs[31]);
466 return 0; 466 return 0;
467
468give_sigsegv:
469 force_sigsegv(signr, current);
470 return -EFAULT;
471} 467}
472#endif 468#endif
473 469
474static int setup_rt_frame(void *sig_return, struct k_sigaction *ka, 470static int setup_rt_frame(void *sig_return, struct ksignal *ksig,
475 struct pt_regs *regs, int signr, sigset_t *set, 471 struct pt_regs *regs, sigset_t *set)
476 siginfo_t *info)
477{ 472{
478 struct rt_sigframe __user *frame; 473 struct rt_sigframe __user *frame;
479 int err = 0; 474 int err = 0;
480 475
481 frame = get_sigframe(ka, regs, sizeof(*frame)); 476 frame = get_sigframe(&ksig->ka, regs, sizeof(*frame));
482 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) 477 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
483 goto give_sigsegv; 478 return -EFAULT;
484 479
485 /* Create siginfo. */ 480 /* Create siginfo. */
486 err |= copy_siginfo_to_user(&frame->rs_info, info); 481 err |= copy_siginfo_to_user(&frame->rs_info, &ksig->info);
487 482
488 /* Create the ucontext. */ 483 /* Create the ucontext. */
489 err |= __put_user(0, &frame->rs_uc.uc_flags); 484 err |= __put_user(0, &frame->rs_uc.uc_flags);
@@ -493,7 +488,7 @@ static int setup_rt_frame(void *sig_return, struct k_sigaction *ka,
493 err |= __copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set)); 488 err |= __copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set));
494 489
495 if (err) 490 if (err)
496 goto give_sigsegv; 491 return -EFAULT;
497 492
498 /* 493 /*
499 * Arguments to signal handler: 494 * Arguments to signal handler:
@@ -505,22 +500,18 @@ static int setup_rt_frame(void *sig_return, struct k_sigaction *ka,
505 * $25 and c0_epc point to the signal handler, $29 points to 500 * $25 and c0_epc point to the signal handler, $29 points to
506 * the struct rt_sigframe. 501 * the struct rt_sigframe.
507 */ 502 */
508 regs->regs[ 4] = signr; 503 regs->regs[ 4] = ksig->sig;
509 regs->regs[ 5] = (unsigned long) &frame->rs_info; 504 regs->regs[ 5] = (unsigned long) &frame->rs_info;
510 regs->regs[ 6] = (unsigned long) &frame->rs_uc; 505 regs->regs[ 6] = (unsigned long) &frame->rs_uc;
511 regs->regs[29] = (unsigned long) frame; 506 regs->regs[29] = (unsigned long) frame;
512 regs->regs[31] = (unsigned long) sig_return; 507 regs->regs[31] = (unsigned long) sig_return;
513 regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler; 508 regs->cp0_epc = regs->regs[25] = (unsigned long) ksig->ka.sa.sa_handler;
514 509
515 DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n", 510 DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n",
516 current->comm, current->pid, 511 current->comm, current->pid,
517 frame, regs->cp0_epc, regs->regs[31]); 512 frame, regs->cp0_epc, regs->regs[31]);
518 513
519 return 0; 514 return 0;
520
521give_sigsegv:
522 force_sigsegv(signr, current);
523 return -EFAULT;
524} 515}
525 516
526struct mips_abi mips_abi = { 517struct mips_abi mips_abi = {
@@ -534,8 +525,7 @@ struct mips_abi mips_abi = {
534 .restart = __NR_restart_syscall 525 .restart = __NR_restart_syscall
535}; 526};
536 527
537static void handle_signal(unsigned long sig, siginfo_t *info, 528static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
538 struct k_sigaction *ka, struct pt_regs *regs)
539{ 529{
540 sigset_t *oldset = sigmask_to_save(); 530 sigset_t *oldset = sigmask_to_save();
541 int ret; 531 int ret;
@@ -557,7 +547,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info,
557 regs->regs[2] = EINTR; 547 regs->regs[2] = EINTR;
558 break; 548 break;
559 case ERESTARTSYS: 549 case ERESTARTSYS:
560 if (!(ka->sa.sa_flags & SA_RESTART)) { 550 if (!(ksig->ka.sa.sa_flags & SA_RESTART)) {
561 regs->regs[2] = EINTR; 551 regs->regs[2] = EINTR;
562 break; 552 break;
563 } 553 }
@@ -571,29 +561,23 @@ static void handle_signal(unsigned long sig, siginfo_t *info,
571 regs->regs[0] = 0; /* Don't deal with this again. */ 561 regs->regs[0] = 0; /* Don't deal with this again. */
572 } 562 }
573 563
574 if (sig_uses_siginfo(ka)) 564 if (sig_uses_siginfo(&ksig->ka))
575 ret = abi->setup_rt_frame(vdso + abi->rt_signal_return_offset, 565 ret = abi->setup_rt_frame(vdso + abi->rt_signal_return_offset,
576 ka, regs, sig, oldset, info); 566 ksig, regs, oldset);
577 else 567 else
578 ret = abi->setup_frame(vdso + abi->signal_return_offset, 568 ret = abi->setup_frame(vdso + abi->signal_return_offset, ksig,
579 ka, regs, sig, oldset); 569 regs, oldset);
580
581 if (ret)
582 return;
583 570
584 signal_delivered(sig, info, ka, regs, 0); 571 signal_setup_done(ret, ksig, 0);
585} 572}
586 573
587static void do_signal(struct pt_regs *regs) 574static void do_signal(struct pt_regs *regs)
588{ 575{
589 struct k_sigaction ka; 576 struct ksignal ksig;
590 siginfo_t info;
591 int signr;
592 577
593 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 578 if (get_signal(&ksig)) {
594 if (signr > 0) {
595 /* Whee! Actually deliver the signal. */ 579 /* Whee! Actually deliver the signal. */
596 handle_signal(signr, &info, &ka, regs); 580 handle_signal(&ksig, regs);
597 return; 581 return;
598 } 582 }
599 583
diff --git a/arch/mips/kernel/signal32.c b/arch/mips/kernel/signal32.c
index bae2e6ee2109..eb8d0e26404d 100644
--- a/arch/mips/kernel/signal32.c
+++ b/arch/mips/kernel/signal32.c
@@ -490,21 +490,21 @@ badframe:
490 force_sig(SIGSEGV, current); 490 force_sig(SIGSEGV, current);
491} 491}
492 492
493static int setup_frame_32(void *sig_return, struct k_sigaction *ka, 493static int setup_frame_32(void *sig_return, struct ksignal *ksig,
494 struct pt_regs *regs, int signr, sigset_t *set) 494 struct pt_regs *regs, sigset_t *set)
495{ 495{
496 struct sigframe32 __user *frame; 496 struct sigframe32 __user *frame;
497 int err = 0; 497 int err = 0;
498 498
499 frame = get_sigframe(ka, regs, sizeof(*frame)); 499 frame = get_sigframe(&ksig->ka, regs, sizeof(*frame));
500 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) 500 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
501 goto give_sigsegv; 501 return -EFAULT;
502 502
503 err |= setup_sigcontext32(regs, &frame->sf_sc); 503 err |= setup_sigcontext32(regs, &frame->sf_sc);
504 err |= __copy_conv_sigset_to_user(&frame->sf_mask, set); 504 err |= __copy_conv_sigset_to_user(&frame->sf_mask, set);
505 505
506 if (err) 506 if (err)
507 goto give_sigsegv; 507 return -EFAULT;
508 508
509 /* 509 /*
510 * Arguments to signal handler: 510 * Arguments to signal handler:
@@ -516,37 +516,32 @@ static int setup_frame_32(void *sig_return, struct k_sigaction *ka,
516 * $25 and c0_epc point to the signal handler, $29 points to the 516 * $25 and c0_epc point to the signal handler, $29 points to the
517 * struct sigframe. 517 * struct sigframe.
518 */ 518 */
519 regs->regs[ 4] = signr; 519 regs->regs[ 4] = ksig->sig;
520 regs->regs[ 5] = 0; 520 regs->regs[ 5] = 0;
521 regs->regs[ 6] = (unsigned long) &frame->sf_sc; 521 regs->regs[ 6] = (unsigned long) &frame->sf_sc;
522 regs->regs[29] = (unsigned long) frame; 522 regs->regs[29] = (unsigned long) frame;
523 regs->regs[31] = (unsigned long) sig_return; 523 regs->regs[31] = (unsigned long) sig_return;
524 regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler; 524 regs->cp0_epc = regs->regs[25] = (unsigned long) ksig->ka.sa.sa_handler;
525 525
526 DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n", 526 DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n",
527 current->comm, current->pid, 527 current->comm, current->pid,
528 frame, regs->cp0_epc, regs->regs[31]); 528 frame, regs->cp0_epc, regs->regs[31]);
529 529
530 return 0; 530 return 0;
531
532give_sigsegv:
533 force_sigsegv(signr, current);
534 return -EFAULT;
535} 531}
536 532
537static int setup_rt_frame_32(void *sig_return, struct k_sigaction *ka, 533static int setup_rt_frame_32(void *sig_return, struct ksignal *ksig,
538 struct pt_regs *regs, int signr, sigset_t *set, 534 struct pt_regs *regs, sigset_t *set)
539 siginfo_t *info)
540{ 535{
541 struct rt_sigframe32 __user *frame; 536 struct rt_sigframe32 __user *frame;
542 int err = 0; 537 int err = 0;
543 538
544 frame = get_sigframe(ka, regs, sizeof(*frame)); 539 frame = get_sigframe(&ksig->ka, regs, sizeof(*frame));
545 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) 540 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
546 goto give_sigsegv; 541 return -EFAULT;
547 542
548 /* Convert (siginfo_t -> compat_siginfo_t) and copy to user. */ 543 /* Convert (siginfo_t -> compat_siginfo_t) and copy to user. */
549 err |= copy_siginfo_to_user32(&frame->rs_info, info); 544 err |= copy_siginfo_to_user32(&frame->rs_info, &ksig->info);
550 545
551 /* Create the ucontext. */ 546 /* Create the ucontext. */
552 err |= __put_user(0, &frame->rs_uc.uc_flags); 547 err |= __put_user(0, &frame->rs_uc.uc_flags);
@@ -556,7 +551,7 @@ static int setup_rt_frame_32(void *sig_return, struct k_sigaction *ka,
556 err |= __copy_conv_sigset_to_user(&frame->rs_uc.uc_sigmask, set); 551 err |= __copy_conv_sigset_to_user(&frame->rs_uc.uc_sigmask, set);
557 552
558 if (err) 553 if (err)
559 goto give_sigsegv; 554 return -EFAULT;
560 555
561 /* 556 /*
562 * Arguments to signal handler: 557 * Arguments to signal handler:
@@ -568,22 +563,18 @@ static int setup_rt_frame_32(void *sig_return, struct k_sigaction *ka,
568 * $25 and c0_epc point to the signal handler, $29 points to 563 * $25 and c0_epc point to the signal handler, $29 points to
569 * the struct rt_sigframe32. 564 * the struct rt_sigframe32.
570 */ 565 */
571 regs->regs[ 4] = signr; 566 regs->regs[ 4] = ksig->sig;
572 regs->regs[ 5] = (unsigned long) &frame->rs_info; 567 regs->regs[ 5] = (unsigned long) &frame->rs_info;
573 regs->regs[ 6] = (unsigned long) &frame->rs_uc; 568 regs->regs[ 6] = (unsigned long) &frame->rs_uc;
574 regs->regs[29] = (unsigned long) frame; 569 regs->regs[29] = (unsigned long) frame;
575 regs->regs[31] = (unsigned long) sig_return; 570 regs->regs[31] = (unsigned long) sig_return;
576 regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler; 571 regs->cp0_epc = regs->regs[25] = (unsigned long) ksig->ka.sa.sa_handler;
577 572
578 DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n", 573 DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n",
579 current->comm, current->pid, 574 current->comm, current->pid,
580 frame, regs->cp0_epc, regs->regs[31]); 575 frame, regs->cp0_epc, regs->regs[31]);
581 576
582 return 0; 577 return 0;
583
584give_sigsegv:
585 force_sigsegv(signr, current);
586 return -EFAULT;
587} 578}
588 579
589/* 580/*
diff --git a/arch/mips/kernel/signal_n32.c b/arch/mips/kernel/signal_n32.c
index b2241bb9cac1..7d04f2868ba6 100644
--- a/arch/mips/kernel/signal_n32.c
+++ b/arch/mips/kernel/signal_n32.c
@@ -102,18 +102,18 @@ badframe:
102 force_sig(SIGSEGV, current); 102 force_sig(SIGSEGV, current);
103} 103}
104 104
105static int setup_rt_frame_n32(void *sig_return, struct k_sigaction *ka, 105static int setup_rt_frame_n32(void *sig_return, struct ksignal *ksig,
106 struct pt_regs *regs, int signr, sigset_t *set, siginfo_t *info) 106 struct pt_regs *regs, sigset_t *set)
107{ 107{
108 struct rt_sigframe_n32 __user *frame; 108 struct rt_sigframe_n32 __user *frame;
109 int err = 0; 109 int err = 0;
110 110
111 frame = get_sigframe(ka, regs, sizeof(*frame)); 111 frame = get_sigframe(&ksig->ka, regs, sizeof(*frame));
112 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) 112 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
113 goto give_sigsegv; 113 return -EFAULT;
114 114
115 /* Create siginfo. */ 115 /* Create siginfo. */
116 err |= copy_siginfo_to_user32(&frame->rs_info, info); 116 err |= copy_siginfo_to_user32(&frame->rs_info, &ksig->info);
117 117
118 /* Create the ucontext. */ 118 /* Create the ucontext. */
119 err |= __put_user(0, &frame->rs_uc.uc_flags); 119 err |= __put_user(0, &frame->rs_uc.uc_flags);
@@ -123,7 +123,7 @@ static int setup_rt_frame_n32(void *sig_return, struct k_sigaction *ka,
123 err |= __copy_conv_sigset_to_user(&frame->rs_uc.uc_sigmask, set); 123 err |= __copy_conv_sigset_to_user(&frame->rs_uc.uc_sigmask, set);
124 124
125 if (err) 125 if (err)
126 goto give_sigsegv; 126 return -EFAULT;
127 127
128 /* 128 /*
129 * Arguments to signal handler: 129 * Arguments to signal handler:
@@ -135,22 +135,18 @@ static int setup_rt_frame_n32(void *sig_return, struct k_sigaction *ka,
135 * $25 and c0_epc point to the signal handler, $29 points to 135 * $25 and c0_epc point to the signal handler, $29 points to
136 * the struct rt_sigframe. 136 * the struct rt_sigframe.
137 */ 137 */
138 regs->regs[ 4] = signr; 138 regs->regs[ 4] = ksig->sig;
139 regs->regs[ 5] = (unsigned long) &frame->rs_info; 139 regs->regs[ 5] = (unsigned long) &frame->rs_info;
140 regs->regs[ 6] = (unsigned long) &frame->rs_uc; 140 regs->regs[ 6] = (unsigned long) &frame->rs_uc;
141 regs->regs[29] = (unsigned long) frame; 141 regs->regs[29] = (unsigned long) frame;
142 regs->regs[31] = (unsigned long) sig_return; 142 regs->regs[31] = (unsigned long) sig_return;
143 regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler; 143 regs->cp0_epc = regs->regs[25] = (unsigned long) ksig->ka.sa.sa_handler;
144 144
145 DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n", 145 DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n",
146 current->comm, current->pid, 146 current->comm, current->pid,
147 frame, regs->cp0_epc, regs->regs[31]); 147 frame, regs->cp0_epc, regs->regs[31]);
148 148
149 return 0; 149 return 0;
150
151give_sigsegv:
152 force_sigsegv(signr, current);
153 return -EFAULT;
154} 150}
155 151
156struct mips_abi mips_abi_n32 = { 152struct mips_abi mips_abi_n32 = {