x86-32, ftrace: Fix static ftrace when early microcode is enabled
authorH. Peter Anvin <hpa@linux.intel.com>
Sat, 31 Aug 2013 00:29:29 +0000 (17:29 -0700)
committerSteven Rostedt <rostedt@goodmis.org>
Thu, 5 Sep 2013 13:31:32 +0000 (09:31 -0400)
Early microcode loading runs C code before paging is enabled on 32
bits.  Since ftrace puts a hook into every function, that hook needs
to be safe to execute in the pre-paging environment.  This is
currently true for dynamic ftrace but not for static ftrace.

Static ftrace is obsolescent and assumed to not be
performance-critical, so we can simply test that the stack pointer
falls within the valid range of kernel addresses.

Reported-by: Jan Kiszka <jan.kiszka@siemens.com>
Tested-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
arch/x86/kernel/entry_32.S

index 2cfbc3a3a2dd61055bccc6633a80a5910c293529..f0dcb0ceb6a2eda24d298b8a05650374e753bcf6 100644 (file)
@@ -1176,6 +1176,9 @@ ftrace_restore_flags:
 #else /* ! CONFIG_DYNAMIC_FTRACE */
 
 ENTRY(mcount)
+       cmpl $__PAGE_OFFSET, %esp
+       jb ftrace_stub          /* Paging not enabled yet? */
+
        cmpl $0, function_trace_stop
        jne  ftrace_stub