4 * Copyright (C) 2008 Paul Mundt
5 * Copyright (C) 2008, 2009 Matt Fleming
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
11 #include <asm/ftrace.h>
12 #include <asm/thread_info.h>
13 #include <asm/asm-offsets.h>
15 #define MCOUNT_ENTER() \
25 #define MCOUNT_LEAVE() \
33 #ifdef CONFIG_STACK_DEBUG
35 * Perform diagnostic checks on the state of the kernel stack.
37 * Check for stack overflow. If there is less than 1KB free
38 * then it has overflowed.
40 * Make sure the stack pointer contains a valid address. Valid
41 * addresses for kernel stacks are anywhere after the bss
42 * (after _ebss) and anywhere in init_thread_union (init_stack).
44 #define STACK_CHECK() \
45 mov #(THREAD_SIZE >> 10), r0; \
49 /* r1 = sp & (THREAD_SIZE - 1) */ \
55 mov #(STACK_WARN >> 8), r2; \
59 /* Is the stack overflowing? */ \
63 /* If sp > _ebss then we're OK. */ \
68 /* If sp < init_stack, we're not OK. */ \
69 mov.l .L_init_thread_union, r1; \
73 /* If sp > init_stack && sp < _ebss, not OK. */ \
80 #endif /* CONFIG_STACK_DEBUG */
84 .type _mcount,@function
86 .type mcount,@function
89 #ifndef CONFIG_DYNAMIC_FTRACE
90 mov.l .Lfunction_trace_stop, r0
99 #ifdef CONFIG_DYNAMIC_FTRACE
102 mov.l .Lftrace_stub, r6
104 mov.l .Lftrace_trace_function, r6
105 mov.l ftrace_stub, r7
118 .Lftrace_trace_function:
119 .long ftrace_trace_function
121 #ifdef CONFIG_DYNAMIC_FTRACE
124 mov.l .Lfunction_trace_stop, r0
135 mov.l .Lftrace_stub, r6
140 #endif /* CONFIG_DYNAMIC_FTRACE */
143 * NOTE: From here on the locations of the .Lftrace_stub label and
144 * ftrace_stub itself are fixed. Adding additional data here will skew
145 * the displacement for the memory table and break the block replacement.
146 * Place new labels either after the ftrace_stub body, or before
147 * ftrace_caller. You have been warned.
158 #ifdef CONFIG_STACK_DEBUG
161 mov.l .Ldump_stack, r0
173 .Lfunction_trace_stop:
174 .long function_trace_stop
177 .L_init_thread_union:
178 .long init_thread_union
189 .string "Stack error"
190 #endif /* CONFIG_STACK_DEBUG */