aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2012-06-14 01:18:51 -0400
committerPaul Mundt <lethal@linux-sh.org>2012-06-14 01:18:51 -0400
commit5f857bce21cfd0531dc7d4daac74d976caf6166b (patch)
tree50894bfbbdf40744e1f224aedd562a73786adcbf /arch/sh
parent37c9ee0161332291c8d13bc40084d24c744ed842 (diff)
sh: Consolidate die definitions for trap handlers.
This kills off the _64 versions and consolidates on the more robust _32 versions instead. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh')
-rw-r--r--arch/sh/include/asm/bug.h4
-rw-r--r--arch/sh/kernel/traps.c71
-rw-r--r--arch/sh/kernel/traps_32.c71
-rw-r--r--arch/sh/kernel/traps_64.c31
4 files changed, 75 insertions, 102 deletions
diff --git a/arch/sh/include/asm/bug.h b/arch/sh/include/asm/bug.h
index 2b87d86bfc4..dcf27807542 100644
--- a/arch/sh/include/asm/bug.h
+++ b/arch/sh/include/asm/bug.h
@@ -110,6 +110,10 @@ do { \
110#include <asm-generic/bug.h> 110#include <asm-generic/bug.h>
111 111
112struct pt_regs; 112struct pt_regs;
113
114/* arch/sh/kernel/traps.c */
113extern void die(const char *str, struct pt_regs *regs, long err) __attribute__ ((noreturn)); 115extern void die(const char *str, struct pt_regs *regs, long err) __attribute__ ((noreturn));
116extern void die_if_kernel(const char *str, struct pt_regs *regs, long err);
117extern void die_if_no_fixup(const char *str, struct pt_regs *regs, long err);
114 118
115#endif /* __ASM_SH_BUG_H */ 119#endif /* __ASM_SH_BUG_H */
diff --git a/arch/sh/kernel/traps.c b/arch/sh/kernel/traps.c
index a87e58a9e38..72246bc0688 100644
--- a/arch/sh/kernel/traps.c
+++ b/arch/sh/kernel/traps.c
@@ -6,9 +6,80 @@
6#include <linux/sched.h> 6#include <linux/sched.h>
7#include <linux/uaccess.h> 7#include <linux/uaccess.h>
8#include <linux/hardirq.h> 8#include <linux/hardirq.h>
9#include <linux/kernel.h>
10#include <linux/kexec.h>
11#include <linux/module.h>
9#include <asm/unwinder.h> 12#include <asm/unwinder.h>
10#include <asm/traps.h> 13#include <asm/traps.h>
11 14
15static DEFINE_SPINLOCK(die_lock);
16
17void die(const char *str, struct pt_regs *regs, long err)
18{
19 static int die_counter;
20
21 oops_enter();
22
23 spin_lock_irq(&die_lock);
24 console_verbose();
25 bust_spinlocks(1);
26
27 printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
28 print_modules();
29 show_regs(regs);
30
31 printk("Process: %s (pid: %d, stack limit = %p)\n", current->comm,
32 task_pid_nr(current), task_stack_page(current) + 1);
33
34 if (!user_mode(regs) || in_interrupt())
35 dump_mem("Stack: ", regs->regs[15], THREAD_SIZE +
36 (unsigned long)task_stack_page(current));
37
38 notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV);
39
40 bust_spinlocks(0);
41 add_taint(TAINT_DIE);
42 spin_unlock_irq(&die_lock);
43 oops_exit();
44
45 if (kexec_should_crash(current))
46 crash_kexec(regs);
47
48 if (in_interrupt())
49 panic("Fatal exception in interrupt");
50
51 if (panic_on_oops)
52 panic("Fatal exception");
53
54 do_exit(SIGSEGV);
55}
56
57void die_if_kernel(const char *str, struct pt_regs *regs, long err)
58{
59 if (!user_mode(regs))
60 die(str, regs, err);
61}
62
63/*
64 * try and fix up kernelspace address errors
65 * - userspace errors just cause EFAULT to be returned, resulting in SEGV
66 * - kernel/userspace interfaces cause a jump to an appropriate handler
67 * - other kernel errors are bad
68 */
69void die_if_no_fixup(const char *str, struct pt_regs *regs, long err)
70{
71 if (!user_mode(regs)) {
72 const struct exception_table_entry *fixup;
73 fixup = search_exception_tables(regs->pc);
74 if (fixup) {
75 regs->pc = fixup->fixup;
76 return;
77 }
78
79 die(str, regs, err);
80 }
81}
82
12#ifdef CONFIG_GENERIC_BUG 83#ifdef CONFIG_GENERIC_BUG
13static void handle_BUG(struct pt_regs *regs) 84static void handle_BUG(struct pt_regs *regs)
14{ 85{
diff --git a/arch/sh/kernel/traps_32.c b/arch/sh/kernel/traps_32.c
index b8f5a51841e..5f513a64ded 100644
--- a/arch/sh/kernel/traps_32.c
+++ b/arch/sh/kernel/traps_32.c
@@ -16,13 +16,11 @@
16#include <linux/hardirq.h> 16#include <linux/hardirq.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/spinlock.h> 18#include <linux/spinlock.h>
19#include <linux/module.h>
20#include <linux/kallsyms.h> 19#include <linux/kallsyms.h>
21#include <linux/io.h> 20#include <linux/io.h>
22#include <linux/bug.h> 21#include <linux/bug.h>
23#include <linux/debug_locks.h> 22#include <linux/debug_locks.h>
24#include <linux/kdebug.h> 23#include <linux/kdebug.h>
25#include <linux/kexec.h>
26#include <linux/limits.h> 24#include <linux/limits.h>
27#include <linux/sysfs.h> 25#include <linux/sysfs.h>
28#include <linux/uaccess.h> 26#include <linux/uaccess.h>
@@ -48,75 +46,6 @@
48#define TRAP_ILLEGAL_SLOT_INST 13 46#define TRAP_ILLEGAL_SLOT_INST 13
49#endif 47#endif
50 48
51static DEFINE_SPINLOCK(die_lock);
52
53void die(const char * str, struct pt_regs * regs, long err)
54{
55 static int die_counter;
56
57 oops_enter();
58
59 spin_lock_irq(&die_lock);
60 console_verbose();
61 bust_spinlocks(1);
62
63 printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
64 print_modules();
65 show_regs(regs);
66
67 printk("Process: %s (pid: %d, stack limit = %p)\n", current->comm,
68 task_pid_nr(current), task_stack_page(current) + 1);
69
70 if (!user_mode(regs) || in_interrupt())
71 dump_mem("Stack: ", regs->regs[15], THREAD_SIZE +
72 (unsigned long)task_stack_page(current));
73
74 notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV);
75
76 bust_spinlocks(0);
77 add_taint(TAINT_DIE);
78 spin_unlock_irq(&die_lock);
79 oops_exit();
80
81 if (kexec_should_crash(current))
82 crash_kexec(regs);
83
84 if (in_interrupt())
85 panic("Fatal exception in interrupt");
86
87 if (panic_on_oops)
88 panic("Fatal exception");
89
90 do_exit(SIGSEGV);
91}
92
93static inline void die_if_kernel(const char *str, struct pt_regs *regs,
94 long err)
95{
96 if (!user_mode(regs))
97 die(str, regs, err);
98}
99
100/*
101 * try and fix up kernelspace address errors
102 * - userspace errors just cause EFAULT to be returned, resulting in SEGV
103 * - kernel/userspace interfaces cause a jump to an appropriate handler
104 * - other kernel errors are bad
105 */
106static void die_if_no_fixup(const char * str, struct pt_regs * regs, long err)
107{
108 if (!user_mode(regs)) {
109 const struct exception_table_entry *fixup;
110 fixup = search_exception_tables(regs->pc);
111 if (fixup) {
112 regs->pc = fixup->fixup;
113 return;
114 }
115
116 die(str, regs, err);
117 }
118}
119
120static inline void sign_extend(unsigned int count, unsigned char *dst) 49static inline void sign_extend(unsigned int count, unsigned char *dst)
121{ 50{
122#ifdef __LITTLE_ENDIAN__ 51#ifdef __LITTLE_ENDIAN__
diff --git a/arch/sh/kernel/traps_64.c b/arch/sh/kernel/traps_64.c
index c902c29400a..75bef61892d 100644
--- a/arch/sh/kernel/traps_64.c
+++ b/arch/sh/kernel/traps_64.c
@@ -41,37 +41,6 @@ asmlinkage void do_##name(unsigned long error_code, struct pt_regs *regs) \
41 do_unhandled_exception(trapnr, signr, str, __stringify(name), error_code, regs, current); \ 41 do_unhandled_exception(trapnr, signr, str, __stringify(name), error_code, regs, current); \
42} 42}
43 43
44static DEFINE_SPINLOCK(die_lock);
45
46void die(const char * str, struct pt_regs * regs, long err)
47{
48 console_verbose();
49 spin_lock_irq(&die_lock);
50 printk("%s: %lx\n", str, (err & 0xffffff));
51 show_regs(regs);
52 spin_unlock_irq(&die_lock);
53 do_exit(SIGSEGV);
54}
55
56static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err)
57{
58 if (!user_mode(regs))
59 die(str, regs, err);
60}
61
62static void die_if_no_fixup(const char * str, struct pt_regs * regs, long err)
63{
64 if (!user_mode(regs)) {
65 const struct exception_table_entry *fixup;
66 fixup = search_exception_tables(regs->pc);
67 if (fixup) {
68 regs->pc = fixup->fixup;
69 return;
70 }
71 die(str, regs, err);
72 }
73}
74
75DO_ERROR(13, SIGILL, "illegal slot instruction", illegal_slot_inst, current) 44DO_ERROR(13, SIGILL, "illegal slot instruction", illegal_slot_inst, current)
76DO_ERROR(87, SIGSEGV, "address error (exec)", address_error_exec, current) 45DO_ERROR(87, SIGSEGV, "address error (exec)", address_error_exec, current)
77 46