From: Peter Zijlstra <peterz@infradead.org>
To: jpoimboe@kernel.org
Cc: chenhuacai@kernel.org, kernel@xen0n.name, x86@kernel.org,
peterz@infradead.org, loongarch@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 15/16] objtool: Fix ANNOTATE_REACHABLE to be a normal annotation
Date: Thu, 28 Nov 2024 10:39:06 +0100 [thread overview]
Message-ID: <20241128094312.494176035@infradead.org> (raw)
In-Reply-To: 20241128093851.469225872@infradead.org
Currently REACHABLE is weird for being on the instruction after the
instruction it modifies.
Since all REACHABLE annotations have an explicit instruction, flip
them around.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/loongarch/include/asm/bug.h | 2 +-
arch/x86/entry/entry_64.S | 5 ++---
arch/x86/include/asm/bug.h | 2 +-
arch/x86/include/asm/irq_stack.h | 4 ++--
include/linux/objtool.h | 4 ++--
tools/objtool/check.c | 23 -----------------------
6 files changed, 8 insertions(+), 32 deletions(-)
--- a/arch/loongarch/include/asm/bug.h
+++ b/arch/loongarch/include/asm/bug.h
@@ -45,7 +45,7 @@
#define __WARN_FLAGS(flags) \
do { \
instrumentation_begin(); \
- __BUG_FLAGS(BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE);\
+ __BUG_FLAGS(BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE(10001b));\
instrumentation_end(); \
} while (0)
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -308,10 +308,9 @@ SYM_CODE_END(xen_error_entry)
movq $-1, ORIG_RAX(%rsp) /* no syscall to restart */
.endif
- call \cfunc
-
/* For some configurations \cfunc ends up being a noreturn. */
ANNOTATE_REACHABLE
+ call \cfunc
jmp error_return
.endm
@@ -529,10 +528,10 @@ SYM_CODE_START(\asmsym)
movq %rsp, %rdi /* pt_regs pointer into first argument */
movq ORIG_RAX(%rsp), %rsi /* get error code into 2nd argument*/
movq $-1, ORIG_RAX(%rsp) /* no syscall to restart */
- call \cfunc
/* For some configurations \cfunc ends up being a noreturn. */
ANNOTATE_REACHABLE
+ call \cfunc
jmp paranoid_exit
--- a/arch/x86/include/asm/bug.h
+++ b/arch/x86/include/asm/bug.h
@@ -92,7 +92,7 @@ do { \
do { \
__auto_type __flags = BUGFLAG_WARNING|(flags); \
instrumentation_begin(); \
- _BUG_FLAGS(ASM_UD2, __flags, ANNOTATE_REACHABLE); \
+ _BUG_FLAGS(ASM_UD2, __flags, ANNOTATE_REACHABLE(1b)); \
instrumentation_end(); \
} while (0)
--- a/arch/x86/include/asm/irq_stack.h
+++ b/arch/x86/include/asm/irq_stack.h
@@ -100,8 +100,8 @@
}
#define ASM_CALL_ARG0 \
- "call %c[__func] \n" \
- ANNOTATE_REACHABLE
+ "1: call %c[__func] \n" \
+ ANNOTATE_REACHABLE(1b)
#define ASM_CALL_ARG1 \
"movq %[arg1], %%rdi \n" \
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -177,11 +177,11 @@
*/
#define ANNOTATE_UNRET_BEGIN ASM_ANNOTATE(ANNOTYPE_UNRET_BEGIN)
/*
- * This should be used directly after an instruction that is considered
+ * This should be used to refer to an instruction that is considered
* terminating, like a noreturn CALL or UD2 when we know they are not -- eg
* WARN using UD2.
*/
-#define ANNOTATE_REACHABLE ASM_ANNOTATE(ANNOTYPE_REACHABLE)
+#define ANNOTATE_REACHABLE(label) __ASM_ANNOTATE(label, ANNOTYPE_REACHABLE)
#else
#define ANNOTATE_NOENDBR ANNOTATE type=ANNOTYPE_NOENDBR
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -614,19 +614,6 @@ static int init_pv_ops(struct objtool_fi
return 0;
}
-static struct instruction *find_last_insn(struct objtool_file *file,
- struct section *sec)
-{
- struct instruction *insn = NULL;
- unsigned int offset;
- unsigned int end = (sec->sh.sh_size > 10) ? sec->sh.sh_size - 10 : 0;
-
- for (offset = sec->sh.sh_size - 1; offset >= end && !insn; offset--)
- insn = find_insn(file, sec, offset);
-
- return insn;
-}
-
static int create_static_call_sections(struct objtool_file *file)
{
struct static_call_site *site;
@@ -2281,16 +2268,6 @@ static int read_annotate(struct objtool_
offset = reloc->sym->offset + reloc_addend(reloc);
insn = find_insn(file, reloc->sym->sec, offset);
- /*
- * Reachable annotations are 'funneh' and act on the previous instruction :/
- */
- if (type == ANNOTYPE_REACHABLE) {
- if (insn)
- insn = prev_insn_same_sec(file, insn);
- else if (offset == reloc->sym->sec->sh.sh_size)
- insn = find_last_insn(file, reloc->sym->sec);
- }
-
if (!insn) {
WARN("bad .discard.annotate_insn entry: %d of type %d", reloc_idx(reloc), type);
return -1;
next prev parent reply other threads:[~2024-11-28 9:44 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-28 9:38 [PATCH v2 00/16] objtool: Rewrite annotations Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 01/16] objtool: Generic annotation infrastructure Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 02/16] objtool: Convert ANNOTATE_NOENDBR to ANNOTATE Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 03/16] objtool: Convert ANNOTATE_RETPOLINE_SAFE " Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 04/16] objtool: Convert instrumentation_{begin,end}() " Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 05/16] objtool: Convert VALIDATE_UNRET_BEGIN " Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 06/16] objtool: Convert ANNOTATE_IGNORE_ALTERNATIVE " Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 07/16] objtool: Convert ANNOTATE_INTRA_FUNCTION_CALL " Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:38 ` [PATCH v2 08/16] objtool: Collapse annotate sequences Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 09/16] objtool: Collect more annotations in objtool.h Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 10/16] unreachable: Unify Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 11/16] x86: Convert unreachable() to BUG() Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-12-16 9:32 ` Peter Zijlstra
2024-12-24 9:47 ` [tip: objtool/core] x86/mm: " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 12/16] loongarch: Use ASM_REACHABLE Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 13/16] objtool: Remove annotate_{,un}reachable() Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 14/16] objtool: Convert {.UN}REACHABLE to ANNOTATE Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` Peter Zijlstra [this message]
2024-12-02 11:15 ` [tip: objtool/core] objtool: Fix ANNOTATE_REACHABLE to be a normal annotation tip-bot2 for Peter Zijlstra
2024-11-28 9:39 ` [PATCH v2 16/16] objtool: Warn about unknown annotation types Peter Zijlstra
2024-12-02 11:15 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2024-11-28 18:44 ` [PATCH v2 00/16] objtool: Rewrite annotations 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=20241128094312.494176035@infradead.org \
--to=peterz@infradead.org \
--cc=chenhuacai@kernel.org \
--cc=jpoimboe@kernel.org \
--cc=kernel@xen0n.name \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--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