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
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+8−3
@@ -175,6 +175,7 @@ SYM_INNER_LABEL(ftrace_caller_end, SYM_L_GLOBAL) · 174 unmodified lines
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) · 101 unmodified lines
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: · 23 unmodified lines
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) · 18 unmodified lines
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+6−0
@@ -143,6 +143,12 @@ struct unwind_hint { · 142 unmodified lines
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+6−0
@@ -143,6 +143,12 @@ struct unwind_hint { · 142 unmodified lines
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

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