]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
objtool: Fix ANNOTATE_REACHABLE to be a normal annotation
authorPeter Zijlstra <peterz@infradead.org>
Thu, 28 Nov 2024 09:39:06 +0000 (10:39 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 2 Dec 2024 11:01:44 +0000 (12:01 +0100)
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>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20241128094312.494176035@infradead.org
arch/loongarch/include/asm/bug.h
arch/x86/entry/entry_64.S
arch/x86/include/asm/bug.h
arch/x86/include/asm/irq_stack.h
include/linux/objtool.h
tools/objtool/check.c

index e25404a938822450c8e223bec5f76db9a45691fb..f6f254f2c5db59bcf0d7b5fedf5fbfb5a9adac0d 100644 (file)
@@ -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)
 
index 9248660ad4096acdb86d8b1842f81e1dc0dcfafe..f52dbe0ad93cd1e261f605e7cbd6209517859a07 100644 (file)
@@ -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
 
index dd8fb1779d972b3a2bce5517283167f721b12925..e85ac0c7c039ea95272a5525e2099ccadf386c1f 100644 (file)
@@ -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)
 
index 5455747ed918e20cbc4f17b31b1ee809cb18bba7..562a547c29a5bb048472f9f39ac1f9d2f0658156 100644 (file)
 }
 
 #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"             \
index e3cb13583fba29e42a7f5922fdf91fbe1b8e3e21..c722a921165ba38f92f8bedb7891470e6e2f7035 100644 (file)
  */
 #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
index 27d0c41535829683394de6c98440f939e2cb6199..26bdd3ebf5d2bf49588e111bff7cd1de946c0853 100644 (file)
@@ -614,19 +614,6 @@ static int init_pv_ops(struct objtool_file *file)
        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_file *file,
                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;