Commit 77ac117b authored by Josh Poimboeuf's avatar Josh Poimboeuf Committed by Steven Rostedt (VMware)

ftrace/x86: Tell objtool to ignore nondeterministic ftrace stack layout

Objtool complains about the new ftrace direct trampoline code:

  arch/x86/kernel/ftrace_64.o: warning: objtool: ftrace_regs_caller()+0x190: stack state mismatch: cfa1=7+16 cfa2=7+24

Typically, code has a deterministic stack layout, such that at a given
instruction address, the stack frame size is always the same.

That's not the case for the new ftrace_regs_caller() code after it
adjusts the stack for the direct case.  Just plead ignorance and assume
it's always the non-direct path.  Note this creates a tiny window for
ORC to get confused.

Link: http://lkml.kernel.org/r/20191108225100.ea3bhsbdf6oerj6g@trebleReported-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent a3ad1a7e
...@@ -86,6 +86,14 @@ ...@@ -86,6 +86,14 @@
UNWIND_HINT sp_offset=\sp_offset UNWIND_HINT sp_offset=\sp_offset
.endm .endm
.macro UNWIND_HINT_SAVE
UNWIND_HINT type=UNWIND_HINT_TYPE_SAVE
.endm
.macro UNWIND_HINT_RESTORE
UNWIND_HINT type=UNWIND_HINT_TYPE_RESTORE
.endm
#else /* !__ASSEMBLY__ */ #else /* !__ASSEMBLY__ */
#define UNWIND_HINT(sp_reg, sp_offset, type, end) \ #define UNWIND_HINT(sp_reg, sp_offset, type, end) \
......
...@@ -178,6 +178,8 @@ ENTRY(ftrace_regs_caller) ...@@ -178,6 +178,8 @@ ENTRY(ftrace_regs_caller)
/* Save the current flags before any operations that can change them */ /* Save the current flags before any operations that can change them */
pushfq pushfq
UNWIND_HINT_SAVE
/* added 8 bytes to save flags */ /* added 8 bytes to save flags */
save_mcount_regs 8 save_mcount_regs 8
/* save_mcount_regs fills in first two parameters */ /* save_mcount_regs fills in first two parameters */
...@@ -250,8 +252,16 @@ GLOBAL(ftrace_regs_call) ...@@ -250,8 +252,16 @@ GLOBAL(ftrace_regs_call)
1: restore_mcount_regs 1: restore_mcount_regs
2:
/*
* The stack layout is nondetermistic here, depending on which path was
* taken. This confuses objtool and ORC, rightfully so. For now,
* pretend the stack always looks like the non-direct case.
*/
UNWIND_HINT_RESTORE
/* Restore flags */ /* Restore flags */
2: popfq popfq
/* /*
* As this jmp to ftrace_epilogue can be a short jump * As this jmp to ftrace_epilogue can be a short jump
......
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