Use dentry_path() to create full path to inode object
[pohmelfs.git] / arch / sh / kernel / traps.c
blob0830c2a9f712bfad77aaff2bb3a823717a567389
1 #include <linux/bug.h>
2 #include <linux/io.h>
3 #include <linux/types.h>
4 #include <linux/kdebug.h>
5 #include <linux/signal.h>
6 #include <linux/sched.h>
7 #include <linux/uaccess.h>
8 #include <linux/hardirq.h>
9 #include <asm/unwinder.h>
10 #include <asm/system.h>
12 #ifdef CONFIG_GENERIC_BUG
13 static void handle_BUG(struct pt_regs *regs)
15 const struct bug_entry *bug;
16 unsigned long bugaddr = regs->pc;
17 enum bug_trap_type tt;
19 if (!is_valid_bugaddr(bugaddr))
20 goto invalid;
22 bug = find_bug(bugaddr);
24 /* Switch unwinders when unwind_stack() is called */
25 if (bug->flags & BUGFLAG_UNWINDER)
26 unwinder_faulted = 1;
28 tt = report_bug(bugaddr, regs);
29 if (tt == BUG_TRAP_TYPE_WARN) {
30 regs->pc += instruction_size(bugaddr);
31 return;
34 invalid:
35 die("Kernel BUG", regs, TRAPA_BUG_OPCODE & 0xff);
38 int is_valid_bugaddr(unsigned long addr)
40 insn_size_t opcode;
42 if (addr < PAGE_OFFSET)
43 return 0;
44 if (probe_kernel_address((insn_size_t *)addr, opcode))
45 return 0;
46 if (opcode == TRAPA_BUG_OPCODE)
47 return 1;
49 return 0;
51 #endif
54 * Generic trap handler.
56 BUILD_TRAP_HANDLER(debug)
58 TRAP_HANDLER_DECL;
60 /* Rewind */
61 regs->pc -= instruction_size(__raw_readw(regs->pc - 4));
63 if (notify_die(DIE_TRAP, "debug trap", regs, 0, vec & 0xff,
64 SIGTRAP) == NOTIFY_STOP)
65 return;
67 force_sig(SIGTRAP, current);
71 * Special handler for BUG() traps.
73 BUILD_TRAP_HANDLER(bug)
75 TRAP_HANDLER_DECL;
77 /* Rewind */
78 regs->pc -= instruction_size(__raw_readw(regs->pc - 4));
80 if (notify_die(DIE_TRAP, "bug trap", regs, 0, TRAPA_BUG_OPCODE & 0xff,
81 SIGTRAP) == NOTIFY_STOP)
82 return;
84 #ifdef CONFIG_GENERIC_BUG
85 if (__kernel_text_address(instruction_pointer(regs))) {
86 insn_size_t insn = *(insn_size_t *)instruction_pointer(regs);
87 if (insn == TRAPA_BUG_OPCODE)
88 handle_BUG(regs);
89 return;
91 #endif
93 force_sig(SIGTRAP, current);
96 BUILD_TRAP_HANDLER(nmi)
98 unsigned int cpu = smp_processor_id();
99 TRAP_HANDLER_DECL;
101 nmi_enter();
102 nmi_count(cpu)++;
104 switch (notify_die(DIE_NMI, "NMI", regs, 0, vec & 0xff, SIGINT)) {
105 case NOTIFY_OK:
106 case NOTIFY_STOP:
107 break;
108 case NOTIFY_BAD:
109 die("Fatal Non-Maskable Interrupt", regs, SIGINT);
110 default:
111 printk(KERN_ALERT "Got NMI, but nobody cared. Ignoring...\n");
112 break;
115 nmi_exit();