From: "tip-bot2 for Josh Poimboeuf" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Josh Poimboeuf <jpoimboe@kernel.org>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: objtool/core] objtool: Update documentation
Date: Mon, 17 Mar 2025 10:46:30 -0000 [thread overview]
Message-ID: <174220839062.14745.16055592795155388481.tip-bot2@tip-bot2> (raw)
In-Reply-To: <2552ee8b48631127bf269359647a7389edf5f002.1741975349.git.jpoimboe@kernel.org>
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: dd95beba97b61ed53e6c96b5a43fbc9edf07c033
Gitweb: https://git.kernel.org/tip/dd95beba97b61ed53e6c96b5a43fbc9edf07c033
Author: Josh Poimboeuf <jpoimboe@kernel.org>
AuthorDate: Fri, 14 Mar 2025 12:29:02 -07:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 17 Mar 2025 11:36:00 +01:00
objtool: Update documentation
Fix some outdated information in the objtool doc.
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/2552ee8b48631127bf269359647a7389edf5f002.1741975349.git.jpoimboe@kernel.org
---
tools/objtool/Documentation/objtool.txt | 95 +++++++++++++-----------
1 file changed, 53 insertions(+), 42 deletions(-)
diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Documentation/objtool.txt
index 87950a7..28ac57b 100644
--- a/tools/objtool/Documentation/objtool.txt
+++ b/tools/objtool/Documentation/objtool.txt
@@ -28,6 +28,15 @@ Objtool has the following features:
sites, enabling the kernel to patch them inline, to prevent "thunk
funneling" for both security and performance reasons
+- Return thunk validation -- validates return thunks are used for
+ certain CPU mitigations including Retbleed and SRSO
+
+- Return thunk annotation -- annotates all return thunk sites so kernel
+ can patch them inline, depending on enabled mitigations
+
+- Return thunk training valiation -- validate that all entry paths
+ untrain a "safe return" before the first return (or call)
+
- Non-instrumentation validation -- validates non-instrumentable
("noinstr") code rules, preventing instrumentation in low-level C
entry code
@@ -53,6 +62,9 @@ Objtool has the following features:
- Function entry annotation -- annotates function entries, enabling
kernel function tracing
+- Function preamble (prefix) annotation and/or symbol generation -- used
+ for FineIBT and call depth tracking
+
- Other toolchain hacks which will go unmentioned at this time...
Each feature can be enabled individually or in combination using the
@@ -197,19 +209,17 @@ To achieve the validation, objtool enforces the following rules:
1. Each callable function must be annotated as such with the ELF
function type. In asm code, this is typically done using the
- ENTRY/ENDPROC macros. If objtool finds a return instruction
+ SYM_FUNC_{START,END} macros. If objtool finds a return instruction
outside of a function, it flags an error since that usually indicates
callable code which should be annotated accordingly.
This rule is needed so that objtool can properly identify each
callable function in order to analyze its stack metadata.
-2. Conversely, each section of code which is *not* callable should *not*
- be annotated as an ELF function. The ENDPROC macro shouldn't be used
- in this case.
-
- This rule is needed so that objtool can ignore non-callable code.
- Such code doesn't have to follow any of the other rules.
+2. Conversely, each section of code which is *not* callable, or is
+ otherwise doing funny things with the stack or registers, should
+ *not* be annotated as an ELF function. Rather, SYM_CODE_{START,END}
+ should be used along with unwind hints.
3. Each callable function which calls another function must have the
correct frame pointer logic, if required by CONFIG_FRAME_POINTER or
@@ -221,7 +231,7 @@ To achieve the validation, objtool enforces the following rules:
function B, the _caller_ of function A will be skipped on the stack
trace.
-4. Dynamic jumps and jumps to undefined symbols are only allowed if:
+4. Indirect jumps and jumps to undefined symbols are only allowed if:
a) the jump is part of a switch statement; or
@@ -304,20 +314,21 @@ the objtool maintainers.
001e 2823e: 80 ce 02 or $0x2,%dh
...
+
2. file.o: warning: objtool: .text+0x53: unreachable instruction
Objtool couldn't find a code path to reach the instruction.
If the error is for an asm file, and the instruction is inside (or
reachable from) a callable function, the function should be annotated
- with the ENTRY/ENDPROC macros (ENDPROC is the important one).
- Otherwise, the code should probably be annotated with the unwind hint
- macros in asm/unwind_hints.h so objtool and the unwinder can know the
- stack state associated with the code.
+ with the SYM_FUNC_START and SYM_FUNC_END macros.
+
+ Otherwise, SYM_CODE_START can be used. In that case the code needs
+ to be annotated with unwind hint macros.
+
+ If you're sure the code won't affect the reliability of runtime stack
+ traces and want objtool to ignore it, see "Adding exceptions" below.
- If you're 100% sure the code won't affect stack traces, or if you're
- a just a bad person, you can tell objtool to ignore it. See the
- "Adding exceptions" section below.
3. file.o: warning: objtool: foo+0x48c: bar() missing __noreturn in .c/.h or NORETURN() in noreturns.h
@@ -326,6 +337,7 @@ the objtool maintainers.
declaration and its definition, and must have a NORETURN() annotation
in tools/objtool/noreturns.h.
+
4. file.o: warning: objtool: func(): can't find starting instruction
or
file.o: warning: objtool: func()+0x11dd: can't decode instruction
@@ -339,23 +351,21 @@ the objtool maintainers.
This is a kernel entry/exit instruction like sysenter or iret. Such
instructions aren't allowed in a callable function, and are most
- likely part of the kernel entry code. They should usually not have
- the callable function annotation (ENDPROC) and should always be
- annotated with the unwind hint macros in asm/unwind_hints.h.
+ likely part of the kernel entry code. Such code should probably be
+ placed in a SYM_FUNC_CODE block with unwind hints.
6. file.o: warning: objtool: func()+0x26: sibling call from callable instruction with modified stack frame
- This is a dynamic jump or a jump to an undefined symbol. Objtool
- assumed it's a sibling call and detected that the frame pointer
- wasn't first restored to its original state.
+ This is a branch to an UNDEF symbol. Objtool assumed it's a
+ sibling call and detected that the stack wasn't first restored to its
+ original state.
- If it's not really a sibling call, you may need to move the
- destination code to the local file.
+ If it's not really a sibling call, you may need to use unwind hints
+ and/or move the destination code to the local file.
If the instruction is not actually in a callable function (e.g.
- kernel entry code), change ENDPROC to END and annotate manually with
- the unwind hint macros in asm/unwind_hints.h.
+ kernel entry code), use SYM_CODE_{START,END} and unwind hints.
7. file: warning: objtool: func()+0x5c: stack state mismatch
@@ -371,8 +381,8 @@ the objtool maintainers.
Another possibility is that the code has some asm or inline asm which
does some unusual things to the stack or the frame pointer. In such
- cases it's probably appropriate to use the unwind hint macros in
- asm/unwind_hints.h.
+ cases it's probably appropriate to use SYM_FUNC_CODE with unwind
+ hints.
8. file.o: warning: objtool: funcA() falls through to next function funcB()
@@ -382,17 +392,16 @@ the objtool maintainers.
can fall through into the next function. There could be different
reasons for this:
- 1) funcA()'s last instruction is a call to a "noreturn" function like
+ a) funcA()'s last instruction is a call to a "noreturn" function like
panic(). In this case the noreturn function needs to be added to
objtool's hard-coded global_noreturns array. Feel free to bug the
objtool maintainer, or you can submit a patch.
- 2) funcA() uses the unreachable() annotation in a section of code
+ b) funcA() uses the unreachable() annotation in a section of code
that is actually reachable.
- 3) If funcA() calls an inline function, the object code for funcA()
- might be corrupt due to a gcc bug. For more details, see:
- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70646
+ c) Some undefined behavior like divide by zero.
+
9. file.o: warning: objtool: funcA() call to funcB() with UACCESS enabled
@@ -430,24 +439,26 @@ the objtool maintainers.
This limitation can be overcome by massaging the alternatives with
NOPs to shift the stack changes around so they no longer conflict.
+
11. file.o: warning: unannotated intra-function call
- This warning means that a direct call is done to a destination which
- is not at the beginning of a function. If this is a legit call, you
- can remove this warning by putting the ANNOTATE_INTRA_FUNCTION_CALL
- directive right before the call.
+ This warning means that a direct call is done to a destination which
+ is not at the beginning of a function. If this is a legit call, you
+ can remove this warning by putting the ANNOTATE_INTRA_FUNCTION_CALL
+ directive right before the call.
+
12. file.o: warning: func(): not an indirect call target
- This means that objtool is running with --ibt and a function expected
- to be an indirect call target is not. In particular, this happens for
- init_module() or cleanup_module() if a module relies on these special
- names and does not use module_init() / module_exit() macros to create
- them.
+ This means that objtool is running with --ibt and a function
+ expected to be an indirect call target is not. In particular, this
+ happens for init_module() or cleanup_module() if a module relies on
+ these special names and does not use module_init() / module_exit()
+ macros to create them.
If the error doesn't seem to make sense, it could be a bug in objtool.
-Feel free to ask the objtool maintainer for help.
+Feel free to ask objtool maintainers for help.
Adding exceptions
next prev parent reply other threads:[~2025-03-17 10:46 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-14 19:28 [PATCH 00/13] Fail the build on objtool warnings Josh Poimboeuf
2025-03-14 19:28 ` [PATCH 01/13] x86/traps: Make exc_double_fault() consistently noreturn Josh Poimboeuf
2025-03-17 8:26 ` Brendan Jackman
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-17 10:47 ` [PATCH 01/13] " Miroslav Benes
2025-03-14 19:29 ` [PATCH 02/13] objtool: Fix error handling inconsistencies in check() Josh Poimboeuf
2025-03-17 8:29 ` Brendan Jackman
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-17 10:47 ` [PATCH 02/13] " Miroslav Benes
2025-03-14 19:29 ` [PATCH 03/13] objtool: Improve __noreturn annotation warning Josh Poimboeuf
2025-03-17 8:31 ` Brendan Jackman
2025-03-17 10:36 ` Miroslav Benes
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-14 19:29 ` [PATCH 04/13] objtool: Update documentation Josh Poimboeuf
2025-03-17 8:47 ` Brendan Jackman
2025-03-17 10:46 ` tip-bot2 for Josh Poimboeuf [this message]
2025-03-17 10:46 ` Miroslav Benes
2025-03-14 19:29 ` [PATCH 05/13] objtool: Increase per-function WARN_FUNC() rate limit Josh Poimboeuf
2025-03-17 9:15 ` Brendan Jackman
2025-03-17 12:29 ` Miroslav Benes
2025-03-18 10:59 ` Brendan Jackman
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-14 19:29 ` [PATCH 06/13] objtool: Remove --unret dependency on --rethunk Josh Poimboeuf
2025-03-14 19:38 ` Peter Zijlstra
2025-03-14 19:52 ` Josh Poimboeuf
2025-03-14 19:58 ` Peter Zijlstra
2025-03-17 12:33 ` Miroslav Benes
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-14 19:29 ` [PATCH 07/13] objtool: Consolidate option validation Josh Poimboeuf
2025-03-17 9:19 ` Brendan Jackman
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-17 12:35 ` [PATCH 07/13] " Miroslav Benes
2025-03-14 19:29 ` [PATCH 08/13] objtool: Upgrade "Linked object detected" warning to error Josh Poimboeuf
2025-03-17 9:21 ` Brendan Jackman
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-17 12:38 ` [PATCH 08/13] " Miroslav Benes
2025-03-14 19:29 ` [PATCH 09/13] objtool: Add --output option Josh Poimboeuf
2025-03-17 9:40 ` Brendan Jackman
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-17 12:48 ` [PATCH 09/13] " Miroslav Benes
2025-03-14 19:29 ` [PATCH 10/13] objtool: Add --Werror option Josh Poimboeuf
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-17 12:53 ` [PATCH 10/13] " Miroslav Benes
2025-03-14 19:29 ` [PATCH 11/13] objtool: Change "warning:" to "error:" for --Werror Josh Poimboeuf
2025-03-17 9:42 ` Brendan Jackman
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-17 13:04 ` [PATCH 11/13] " Miroslav Benes
2025-03-14 19:29 ` [PATCH 12/13] objtool: Create backup on error and print args Josh Poimboeuf
2025-03-17 9:53 ` Brendan Jackman
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-17 14:09 ` [PATCH 12/13] " Miroslav Benes
2025-03-14 19:29 ` [PATCH 13/13] objtool: Add CONFIG_OBJTOOL_WERROR Josh Poimboeuf
2025-03-16 0:41 ` Ingo Molnar
2025-03-16 1:49 ` Josh Poimboeuf
2025-03-16 11:56 ` Ingo Molnar
2025-03-18 4:55 ` Josh Poimboeuf
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-17 11:07 ` tip-bot2 for Josh Poimboeuf
2025-03-17 21:27 ` Ingo Molnar
2025-03-18 0:05 ` Josh Poimboeuf
2025-03-20 17:10 ` Steven Rostedt
2025-03-18 11:51 ` Ingo Molnar
2025-03-18 14:26 ` Josh Poimboeuf
2025-03-20 8:51 ` Ingo Molnar
2025-03-18 0:27 ` Josh Poimboeuf
2025-03-18 4:59 ` Josh Poimboeuf
2025-03-17 14:14 ` [PATCH 13/13] " Miroslav Benes
2025-03-23 7:50 ` Josh Poimboeuf
-- strict thread matches above, loose matches on Subject: below --
2022-04-18 16:50 [PATCH v2 25/25] objtool: Update documentation Josh Poimboeuf
2022-04-22 10:34 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=174220839062.14745.16055592795155388481.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®