Skip to content

Commit 7b6c7a8

Browse files
committed
x86/ftrace: Remove OBJECT_FILES_NON_STANDARD usage
The file-wide OBJECT_FILES_NON_STANDARD annotation is used with CONFIG_FRAME_POINTER to tell objtool to skip the entire file when frame pointers are enabled. However that annotation is now deprecated because it doesn't work with IBT, where objtool runs on vmlinux.o instead of individual translation units. Instead, use more fine-grained function-specific annotations: - The 'save_mcount_regs' macro does funny things with the frame pointer. Use STACK_FRAME_NON_STANDARD_FP to tell objtool to ignore the functions using it. - The return_to_handler() "function" isn't actually a callable function. Instead of being called, it's returned to. The real return address isn't on the stack, so unwinding is already doomed no matter which unwinder is used. So just remove the STT_FUNC annotation, telling objtool to ignore it. That also removes the implicit ANNOTATE_NOENDBR, which now needs to be made explicit. Fixes the following warning: vmlinux.o: warning: objtool: __fentry__+0x16: return with modified stack frame Fixes: ed53a0d ("x86/alternative: Use .ibt_endbr_seal to seal indirect calls") Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> Link: https://lore.kernel.org/r/b7a7a42fe306aca37826043dac89e113a1acdbac.1654268610.git.jpoimboe@kernel.org
1 parent dcea997 commit 7b6c7a8

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

arch/x86/kernel/Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ KCSAN_SANITIZE := n
3636

3737
OBJECT_FILES_NON_STANDARD_test_nx.o := y
3838

39-
ifdef CONFIG_FRAME_POINTER
40-
OBJECT_FILES_NON_STANDARD_ftrace_$(BITS).o := y
41-
endif
42-
4339
# If instrumentation of this dir is enabled, boot hangs during first second.
4440
# Probably could be more selective here, but note that files related to irqs,
4541
# boot, dumpstack/stacktrace, etc are either non-interesting or can lead to

arch/x86/kernel/ftrace_64.S

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ SYM_INNER_LABEL(ftrace_caller_end, SYM_L_GLOBAL)
175175

176176
jmp ftrace_epilogue
177177
SYM_FUNC_END(ftrace_caller);
178+
STACK_FRAME_NON_STANDARD_FP(ftrace_caller)
178179

179180
SYM_FUNC_START(ftrace_epilogue)
180181
/*
@@ -282,6 +283,7 @@ SYM_INNER_LABEL(ftrace_regs_caller_end, SYM_L_GLOBAL)
282283
jmp ftrace_epilogue
283284

284285
SYM_FUNC_END(ftrace_regs_caller)
286+
STACK_FRAME_NON_STANDARD_FP(ftrace_regs_caller)
285287

286288

287289
#else /* ! CONFIG_DYNAMIC_FTRACE */
@@ -311,10 +313,14 @@ trace:
311313
jmp ftrace_stub
312314
SYM_FUNC_END(__fentry__)
313315
EXPORT_SYMBOL(__fentry__)
316+
STACK_FRAME_NON_STANDARD_FP(__fentry__)
317+
314318
#endif /* CONFIG_DYNAMIC_FTRACE */
315319

316320
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
317-
SYM_FUNC_START(return_to_handler)
321+
SYM_CODE_START(return_to_handler)
322+
UNWIND_HINT_EMPTY
323+
ANNOTATE_NOENDBR
318324
subq $16, %rsp
319325

320326
/* Save the return values */
@@ -339,7 +345,6 @@ SYM_FUNC_START(return_to_handler)
339345
int3
340346
.Ldo_rop:
341347
mov %rdi, (%rsp)
342-
UNWIND_HINT_FUNC
343348
RET
344-
SYM_FUNC_END(return_to_handler)
349+
SYM_CODE_END(return_to_handler)
345350
#endif

include/linux/objtool.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ struct unwind_hint {
143143
.popsection
144144
.endm
145145

146+
.macro STACK_FRAME_NON_STANDARD_FP func:req
147+
#ifdef CONFIG_FRAME_POINTER
148+
STACK_FRAME_NON_STANDARD \func
149+
#endif
150+
.endm
151+
146152
.macro ANNOTATE_NOENDBR
147153
.Lhere_\@:
148154
.pushsection .discard.noendbr

tools/include/linux/objtool.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ struct unwind_hint {
143143
.popsection
144144
.endm
145145

146+
.macro STACK_FRAME_NON_STANDARD_FP func:req
147+
#ifdef CONFIG_FRAME_POINTER
148+
STACK_FRAME_NON_STANDARD \func
149+
#endif
150+
.endm
151+
146152
.macro ANNOTATE_NOENDBR
147153
.Lhere_\@:
148154
.pushsection .discard.noendbr

0 commit comments

Comments
 (0)