aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2006-10-15 20:38:50 -0400
committerRalf Baechle <ralf@linux-mips.org>2006-11-29 20:14:50 -0500
commit63dc68a8cf60cb110b147dab1704d990808b39e2 (patch)
tree48dbc7a170eff5e16c3a1f6bf4fe53ab168c4e83
parent005985609ff72df3257fde6b29aa9d71342c2a6b (diff)
[MIPS] Use conditional traps for BUG_ON on MIPS II and better.
This shaves of around 4kB and a few cycles for the average kernel that has CONFIG_BUG enabled. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r--arch/mips/kernel/traps.c14
-rw-r--r--include/asm-mips/bug.h12
-rw-r--r--include/asm-mips/ptrace.h2
3 files changed, 22 insertions, 6 deletions
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 0ae19e1fa867..2a932cada244 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -669,8 +669,6 @@ asmlinkage void do_bp(struct pt_regs *regs)
669 unsigned int opcode, bcode; 669 unsigned int opcode, bcode;
670 siginfo_t info; 670 siginfo_t info;
671 671
672 die_if_kernel("Break instruction in kernel code", regs);
673
674 if (get_user(opcode, (unsigned int __user *) exception_epc(regs))) 672 if (get_user(opcode, (unsigned int __user *) exception_epc(regs)))
675 goto out_sigsegv; 673 goto out_sigsegv;
676 674
@@ -693,6 +691,7 @@ asmlinkage void do_bp(struct pt_regs *regs)
693 switch (bcode) { 691 switch (bcode) {
694 case BRK_OVERFLOW << 10: 692 case BRK_OVERFLOW << 10:
695 case BRK_DIVZERO << 10: 693 case BRK_DIVZERO << 10:
694 die_if_kernel("Break instruction in kernel code", regs);
696 if (bcode == (BRK_DIVZERO << 10)) 695 if (bcode == (BRK_DIVZERO << 10))
697 info.si_code = FPE_INTDIV; 696 info.si_code = FPE_INTDIV;
698 else 697 else
@@ -702,7 +701,11 @@ asmlinkage void do_bp(struct pt_regs *regs)
702 info.si_addr = (void __user *) regs->cp0_epc; 701 info.si_addr = (void __user *) regs->cp0_epc;
703 force_sig_info(SIGFPE, &info, current); 702 force_sig_info(SIGFPE, &info, current);
704 break; 703 break;
704 case BRK_BUG:
705 die("Kernel bug detected", regs);
706 break;
705 default: 707 default:
708 die_if_kernel("Break instruction in kernel code", regs);
706 force_sig(SIGTRAP, current); 709 force_sig(SIGTRAP, current);
707 } 710 }
708 711
@@ -715,8 +718,6 @@ asmlinkage void do_tr(struct pt_regs *regs)
715 unsigned int opcode, tcode = 0; 718 unsigned int opcode, tcode = 0;
716 siginfo_t info; 719 siginfo_t info;
717 720
718 die_if_kernel("Trap instruction in kernel code", regs);
719
720 if (get_user(opcode, (unsigned int __user *) exception_epc(regs))) 721 if (get_user(opcode, (unsigned int __user *) exception_epc(regs)))
721 goto out_sigsegv; 722 goto out_sigsegv;
722 723
@@ -733,6 +734,7 @@ asmlinkage void do_tr(struct pt_regs *regs)
733 switch (tcode) { 734 switch (tcode) {
734 case BRK_OVERFLOW: 735 case BRK_OVERFLOW:
735 case BRK_DIVZERO: 736 case BRK_DIVZERO:
737 die_if_kernel("Trap instruction in kernel code", regs);
736 if (tcode == BRK_DIVZERO) 738 if (tcode == BRK_DIVZERO)
737 info.si_code = FPE_INTDIV; 739 info.si_code = FPE_INTDIV;
738 else 740 else
@@ -742,7 +744,11 @@ asmlinkage void do_tr(struct pt_regs *regs)
742 info.si_addr = (void __user *) regs->cp0_epc; 744 info.si_addr = (void __user *) regs->cp0_epc;
743 force_sig_info(SIGFPE, &info, current); 745 force_sig_info(SIGFPE, &info, current);
744 break; 746 break;
747 case BRK_BUG:
748 die("Kernel bug detected", regs);
749 break;
745 default: 750 default:
751 die_if_kernel("Trap instruction in kernel code", regs);
746 force_sig(SIGTRAP, current); 752 force_sig(SIGTRAP, current);
747 } 753 }
748 754
diff --git a/include/asm-mips/bug.h b/include/asm-mips/bug.h
index 7b4739dc8f3f..4d560a533940 100644
--- a/include/asm-mips/bug.h
+++ b/include/asm-mips/bug.h
@@ -1,6 +1,7 @@
1#ifndef __ASM_BUG_H 1#ifndef __ASM_BUG_H
2#define __ASM_BUG_H 2#define __ASM_BUG_H
3 3
4#include <asm/sgidefs.h>
4 5
5#ifdef CONFIG_BUG 6#ifdef CONFIG_BUG
6 7
@@ -13,6 +14,17 @@ do { \
13 14
14#define HAVE_ARCH_BUG 15#define HAVE_ARCH_BUG
15 16
17#if (_MIPS_ISA > _MIPS_ISA_MIPS1)
18
19#define BUG_ON(condition) \
20do { \
21 __asm__ __volatile__("tne $0, %0" : : "r" (condition)); \
22} while (0)
23
24#define HAVE_ARCH_BUG_ON
25
26#endif /* _MIPS_ISA > _MIPS_ISA_MIPS1 */
27
16#endif 28#endif
17 29
18#include <asm-generic/bug.h> 30#include <asm-generic/bug.h>
diff --git a/include/asm-mips/ptrace.h b/include/asm-mips/ptrace.h
index 5f3a9075cd28..30bf555faeaa 100644
--- a/include/asm-mips/ptrace.h
+++ b/include/asm-mips/ptrace.h
@@ -80,8 +80,6 @@ struct pt_regs {
80#define instruction_pointer(regs) ((regs)->cp0_epc) 80#define instruction_pointer(regs) ((regs)->cp0_epc)
81#define profile_pc(regs) instruction_pointer(regs) 81#define profile_pc(regs) instruction_pointer(regs)
82 82
83extern void show_regs(struct pt_regs *);
84
85extern asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit); 83extern asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit);
86 84
87#endif 85#endif