aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/sh/Kconfig.debug20
-rw-r--r--arch/sh/Makefile4
-rw-r--r--arch/sh/boot/compressed/Makefile2
-rw-r--r--arch/sh/kernel/irq.c17
-rw-r--r--arch/sh/kernel/sh_ksyms_32.c4
-rw-r--r--arch/sh/lib/Makefile3
-rw-r--r--arch/sh/lib/mcount.S83
7 files changed, 60 insertions, 73 deletions
diff --git a/arch/sh/Kconfig.debug b/arch/sh/Kconfig.debug
index 52a132c24aab..b440fd936714 100644
--- a/arch/sh/Kconfig.debug
+++ b/arch/sh/Kconfig.debug
@@ -61,12 +61,14 @@ config EARLY_PRINTK
61 select both the EARLY_SCIF_CONSOLE and SH_STANDARD_BIOS, using 61 select both the EARLY_SCIF_CONSOLE and SH_STANDARD_BIOS, using
62 the kernel command line option to toggle back and forth. 62 the kernel command line option to toggle back and forth.
63 63
64config DEBUG_STACKOVERFLOW 64config STACK_DEBUG
65 bool "Check for stack overflows" 65 bool "Check for stack overflows"
66 depends on DEBUG_KERNEL && SUPERH32 66 depends on DEBUG_KERNEL && SUPERH32
67 help 67 help
68 This option will cause messages to be printed if free stack space 68 This option will cause messages to be printed if free stack space
69 drops below a certain limit. 69 drops below a certain limit. Saying Y here will add overhead to
70 every function call and will therefore incur a major
71 performance hit. Most users should say N.
70 72
71config DEBUG_STACK_USAGE 73config DEBUG_STACK_USAGE
72 bool "Stack utilization instrumentation" 74 bool "Stack utilization instrumentation"
@@ -123,15 +125,9 @@ config SH64_SR_WATCH
123 bool "Debug: set SR.WATCH to enable hardware watchpoints and trace" 125 bool "Debug: set SR.WATCH to enable hardware watchpoints and trace"
124 depends on SUPERH64 126 depends on SUPERH64
125 127
126config STACK_DEBUG 128config MCOUNT
127 bool "Enable diagnostic checks of the kernel stack" 129 def_bool y
128 depends on FUNCTION_TRACER 130 depends on SUPERH32
129 select DEBUG_STACKOVERFLOW 131 depends on STACK_DEBUG || FUNCTION_TRACER
130 default n
131 help
132 This option allows checks to be performed on the kernel stack
133 at runtime. Saying Y here will add overhead to every function
134 call and will therefore incur a major performance hit. Most
135 users should say N.
136 132
137endmenu 133endmenu
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 75d049b03f7e..52c34bf56962 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -186,6 +186,10 @@ KBUILD_CFLAGS += -pipe $(cflags-y)
186KBUILD_CPPFLAGS += $(cflags-y) 186KBUILD_CPPFLAGS += $(cflags-y)
187KBUILD_AFLAGS += $(cflags-y) 187KBUILD_AFLAGS += $(cflags-y)
188 188
189ifeq ($(CONFIG_MCOUNT),y)
190 KBUILD_CFLAGS += -pg
191endif
192
189libs-$(CONFIG_SUPERH32) := arch/sh/lib/ $(libs-y) 193libs-$(CONFIG_SUPERH32) := arch/sh/lib/ $(libs-y)
190libs-$(CONFIG_SUPERH64) := arch/sh/lib64/ $(libs-y) 194libs-$(CONFIG_SUPERH64) := arch/sh/lib64/ $(libs-y)
191 195
diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile
index 3324019e207e..59e2937caa2f 100644
--- a/arch/sh/boot/compressed/Makefile
+++ b/arch/sh/boot/compressed/Makefile
@@ -24,7 +24,7 @@ IMAGE_OFFSET := $(shell /bin/bash -c 'printf "0x%08x" \
24 24
25LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) 25LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
26 26
27ifeq ($(CONFIG_FUNCTION_TRACER),y) 27ifeq ($(CONFIG_MCOUNT),y)
28ORIG_CFLAGS := $(KBUILD_CFLAGS) 28ORIG_CFLAGS := $(KBUILD_CFLAGS)
29KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS)) 29KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
30endif 30endif
diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
index 3d09062f4682..278c68c60488 100644
--- a/arch/sh/kernel/irq.c
+++ b/arch/sh/kernel/irq.c
@@ -114,23 +114,6 @@ asmlinkage int do_IRQ(unsigned int irq, struct pt_regs *regs)
114#endif 114#endif
115 115
116 irq_enter(); 116 irq_enter();
117
118#ifdef CONFIG_DEBUG_STACKOVERFLOW
119 /* Debugging check for stack overflow: is there less than 1KB free? */
120 {
121 long sp;
122
123 __asm__ __volatile__ ("and r15, %0" :
124 "=r" (sp) : "0" (THREAD_SIZE - 1));
125
126 if (unlikely(sp < (sizeof(struct thread_info) + STACK_WARN))) {
127 printk("do_IRQ: stack overflow: %ld\n",
128 sp - sizeof(struct thread_info));
129 dump_stack();
130 }
131 }
132#endif
133
134 irq = irq_demux(intc_evt2irq(irq)); 117 irq = irq_demux(intc_evt2irq(irq));
135 118
136#ifdef CONFIG_IRQSTACKS 119#ifdef CONFIG_IRQSTACKS
diff --git a/arch/sh/kernel/sh_ksyms_32.c b/arch/sh/kernel/sh_ksyms_32.c
index fcc5de31f83b..cec610888e28 100644
--- a/arch/sh/kernel/sh_ksyms_32.c
+++ b/arch/sh/kernel/sh_ksyms_32.c
@@ -106,8 +106,8 @@ EXPORT_SYMBOL(flush_dcache_page);
106EXPORT_SYMBOL(clear_user_page); 106EXPORT_SYMBOL(clear_user_page);
107#endif 107#endif
108 108
109#ifdef CONFIG_FUNCTION_TRACER 109#ifdef CONFIG_MCOUNT
110EXPORT_SYMBOL(mcount); 110DECLARE_EXPORT(mcount);
111#endif 111#endif
112EXPORT_SYMBOL(csum_partial); 112EXPORT_SYMBOL(csum_partial);
113EXPORT_SYMBOL(csum_partial_copy_generic); 113EXPORT_SYMBOL(csum_partial_copy_generic);
diff --git a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile
index 19328d90a2d1..c2b28d8b2dd1 100644
--- a/arch/sh/lib/Makefile
+++ b/arch/sh/lib/Makefile
@@ -24,8 +24,7 @@ memcpy-y := memcpy.o
24memcpy-$(CONFIG_CPU_SH4) := memcpy-sh4.o 24memcpy-$(CONFIG_CPU_SH4) := memcpy-sh4.o
25 25
26lib-$(CONFIG_MMU) += copy_page.o clear_page.o 26lib-$(CONFIG_MMU) += copy_page.o clear_page.o
27lib-$(CONFIG_FUNCTION_TRACER) += mcount.o 27lib-$(CONFIG_MCOUNT) += mcount.o
28lib-$(CONFIG_FUNCTION_GRAPH_TRACER) += mcount.o
29lib-y += $(memcpy-y) $(udivsi3-y) 28lib-y += $(memcpy-y) $(udivsi3-y)
30 29
31EXTRA_CFLAGS += -Werror 30EXTRA_CFLAGS += -Werror
diff --git a/arch/sh/lib/mcount.S b/arch/sh/lib/mcount.S
index bd3ec648becc..84a57761f17e 100644
--- a/arch/sh/lib/mcount.S
+++ b/arch/sh/lib/mcount.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/sh/lib/mcount.S 2 * arch/sh/lib/mcount.S
3 * 3 *
4 * Copyright (C) 2008 Paul Mundt 4 * Copyright (C) 2008, 2009 Paul Mundt
5 * Copyright (C) 2008, 2009 Matt Fleming 5 * Copyright (C) 2008, 2009 Matt Fleming
6 * 6 *
7 * This file is subject to the terms and conditions of the GNU General Public 7 * This file is subject to the terms and conditions of the GNU General Public
@@ -86,13 +86,18 @@
86 .type mcount,@function 86 .type mcount,@function
87_mcount: 87_mcount:
88mcount: 88mcount:
89 STACK_CHECK()
90
91#ifndef CONFIG_FUNCTION_TRACER
92 rts
93 nop
94#else
89#ifndef CONFIG_DYNAMIC_FTRACE 95#ifndef CONFIG_DYNAMIC_FTRACE
90 mov.l .Lfunction_trace_stop, r0 96 mov.l .Lfunction_trace_stop, r0
91 mov.l @r0, r0 97 mov.l @r0, r0
92 tst r0, r0 98 tst r0, r0
93 bf ftrace_stub 99 bf ftrace_stub
94#endif 100#endif
95 STACK_CHECK()
96 101
97 MCOUNT_ENTER() 102 MCOUNT_ENTER()
98 103
@@ -174,8 +179,6 @@ ftrace_caller:
174 tst r0, r0 179 tst r0, r0
175 bf ftrace_stub 180 bf ftrace_stub
176 181
177 STACK_CHECK()
178
179 MCOUNT_ENTER() 182 MCOUNT_ENTER()
180 183
181 .globl ftrace_call 184 .globl ftrace_call
@@ -192,6 +195,10 @@ ftrace_call:
192#endif /* CONFIG_FUNCTION_GRAPH_TRACER */ 195#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
193#endif /* CONFIG_DYNAMIC_FTRACE */ 196#endif /* CONFIG_DYNAMIC_FTRACE */
194 197
198 .align 2
199.Lfunction_trace_stop:
200 .long function_trace_stop
201
195/* 202/*
196 * NOTE: From here on the locations of the .Lftrace_stub label and 203 * NOTE: From here on the locations of the .Lftrace_stub label and
197 * ftrace_stub itself are fixed. Adding additional data here will skew 204 * ftrace_stub itself are fixed. Adding additional data here will skew
@@ -199,7 +206,6 @@ ftrace_call:
199 * Place new labels either after the ftrace_stub body, or before 206 * Place new labels either after the ftrace_stub body, or before
200 * ftrace_caller. You have been warned. 207 * ftrace_caller. You have been warned.
201 */ 208 */
202 .align 2
203.Lftrace_stub: 209.Lftrace_stub:
204 .long ftrace_stub 210 .long ftrace_stub
205 211
@@ -208,40 +214,6 @@ ftrace_stub:
208 rts 214 rts
209 nop 215 nop
210 216
211#ifdef CONFIG_STACK_DEBUG
212 .globl stack_panic
213stack_panic:
214 mov.l .Ldump_stack, r0
215 jsr @r0
216 nop
217
218 mov.l .Lpanic, r0
219 jsr @r0
220 mov.l .Lpanic_s, r4
221
222 rts
223 nop
224
225 .align 2
226.Lfunction_trace_stop:
227 .long function_trace_stop
228.L_ebss:
229 .long _ebss
230.L_init_thread_union:
231 .long init_thread_union
232.Lpanic:
233 .long panic
234.Lpanic_s:
235 .long .Lpanic_str
236.Ldump_stack:
237 .long dump_stack
238
239 .section .rodata
240 .align 2
241.Lpanic_str:
242 .string "Stack error"
243#endif /* CONFIG_STACK_DEBUG */
244
245#ifdef CONFIG_FUNCTION_GRAPH_TRACER 217#ifdef CONFIG_FUNCTION_GRAPH_TRACER
246 .globl ftrace_graph_caller 218 .globl ftrace_graph_caller
247ftrace_graph_caller: 219ftrace_graph_caller:
@@ -303,3 +275,36 @@ return_to_handler:
303.Lftrace_return_to_handler: 275.Lftrace_return_to_handler:
304 .long ftrace_return_to_handler 276 .long ftrace_return_to_handler
305#endif /* CONFIG_FUNCTION_GRAPH_TRACER */ 277#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
278#endif /* CONFIG_FUNCTION_TRACER */
279
280#ifdef CONFIG_STACK_DEBUG
281 .globl stack_panic
282stack_panic:
283 mov.l .Ldump_stack, r0
284 jsr @r0
285 nop
286
287 mov.l .Lpanic, r0
288 jsr @r0
289 mov.l .Lpanic_s, r4
290
291 rts
292 nop
293
294 .align 2
295.L_ebss:
296 .long _ebss
297.L_init_thread_union:
298 .long init_thread_union
299.Lpanic:
300 .long panic
301.Lpanic_s:
302 .long .Lpanic_str
303.Ldump_stack:
304 .long dump_stack
305
306 .section .rodata
307 .align 2
308.Lpanic_str:
309 .string "Stack error"
310#endif /* CONFIG_STACK_DEBUG */