1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#include <linux/types.h>
18#include <linux/sched.h>
19#include <linux/sched/debug.h>
20#include <linux/mm_types.h>
21#include <linux/kernel.h>
22#include <linux/errno.h>
23#include <linux/init.h>
24#include <linux/module.h>
25#include <linux/bug.h>
26
27#include <asm/irq.h>
28#include <asm/traps.h>
29#include <asm/page.h>
30
31static DEFINE_SPINLOCK(die_lock);
32
33
34
35
36
37
38void __init base_trap_init(void)
39{
40}
41
42void __init trap_init(void)
43{
44}
45
46asmlinkage void set_esp0(unsigned long ssp)
47{
48 current->thread.esp0 = ssp;
49}
50
51
52
53
54
55static void dump(struct pt_regs *fp)
56{
57 unsigned long *sp;
58 unsigned char *tp;
59 int i;
60
61 pr_info("\nCURRENT PROCESS:\n\n");
62 pr_info("COMM=%s PID=%d\n", current->comm, current->pid);
63 if (current->mm) {
64 pr_info("TEXT=%08x-%08x DATA=%08x-%08x BSS=%08x-%08x\n",
65 (int) current->mm->start_code,
66 (int) current->mm->end_code,
67 (int) current->mm->start_data,
68 (int) current->mm->end_data,
69 (int) current->mm->end_data,
70 (int) current->mm->brk);
71 pr_info("USER-STACK=%08x KERNEL-STACK=%08lx\n\n",
72 (int) current->mm->start_stack,
73 (int) PAGE_SIZE+(unsigned long)current);
74 }
75
76 show_regs(fp);
77 pr_info("\nCODE:");
78 tp = ((unsigned char *) fp->pc) - 0x20;
79 for (sp = (unsigned long *) tp, i = 0; (i < 0x40); i += 4) {
80 if ((i % 0x10) == 0)
81 pr_info("\n%08x: ", (int) (tp + i));
82 pr_info("%08x ", (int) *sp++);
83 }
84 pr_info("\n");
85
86 pr_info("\nKERNEL STACK:");
87 tp = ((unsigned char *) fp) - 0x40;
88 for (sp = (unsigned long *) tp, i = 0; (i < 0xc0); i += 4) {
89 if ((i % 0x10) == 0)
90 pr_info("\n%08x: ", (int) (tp + i));
91 pr_info("%08x ", (int) *sp++);
92 }
93 pr_info("\n");
94 if (STACK_MAGIC != *(unsigned long *)((unsigned long)current+PAGE_SIZE))
95 pr_info("(Possibly corrupted stack page??)\n");
96
97 pr_info("\n\n");
98}
99
100void die(const char *str, struct pt_regs *fp, unsigned long err)
101{
102 static int diecount;
103
104 oops_enter();
105
106 console_verbose();
107 spin_lock_irq(&die_lock);
108 report_bug(fp->pc, fp);
109 pr_crit("%s: %04lx [#%d] ", str, err & 0xffff, ++diecount);
110 dump(fp);
111
112 spin_unlock_irq(&die_lock);
113 do_exit(SIGSEGV);
114}
115
116static int kstack_depth_to_print = 24;
117
118void show_stack(struct task_struct *task, unsigned long *esp)
119{
120 unsigned long *stack, addr;
121 int i;
122
123 if (esp == NULL)
124 esp = (unsigned long *) &esp;
125
126 stack = esp;
127
128 pr_info("Stack from %08lx:", (unsigned long)stack);
129 for (i = 0; i < kstack_depth_to_print; i++) {
130 if (((unsigned long)stack & (THREAD_SIZE - 1)) >=
131 THREAD_SIZE-4)
132 break;
133 if (i % 8 == 0)
134 pr_info(" ");
135 pr_cont(" %08lx", *stack++);
136 }
137
138 pr_info("\nCall Trace:\n");
139 i = 0;
140 stack = esp;
141 while (((unsigned long)stack & (THREAD_SIZE - 1)) < THREAD_SIZE-4) {
142 addr = *stack++;
143
144
145
146
147
148
149
150
151 if (check_kernel_text(addr)) {
152 if (i % 4 == 0)
153 pr_info(" ");
154 pr_cont(" [<%08lx>]", addr);
155 i++;
156 }
157 }
158 pr_info("\n");
159}
160