Commit 63dc68a8 authored by Ralf Baechle's avatar Ralf Baechle

[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: default avatarRalf Baechle <ralf@linux-mips.org>
parent 00598560
...@@ -669,8 +669,6 @@ asmlinkage void do_bp(struct pt_regs *regs) ...@@ -669,8 +669,6 @@ asmlinkage void do_bp(struct pt_regs *regs)
unsigned int opcode, bcode; unsigned int opcode, bcode;
siginfo_t info; siginfo_t info;
die_if_kernel("Break instruction in kernel code", regs);
if (get_user(opcode, (unsigned int __user *) exception_epc(regs))) if (get_user(opcode, (unsigned int __user *) exception_epc(regs)))
goto out_sigsegv; goto out_sigsegv;
...@@ -693,6 +691,7 @@ asmlinkage void do_bp(struct pt_regs *regs) ...@@ -693,6 +691,7 @@ asmlinkage void do_bp(struct pt_regs *regs)
switch (bcode) { switch (bcode) {
case BRK_OVERFLOW << 10: case BRK_OVERFLOW << 10:
case BRK_DIVZERO << 10: case BRK_DIVZERO << 10:
die_if_kernel("Break instruction in kernel code", regs);
if (bcode == (BRK_DIVZERO << 10)) if (bcode == (BRK_DIVZERO << 10))
info.si_code = FPE_INTDIV; info.si_code = FPE_INTDIV;
else else
...@@ -702,7 +701,11 @@ asmlinkage void do_bp(struct pt_regs *regs) ...@@ -702,7 +701,11 @@ asmlinkage void do_bp(struct pt_regs *regs)
info.si_addr = (void __user *) regs->cp0_epc; info.si_addr = (void __user *) regs->cp0_epc;
force_sig_info(SIGFPE, &info, current); force_sig_info(SIGFPE, &info, current);
break; break;
case BRK_BUG:
die("Kernel bug detected", regs);
break;
default: default:
die_if_kernel("Break instruction in kernel code", regs);
force_sig(SIGTRAP, current); force_sig(SIGTRAP, current);
} }
...@@ -715,8 +718,6 @@ asmlinkage void do_tr(struct pt_regs *regs) ...@@ -715,8 +718,6 @@ asmlinkage void do_tr(struct pt_regs *regs)
unsigned int opcode, tcode = 0; unsigned int opcode, tcode = 0;
siginfo_t info; siginfo_t info;
die_if_kernel("Trap instruction in kernel code", regs);
if (get_user(opcode, (unsigned int __user *) exception_epc(regs))) if (get_user(opcode, (unsigned int __user *) exception_epc(regs)))
goto out_sigsegv; goto out_sigsegv;
...@@ -733,6 +734,7 @@ asmlinkage void do_tr(struct pt_regs *regs) ...@@ -733,6 +734,7 @@ asmlinkage void do_tr(struct pt_regs *regs)
switch (tcode) { switch (tcode) {
case BRK_OVERFLOW: case BRK_OVERFLOW:
case BRK_DIVZERO: case BRK_DIVZERO:
die_if_kernel("Trap instruction in kernel code", regs);
if (tcode == BRK_DIVZERO) if (tcode == BRK_DIVZERO)
info.si_code = FPE_INTDIV; info.si_code = FPE_INTDIV;
else else
...@@ -742,7 +744,11 @@ asmlinkage void do_tr(struct pt_regs *regs) ...@@ -742,7 +744,11 @@ asmlinkage void do_tr(struct pt_regs *regs)
info.si_addr = (void __user *) regs->cp0_epc; info.si_addr = (void __user *) regs->cp0_epc;
force_sig_info(SIGFPE, &info, current); force_sig_info(SIGFPE, &info, current);
break; break;
case BRK_BUG:
die("Kernel bug detected", regs);
break;
default: default:
die_if_kernel("Trap instruction in kernel code", regs);
force_sig(SIGTRAP, current); force_sig(SIGTRAP, current);
} }
......
#ifndef __ASM_BUG_H #ifndef __ASM_BUG_H
#define __ASM_BUG_H #define __ASM_BUG_H
#include <asm/sgidefs.h>
#ifdef CONFIG_BUG #ifdef CONFIG_BUG
...@@ -13,6 +14,17 @@ do { \ ...@@ -13,6 +14,17 @@ do { \
#define HAVE_ARCH_BUG #define HAVE_ARCH_BUG
#if (_MIPS_ISA > _MIPS_ISA_MIPS1)
#define BUG_ON(condition) \
do { \
__asm__ __volatile__("tne $0, %0" : : "r" (condition)); \
} while (0)
#define HAVE_ARCH_BUG_ON
#endif /* _MIPS_ISA > _MIPS_ISA_MIPS1 */
#endif #endif
#include <asm-generic/bug.h> #include <asm-generic/bug.h>
......
...@@ -80,8 +80,6 @@ struct pt_regs { ...@@ -80,8 +80,6 @@ struct pt_regs {
#define instruction_pointer(regs) ((regs)->cp0_epc) #define instruction_pointer(regs) ((regs)->cp0_epc)
#define profile_pc(regs) instruction_pointer(regs) #define profile_pc(regs) instruction_pointer(regs)
extern void show_regs(struct pt_regs *);
extern asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit); extern asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment