x86: cpa: move clflush_cache_range()
[wrt350n-kernel.git] / arch / arm / kernel / stacktrace.c
blobae31deb2d0653a6a8fe57b000fb2827de9acdf13
1 #include <linux/module.h>
2 #include <linux/sched.h>
3 #include <linux/stacktrace.h>
5 #include "stacktrace.h"
7 int walk_stackframe(unsigned long fp, unsigned long low, unsigned long high,
8 int (*fn)(struct stackframe *, void *), void *data)
10 struct stackframe *frame;
12 do {
14 * Check current frame pointer is within bounds
16 if (fp < (low + 12) || fp + 4 >= high)
17 break;
19 frame = (struct stackframe *)(fp - 12);
21 if (fn(frame, data))
22 break;
25 * Update the low bound - the next frame must always
26 * be at a higher address than the current frame.
28 low = fp + 4;
29 fp = frame->fp;
30 } while (fp);
32 return 0;
34 EXPORT_SYMBOL(walk_stackframe);
36 #ifdef CONFIG_STACKTRACE
37 struct stack_trace_data {
38 struct stack_trace *trace;
39 unsigned int skip;
42 static int save_trace(struct stackframe *frame, void *d)
44 struct stack_trace_data *data = d;
45 struct stack_trace *trace = data->trace;
47 if (data->skip) {
48 data->skip--;
49 return 0;
52 trace->entries[trace->nr_entries++] = frame->lr;
54 return trace->nr_entries >= trace->max_entries;
57 void save_stack_trace(struct stack_trace *trace)
59 struct stack_trace_data data;
60 unsigned long fp, base;
62 data.trace = trace;
63 data.skip = trace->skip;
64 base = (unsigned long)task_stack_page(current);
65 asm("mov %0, fp" : "=r" (fp));
67 walk_stackframe(fp, base, base + THREAD_SIZE, save_trace, &data);
69 #endif