aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/traps.c
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy@goop.org>2006-12-08 06:30:41 -0500
committerPaul Mackerras <paulus@samba.org>2006-12-11 00:35:07 -0500
commit73c9ceab40b1269d6195e556773167c078ac8311 (patch)
treed1de1c286b58a8b1e8dcd0e690ac6e8724e990f5 /arch/powerpc/kernel/traps.c
parent973c1fabc70deb10f12a0eaab2f50c2263784257 (diff)
[POWERPC] Generic BUG for powerpc
This makes powerpc use the generic BUG machinery. The biggest reports the function name, since it is redundant with kallsyms, and not needed in general. There is an overall reduction of code, since module_32/64 duplicated several functions. Unfortunately there's no way to tell gcc that BUG won't return, so the BUG macro includes a goto loop. This will generate a real jmp instruction, which is never used. [akpm@osdl.org: build fix] [paulus@samba.org: remove infinite loop in BUG_ON] Signed-off-by: Jeremy Fitzhardinge <jeremy@goop.org> Cc: Andi Kleen <ak@muc.de> Cc: Hugh Dickens <hugh@veritas.com> Cc: Michael Ellerman <michael@ellerman.id.au> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel/traps.c')
-rw-r--r--arch/powerpc/kernel/traps.c54
1 files changed, 6 insertions, 48 deletions
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index fde820e52d03..535f50665647 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -32,6 +32,7 @@
32#include <linux/kprobes.h> 32#include <linux/kprobes.h>
33#include <linux/kexec.h> 33#include <linux/kexec.h>
34#include <linux/backlight.h> 34#include <linux/backlight.h>
35#include <linux/bug.h>
35 36
36#include <asm/kdebug.h> 37#include <asm/kdebug.h>
37#include <asm/pgtable.h> 38#include <asm/pgtable.h>
@@ -727,54 +728,9 @@ static int emulate_instruction(struct pt_regs *regs)
727 return -EINVAL; 728 return -EINVAL;
728} 729}
729 730
730/* 731int is_valid_bugaddr(unsigned long addr)
731 * Look through the list of trap instructions that are used for BUG(),
732 * BUG_ON() and WARN_ON() and see if we hit one. At this point we know
733 * that the exception was caused by a trap instruction of some kind.
734 * Returns 1 if we should continue (i.e. it was a WARN_ON) or 0
735 * otherwise.
736 */
737extern struct bug_entry __start___bug_table[], __stop___bug_table[];
738
739#ifndef CONFIG_MODULES
740#define module_find_bug(x) NULL
741#endif
742
743struct bug_entry *find_bug(unsigned long bugaddr)
744{ 732{
745 struct bug_entry *bug; 733 return is_kernel_addr(addr);
746
747 for (bug = __start___bug_table; bug < __stop___bug_table; ++bug)
748 if (bugaddr == bug->bug_addr)
749 return bug;
750 return module_find_bug(bugaddr);
751}
752
753static int check_bug_trap(struct pt_regs *regs)
754{
755 struct bug_entry *bug;
756 unsigned long addr;
757
758 if (regs->msr & MSR_PR)
759 return 0; /* not in kernel */
760 addr = regs->nip; /* address of trap instruction */
761 if (addr < PAGE_OFFSET)
762 return 0;
763 bug = find_bug(regs->nip);
764 if (bug == NULL)
765 return 0;
766 if (bug->line & BUG_WARNING_TRAP) {
767 /* this is a WARN_ON rather than BUG/BUG_ON */
768 printk(KERN_ERR "Badness in %s at %s:%ld\n",
769 bug->function, bug->file,
770 bug->line & ~BUG_WARNING_TRAP);
771 dump_stack();
772 return 1;
773 }
774 printk(KERN_CRIT "kernel BUG in %s at %s:%ld!\n",
775 bug->function, bug->file, bug->line);
776
777 return 0;
778} 734}
779 735
780void __kprobes program_check_exception(struct pt_regs *regs) 736void __kprobes program_check_exception(struct pt_regs *regs)
@@ -810,7 +766,9 @@ void __kprobes program_check_exception(struct pt_regs *regs)
810 return; 766 return;
811 if (debugger_bpt(regs)) 767 if (debugger_bpt(regs))
812 return; 768 return;
813 if (check_bug_trap(regs)) { 769
770 if (!(regs->msr & MSR_PR) && /* not user-mode */
771 report_bug(regs->nip) == BUG_TRAP_TYPE_WARN) {
814 regs->nip += 4; 772 regs->nip += 4;
815 return; 773 return;
816 } 774 }