aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel/traps.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2011-08-16 18:44:26 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2011-10-17 04:13:41 -0400
commit87e040b6456fd3416a1f6831c1eedaef5c0a94ff (patch)
tree6a532e73b33c60d0f8b57d0954a055de4a243120 /arch/arm/kernel/traps.c
parenta675002c797815ec5df4a89748d8cab83158b11d (diff)
ARM: 7017/1: Use generic BUG() handler
ARM uses its own BUG() handler which makes its output slightly different from other archtectures. One of the problems is that the ARM implementation doesn't report the function with the BUG() in it, but always reports the PC being in __bug(). The generic implementation doesn't have this problem. Currently we get something like: kernel BUG at fs/proc/breakme.c:35! Unable to handle kernel NULL pointer dereference at virtual address 00000000 ... PC is at __bug+0x20/0x2c With this patch it displays: kernel BUG at fs/proc/breakme.c:35! Internal error: Oops - undefined instruction: 0 [#1] PREEMPT SMP ... PC is at write_breakme+0xd0/0x1b4 This implementation uses an undefined instruction to implement BUG, and sets up a bug table containing the relevant information. Many versions of gcc do not support %c properly for ARM (inserting a # when they shouldn't) so we work around this using distasteful macro magic. v1: Initial version to replace existing ARM BUG() implementation with something more similar to other architectures. v2: Add Thumb support, remove backtrace whitespace output changes. Change to use macros instead of requiring the asm %d flag to work (thanks to Dave Martin <dave.martin@linaro.org>) v3: Remove old BUG() implementation in favor of this one. Remove the Backtrace: message (will submit this separately). Use ARM_EXIT_KEEP() so that some architectures can dump exit text at link time thanks to Stephen Boyd <sboyd@codeaurora.org> (although since we always define GENERIC_BUG this might be academic.) Rebase to linux-2.6.git master. v4: Allow BUGS in modules (these were not reported correctly in v3) (thanks to Stephen Boyd <sboyd@codeaurora.org> for suggesting that.) Remove __bug() as this is no longer needed. v5: Add %progbits as the section flags. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Tested-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/kernel/traps.c')
-rw-r--r--arch/arm/kernel/traps.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index bc9f9da782cb..74969248c375 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -21,6 +21,7 @@
21#include <linux/kdebug.h> 21#include <linux/kdebug.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/kexec.h> 23#include <linux/kexec.h>
24#include <linux/bug.h>
24#include <linux/delay.h> 25#include <linux/delay.h>
25#include <linux/init.h> 26#include <linux/init.h>
26#include <linux/sched.h> 27#include <linux/sched.h>
@@ -270,6 +271,8 @@ void die(const char *str, struct pt_regs *regs, int err)
270 spin_lock_irq(&die_lock); 271 spin_lock_irq(&die_lock);
271 console_verbose(); 272 console_verbose();
272 bust_spinlocks(1); 273 bust_spinlocks(1);
274 if (!user_mode(regs))
275 report_bug(regs->ARM_pc, regs);
273 ret = __die(str, err, thread, regs); 276 ret = __die(str, err, thread, regs);
274 277
275 if (regs && kexec_should_crash(thread->task)) 278 if (regs && kexec_should_crash(thread->task))
@@ -301,6 +304,24 @@ void arm_notify_die(const char *str, struct pt_regs *regs,
301 } 304 }
302} 305}
303 306
307#ifdef CONFIG_GENERIC_BUG
308
309int is_valid_bugaddr(unsigned long pc)
310{
311#ifdef CONFIG_THUMB2_KERNEL
312 unsigned short bkpt;
313#else
314 unsigned long bkpt;
315#endif
316
317 if (probe_kernel_address((unsigned *)pc, bkpt))
318 return 0;
319
320 return bkpt == BUG_INSTR_VALUE;
321}
322
323#endif
324
304static LIST_HEAD(undef_hook); 325static LIST_HEAD(undef_hook);
305static DEFINE_SPINLOCK(undef_lock); 326static DEFINE_SPINLOCK(undef_lock);
306 327
@@ -706,16 +727,6 @@ baddataabort(int code, unsigned long instr, struct pt_regs *regs)
706 arm_notify_die("unknown data abort code", regs, &info, instr, 0); 727 arm_notify_die("unknown data abort code", regs, &info, instr, 0);
707} 728}
708 729
709void __attribute__((noreturn)) __bug(const char *file, int line)
710{
711 printk(KERN_CRIT"kernel BUG at %s:%d!\n", file, line);
712 *(int *)0 = 0;
713
714 /* Avoid "noreturn function does return" */
715 for (;;);
716}
717EXPORT_SYMBOL(__bug);
718
719void __readwrite_bug(const char *fn) 730void __readwrite_bug(const char *fn)
720{ 731{
721 printk("%s called, but not implemented\n", fn); 732 printk("%s called, but not implemented\n", fn);