[for-next][PATCH 3/4] x86-32, ftrace: Fix static ftrace when early microcode is enabled

From: Steven Rostedt
Date: Thu Sep 05 2013 - 21:49:32 EST


From: "H. Peter Anvin" <hpa@xxxxxxxxxxxxxxx>

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@xxxxxxxxxxx>
Tested-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
Signed-off-by: H. Peter Anvin <hpa@xxxxxxxxxxxxxxx>
Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
arch/x86/kernel/entry_32.S | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 2cfbc3a..f0dcb0c 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -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

--
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/