Commit 0f42c1ad authored by Borislav Petkov's avatar Borislav Petkov

x86/ftrace: Get rid of function_hook

History lesson courtesy of Steve:

"When ftrace first was introduced to the kernel, it used gcc's
mcount profiling mechanism. The mcount mechanism would add a call to
"mcount" at the start of every function but after the stack frame was
set up. Later, in gcc 4.6, gcc introduced -mfentry, that would create a
call to "__fentry__" instead of "mcount", before the stack frame was
set up. In order to handle both cases, ftrace defined a macro
"function_hook" that would be either "mcount" or "__fentry__" depending
on which one was being used.

The Linux kernel no longer supports the "mcount" method, thus there's
no reason to keep the "function_hook" define around. Simply use
"__fentry__", as there is no ambiguity to the name anymore."

Drop it everywhere.
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Acked-by: default avatarJiri Slaby <jslaby@suse.cz>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: linux-doc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
Link: http://lkml.kernel.org/r/20191018124800.0a7006bb@gandalf.local.home
parent 13fbe784
...@@ -117,9 +117,9 @@ This section covers ``SYM_FUNC_*`` and ``SYM_CODE_*`` enumerated above. ...@@ -117,9 +117,9 @@ This section covers ``SYM_FUNC_*`` and ``SYM_CODE_*`` enumerated above.
So in most cases, developers should write something like in the following So in most cases, developers should write something like in the following
example, having some asm instructions in between the macros, of course:: example, having some asm instructions in between the macros, of course::
SYM_FUNC_START(function_hook) SYM_FUNC_START(memset)
... asm insns ... ... asm insns ...
SYM_FUNC_END(function_hook) SYM_FUNC_END(memset)
In fact, this kind of annotation corresponds to the now deprecated ``ENTRY`` In fact, this kind of annotation corresponds to the now deprecated ``ENTRY``
and ``ENDPROC`` macros. and ``ENDPROC`` macros.
......
...@@ -12,18 +12,16 @@ ...@@ -12,18 +12,16 @@
#include <asm/frame.h> #include <asm/frame.h>
#include <asm/asm-offsets.h> #include <asm/asm-offsets.h>
# define function_hook __fentry__
EXPORT_SYMBOL(__fentry__)
#ifdef CONFIG_FRAME_POINTER #ifdef CONFIG_FRAME_POINTER
# define MCOUNT_FRAME 1 /* using frame = true */ # define MCOUNT_FRAME 1 /* using frame = true */
#else #else
# define MCOUNT_FRAME 0 /* using frame = false */ # define MCOUNT_FRAME 0 /* using frame = false */
#endif #endif
SYM_FUNC_START(function_hook) SYM_FUNC_START(__fentry__)
ret ret
SYM_FUNC_END(function_hook) SYM_FUNC_END(__fentry__)
EXPORT_SYMBOL(__fentry__)
SYM_CODE_START(ftrace_caller) SYM_CODE_START(ftrace_caller)
......
...@@ -14,9 +14,6 @@ ...@@ -14,9 +14,6 @@
.code64 .code64
.section .entry.text, "ax" .section .entry.text, "ax"
# define function_hook __fentry__
EXPORT_SYMBOL(__fentry__)
#ifdef CONFIG_FRAME_POINTER #ifdef CONFIG_FRAME_POINTER
/* Save parent and function stack frames (rip and rbp) */ /* Save parent and function stack frames (rip and rbp) */
# define MCOUNT_FRAME_SIZE (8+16*2) # define MCOUNT_FRAME_SIZE (8+16*2)
...@@ -132,9 +129,10 @@ EXPORT_SYMBOL(__fentry__) ...@@ -132,9 +129,10 @@ EXPORT_SYMBOL(__fentry__)
#ifdef CONFIG_DYNAMIC_FTRACE #ifdef CONFIG_DYNAMIC_FTRACE
SYM_FUNC_START(function_hook) SYM_FUNC_START(__fentry__)
retq retq
SYM_FUNC_END(function_hook) SYM_FUNC_END(__fentry__)
EXPORT_SYMBOL(__fentry__)
SYM_FUNC_START(ftrace_caller) SYM_FUNC_START(ftrace_caller)
/* save_mcount_regs fills in first two parameters */ /* save_mcount_regs fills in first two parameters */
...@@ -248,7 +246,7 @@ SYM_FUNC_END(ftrace_regs_caller) ...@@ -248,7 +246,7 @@ SYM_FUNC_END(ftrace_regs_caller)
#else /* ! CONFIG_DYNAMIC_FTRACE */ #else /* ! CONFIG_DYNAMIC_FTRACE */
SYM_FUNC_START(function_hook) SYM_FUNC_START(__fentry__)
cmpq $ftrace_stub, ftrace_trace_function cmpq $ftrace_stub, ftrace_trace_function
jnz trace jnz trace
...@@ -279,7 +277,8 @@ trace: ...@@ -279,7 +277,8 @@ trace:
restore_mcount_regs restore_mcount_regs
jmp fgraph_trace jmp fgraph_trace
SYM_FUNC_END(function_hook) SYM_FUNC_END(__fentry__)
EXPORT_SYMBOL(__fentry__)
#endif /* CONFIG_DYNAMIC_FTRACE */ #endif /* CONFIG_DYNAMIC_FTRACE */
#ifdef CONFIG_FUNCTION_GRAPH_TRACER #ifdef CONFIG_FUNCTION_GRAPH_TRACER
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment