10 #include <linux/module.h>
11 #include <linux/ptrace.h>
12 #include <linux/kexec.h>
17 #include <asm/stacktrace.h>
20 #define N_EXCEPTION_STACKS_END \
21 (N_EXCEPTION_STACKS + DEBUG_STKSZ/EXCEPTION_STKSZ - 2)
23 static char x86_stack_ids[][8] = {
29 #if DEBUG_STKSZ > EXCEPTION_STKSZ
35 static unsigned long *in_exception_stack(
unsigned cpu,
unsigned long stack,
36 unsigned *usedp,
char **idp)
63 if (*usedp & (1
U << k))
66 *idp = x86_stack_ids[
k];
67 return (
unsigned long *)
end;
74 #if DEBUG_STKSZ > EXCEPTION_STKSZ
76 unsigned j = N_EXCEPTION_STACKS - 1;
86 x86_stack_ids[
j][4] =
'1' +
89 if (*usedp & (1
U << j))
92 *idp = x86_stack_ids[
j];
93 return (
unsigned long *)
end;
101 in_irq_stack(
unsigned long *stack,
unsigned long *irq_stack,
102 unsigned long *irq_stack_end)
104 return (stack >= irq_stack && stack < irq_stack_end);
115 unsigned long *stack,
unsigned long bp,
118 const unsigned cpu =
get_cpu();
119 unsigned long *irq_stack_end =
120 (
unsigned long *)
per_cpu(irq_stack_ptr, cpu);
131 stack = (
unsigned long *)regs->
sp;
133 stack = (
unsigned long *)task->
thread.sp;
148 unsigned long *estack_end;
149 estack_end = in_exception_stack(cpu, (
unsigned long)stack,
153 if (ops->
stack(data,
id) < 0)
157 data, estack_end, &graph);
158 ops->
stack(data,
"<EOE>");
164 stack = (
unsigned long *) estack_end[-2];
168 unsigned long *irq_stack;
169 irq_stack = irq_stack_end -
172 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
173 if (ops->
stack(data,
"IRQ") < 0)
176 ops, data, irq_stack_end, &graph);
182 stack = (
unsigned long *) (irq_stack_end[-1]);
183 irq_stack_end =
NULL;
184 ops->
stack(data,
"EOI");
201 unsigned long *
sp,
unsigned long bp,
char *log_lvl)
203 unsigned long *irq_stack_end;
204 unsigned long *irq_stack;
205 unsigned long *
stack;
212 irq_stack_end = (
unsigned long *)(
per_cpu(irq_stack_ptr, cpu));
221 sp = (
unsigned long *)task->
thread.sp;
223 sp = (
unsigned long *)&
sp;
228 if (stack >= irq_stack && stack <= irq_stack_end) {
229 if (stack == irq_stack_end) {
230 stack = (
unsigned long *) (irq_stack_end[-1]);
266 unsigned int code_prologue =
code_bytes * 43 / 64;
277 ip = (
u8 *)regs->ip - code_prologue;
281 code_len = code_len - code_prologue + 1;
283 for (i = 0; i < code_len; i++, ip++) {
289 if (ip == (
u8 *)regs->ip)
305 return ud2 == 0x0b0f;