History

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

Josh Poimboeuf committed 4 years ago

Commit 7b6c7a81 parent dcea9974 files · +20 −7Browse files

Unified · Split

4 files
  1. arch/x86/kernel/Makefile +0 −4
  2. arch/x86/kernel/ftrace_64.S +8 −3
  3. include/linux/objtool.h +6 −0
  4. tools/include/linux/objtool.h +6 −0
arch/x86/kernel/Makefile+0−4
@@ -36,10 +36,6 @@ KCSAN_SANITIZE := n · 35 unmodified lines
36 36
37OBJECT_FILES_NON_STANDARD_test_nx.o := y37OBJECT_FILES_NON_STANDARD_test_nx.o := y
38 38
39ifdef CONFIG_FRAME_POINTER
40OBJECT_FILES_NON_STANDARD_ftrace_$(BITS).o := y
41endif
42
43# If instrumentation of this dir is enabled, boot hangs during first second.39# If instrumentation of this dir is enabled, boot hangs during first second.
44# Probably could be more selective here, but note that files related to irqs,40# Probably could be more selective here, but note that files related to irqs,
45# boot, dumpstack/stacktrace, etc are either non-interesting or can lead to41# boot, dumpstack/stacktrace, etc are either non-interesting or can lead to
arch/x86/kernel/ftrace_64.S+8−3
@@ -175,6 +175,7 @@ SYM_INNER_LABEL(ftrace_caller_end, SYM_L_GLOBAL) · 174 unmodified lines
175 175
176 jmp ftrace_epilogue176 jmp ftrace_epilogue
177SYM_FUNC_END(ftrace_caller);177SYM_FUNC_END(ftrace_caller);
178STACK_FRAME_NON_STANDARD_FP(ftrace_caller)
178 179
179SYM_FUNC_START(ftrace_epilogue)180SYM_FUNC_START(ftrace_epilogue)
180/*181/*
@@ -282,6 +283,7 @@ SYM_INNER_LABEL(ftrace_regs_caller_end, SYM_L_GLOBAL) · 101 unmodified lines
282 jmp ftrace_epilogue283 jmp ftrace_epilogue
283 284
284SYM_FUNC_END(ftrace_regs_caller)285SYM_FUNC_END(ftrace_regs_caller)
286STACK_FRAME_NON_STANDARD_FP(ftrace_regs_caller)
285 287
286 288
287#else /* ! CONFIG_DYNAMIC_FTRACE */289#else /* ! CONFIG_DYNAMIC_FTRACE */
@@ -311,10 +313,14 @@ trace: · 23 unmodified lines
311 jmp ftrace_stub313 jmp ftrace_stub
312SYM_FUNC_END(__fentry__)314SYM_FUNC_END(__fentry__)
313EXPORT_SYMBOL(__fentry__)315EXPORT_SYMBOL(__fentry__)
316STACK_FRAME_NON_STANDARD_FP(__fentry__)
317
314#endif /* CONFIG_DYNAMIC_FTRACE */318#endif /* CONFIG_DYNAMIC_FTRACE */
315 319
316#ifdef CONFIG_FUNCTION_GRAPH_TRACER320#ifdef CONFIG_FUNCTION_GRAPH_TRACER
317SYM_FUNC_START(return_to_handler)321SYM_CODE_START(return_to_handler)
322 UNWIND_HINT_EMPTY
323 ANNOTATE_NOENDBR
318 subq $16, %rsp324 subq $16, %rsp
319 325
320 /* Save the return values */326 /* Save the return values */
@@ -339,7 +345,6 @@ SYM_FUNC_START(return_to_handler) · 18 unmodified lines
339 int3345 int3
340.Ldo_rop:346.Ldo_rop:
341 mov %rdi, (%rsp)347 mov %rdi, (%rsp)
342 UNWIND_HINT_FUNC
343 RET348 RET
344SYM_FUNC_END(return_to_handler)349SYM_CODE_END(return_to_handler)
345#endif350#endif
include/linux/objtool.h+6−0
@@ -143,6 +143,12 @@ struct unwind_hint { · 142 unmodified lines
143 .popsection143 .popsection
144.endm144.endm
145 145
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
146.macro ANNOTATE_NOENDBR152.macro ANNOTATE_NOENDBR
147.Lhere_\@:153.Lhere_\@:
148 .pushsection .discard.noendbr154 .pushsection .discard.noendbr
tools/include/linux/objtool.h+6−0
@@ -143,6 +143,12 @@ struct unwind_hint { · 142 unmodified lines
143 .popsection143 .popsection
144.endm144.endm
145 145
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
146.macro ANNOTATE_NOENDBR152.macro ANNOTATE_NOENDBR
147.Lhere_\@:153.Lhere_\@:
148 .pushsection .discard.noendbr154 .pushsection .discard.noendbr

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t