aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorJudith Lebzelter <judith@osdl.org>2006-12-08 05:36:23 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-08 11:28:39 -0500
commita8605aef813f8eb3ef4b80d32cba6a671ef8deb0 (patch)
treee2da11449f9fe91a116e0121be8fff11388941f5 /arch
parente182c965b6ce0dffed0967a1be2173825a2ede2f (diff)
[PATCH] use generic BUG for ppc
Switch ppc over to using the generic BUG implementation. Signed-off-by: Judith Lebzelter <judith@osdl.org> Cc: Jeremy Fitzhardinge <jeremy@goop.org> Cc: Michael Ellerman <michael@ellerman.id.au> Cc: Paul Mackerras <paulus@samba.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/ppc/Kconfig5
-rw-r--r--arch/ppc/kernel/traps.c64
2 files changed, 11 insertions, 58 deletions
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index edf71a4ecc95..f76a146cff13 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -52,6 +52,11 @@ config ARCH_MAY_HAVE_PC_FDC
52 bool 52 bool
53 default y 53 default y
54 54
55config GENERIC_BUG
56 bool
57 default y
58 depends on BUG
59
55source "init/Kconfig" 60source "init/Kconfig"
56 61
57menu "Processor" 62menu "Processor"
diff --git a/arch/ppc/kernel/traps.c b/arch/ppc/kernel/traps.c
index 2f835b9e95e4..810f7aa72e92 100644
--- a/arch/ppc/kernel/traps.c
+++ b/arch/ppc/kernel/traps.c
@@ -28,6 +28,7 @@
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/prctl.h> 30#include <linux/prctl.h>
31#include <linux/bug.h>
31 32
32#include <asm/pgtable.h> 33#include <asm/pgtable.h>
33#include <asm/uaccess.h> 34#include <asm/uaccess.h>
@@ -559,64 +560,9 @@ static void emulate_single_step(struct pt_regs *regs)
559 } 560 }
560} 561}
561 562
562/* 563int is_valid_bugaddr(unsigned long addr)
563 * Look through the list of trap instructions that are used for BUG(),
564 * BUG_ON() and WARN_ON() and see if we hit one. At this point we know
565 * that the exception was caused by a trap instruction of some kind.
566 * Returns 1 if we should continue (i.e. it was a WARN_ON) or 0
567 * otherwise.
568 */
569extern struct bug_entry __start___bug_table[], __stop___bug_table[];
570
571#ifndef CONFIG_MODULES
572#define module_find_bug(x) NULL
573#endif
574
575struct bug_entry *find_bug(unsigned long bugaddr)
576{
577 struct bug_entry *bug;
578
579 for (bug = __start___bug_table; bug < __stop___bug_table; ++bug)
580 if (bugaddr == bug->bug_addr)
581 return bug;
582 return module_find_bug(bugaddr);
583}
584
585int check_bug_trap(struct pt_regs *regs)
586{ 564{
587 struct bug_entry *bug; 565 return addr >= PAGE_OFFSET;
588 unsigned long addr;
589
590 if (regs->msr & MSR_PR)
591 return 0; /* not in kernel */
592 addr = regs->nip; /* address of trap instruction */
593 if (addr < PAGE_OFFSET)
594 return 0;
595 bug = find_bug(regs->nip);
596 if (bug == NULL)
597 return 0;
598 if (bug->line & BUG_WARNING_TRAP) {
599 /* this is a WARN_ON rather than BUG/BUG_ON */
600#ifdef CONFIG_XMON
601 xmon_printf(KERN_ERR "Badness in %s at %s:%ld\n",
602 bug->function, bug->file,
603 bug->line & ~BUG_WARNING_TRAP);
604#endif /* CONFIG_XMON */
605 printk(KERN_ERR "Badness in %s at %s:%ld\n",
606 bug->function, bug->file,
607 bug->line & ~BUG_WARNING_TRAP);
608 dump_stack();
609 return 1;
610 }
611#ifdef CONFIG_XMON
612 xmon_printf(KERN_CRIT "kernel BUG in %s at %s:%ld!\n",
613 bug->function, bug->file, bug->line);
614 xmon(regs);
615#endif /* CONFIG_XMON */
616 printk(KERN_CRIT "kernel BUG in %s at %s:%ld!\n",
617 bug->function, bug->file, bug->line);
618
619 return 0;
620} 566}
621 567
622void program_check_exception(struct pt_regs *regs) 568void program_check_exception(struct pt_regs *regs)
@@ -671,7 +617,9 @@ void program_check_exception(struct pt_regs *regs)
671 /* trap exception */ 617 /* trap exception */
672 if (debugger_bpt(regs)) 618 if (debugger_bpt(regs))
673 return; 619 return;
674 if (check_bug_trap(regs)) { 620
621 if (!(regs->msr & MSR_PR) && /* not user-mode */
622 report_bug(regs->nip) == BUG_TRAP_TYPE_WARN) {
675 regs->nip += 4; 623 regs->nip += 4;
676 return; 624 return;
677 } 625 }