Commit 70dc6f045fce6907b5d10377850a78ada6837ffb

Authored by David Daney
Committed by Ralf Baechle
1 parent 7281cd2297

MIPS: Clean up notify_die() usage.

The sixth argument of notify_die() is a signal number, the fifth is a
trap number.

Instead of passing a signal number in a randomly selected argument,
pass it in the sixth.  Extract the exception code from regs and pass
that as the trap number.

Get rid of redundant cast, and remove some gratuitous spaces.

Nobody actually does anything with the signal number or trap number,
but we might as well populate them with sensible values.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
To: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/1532/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

Showing 1 changed file with 15 additions and 10 deletions Side-by-side Diff

arch/mips/kernel/traps.c
... ... @@ -357,9 +357,14 @@
357 357 printk("\n");
358 358 }
359 359  
  360 +static int regs_to_trapnr(struct pt_regs *regs)
  361 +{
  362 + return (regs->cp0_cause >> 2) & 0x1f;
  363 +}
  364 +
360 365 static DEFINE_SPINLOCK(die_lock);
361 366  
362   -void __noreturn die(const char * str, struct pt_regs * regs)
  367 +void __noreturn die(const char *str, struct pt_regs *regs)
363 368 {
364 369 static int die_counter;
365 370 int sig = SIGSEGV;
... ... @@ -367,7 +372,7 @@
367 372 unsigned long dvpret = dvpe();
368 373 #endif /* CONFIG_MIPS_MT_SMTC */
369 374  
370   - notify_die(DIE_OOPS, str, (struct pt_regs *)regs, SIGSEGV, 0, 0);
  375 + notify_die(DIE_OOPS, str, regs, 0, regs_to_trapnr(regs), SIGSEGV);
371 376  
372 377 console_verbose();
373 378 spin_lock_irq(&die_lock);
... ... @@ -376,7 +381,7 @@
376 381 mips_mt_regdump(dvpret);
377 382 #endif /* CONFIG_MIPS_MT_SMTC */
378 383  
379   - if (notify_die(DIE_OOPS, str, regs, 0, 0, SIGSEGV) == NOTIFY_STOP)
  384 + if (notify_die(DIE_OOPS, str, regs, 0, regs_to_trapnr(regs), SIGSEGV) == NOTIFY_STOP)
380 385 sig = 0;
381 386  
382 387 printk("%s[#%d]:\n", str, ++die_counter);
... ... @@ -450,7 +455,7 @@
450 455 printk(KERN_ALERT "%s bus error, epc == %0*lx, ra == %0*lx\n",
451 456 data ? "Data" : "Instruction",
452 457 field, regs->cp0_epc, field, regs->regs[31]);
453   - if (notify_die(DIE_OOPS, "bus error", regs, SIGBUS, 0, 0)
  458 + if (notify_die(DIE_OOPS, "bus error", regs, 0, regs_to_trapnr(regs), SIGBUS)
454 459 == NOTIFY_STOP)
455 460 return;
456 461  
... ... @@ -651,7 +656,7 @@
651 656 {
652 657 siginfo_t info;
653 658  
654   - if (notify_die(DIE_FP, "FP exception", regs, SIGFPE, 0, 0)
  659 + if (notify_die(DIE_FP, "FP exception", regs, 0, regs_to_trapnr(regs), SIGFPE)
655 660 == NOTIFY_STOP)
656 661 return;
657 662 die_if_kernel("FP exception in kernel code", regs);
658 663  
... ... @@ -714,11 +719,11 @@
714 719 char b[40];
715 720  
716 721 #ifdef CONFIG_KGDB_LOW_LEVEL_TRAP
717   - if (kgdb_ll_trap(DIE_TRAP, str, regs, code, 0, 0) == NOTIFY_STOP)
  722 + if (kgdb_ll_trap(DIE_TRAP, str, regs, code, regs_to_trapnr(regs), SIGTRAP) == NOTIFY_STOP)
718 723 return;
719 724 #endif /* CONFIG_KGDB_LOW_LEVEL_TRAP */
720 725  
721   - if (notify_die(DIE_TRAP, str, regs, code, 0, 0) == NOTIFY_STOP)
  726 + if (notify_die(DIE_TRAP, str, regs, code, regs_to_trapnr(regs), SIGTRAP) == NOTIFY_STOP)
722 727 return;
723 728  
724 729 /*
725 730  
... ... @@ -790,12 +795,12 @@
790 795 */
791 796 switch (bcode) {
792 797 case BRK_KPROBE_BP:
793   - if (notify_die(DIE_BREAK, "debug", regs, bcode, 0, 0) == NOTIFY_STOP)
  798 + if (notify_die(DIE_BREAK, "debug", regs, bcode, regs_to_trapnr(regs), SIGTRAP) == NOTIFY_STOP)
794 799 return;
795 800 else
796 801 break;
797 802 case BRK_KPROBE_SSTEPBP:
798   - if (notify_die(DIE_SSTEPBP, "single_step", regs, bcode, 0, 0) == NOTIFY_STOP)
  803 + if (notify_die(DIE_SSTEPBP, "single_step", regs, bcode, regs_to_trapnr(regs), SIGTRAP) == NOTIFY_STOP)
799 804 return;
800 805 else
801 806 break;
... ... @@ -835,7 +840,7 @@
835 840 unsigned int opcode = 0;
836 841 int status = -1;
837 842  
838   - if (notify_die(DIE_RI, "RI Fault", regs, SIGSEGV, 0, 0)
  843 + if (notify_die(DIE_RI, "RI Fault", regs, 0, regs_to_trapnr(regs), SIGILL)
839 844 == NOTIFY_STOP)
840 845 return;
841 846