]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
objtool: Handle per arch retpoline naming
authorPeter Zijlstra <peterz@infradead.org>
Fri, 26 Mar 2021 15:12:04 +0000 (16:12 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 25 Jul 2022 09:26:14 +0000 (11:26 +0200)
commit 530b4ddd9dd92b263081f5c7786d39a8129c8b2d upstream.

The __x86_indirect_ naming is obviously not generic. Shorten to allow
matching some additional magic names later.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Link: https://lkml.kernel.org/r/20210326151259.630296706@infradead.org
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/objtool/arch.h
tools/objtool/arch/x86/decode.c
tools/objtool/check.c

index 5e3f3ea8bb895de8753c961098c4651dd8aef8bc..82896d7615f5585e8b60c74c1417a2d62cf61336 100644 (file)
@@ -86,4 +86,6 @@ const char *arch_nop_insn(int len);
 
 int arch_decode_hint_reg(struct instruction *insn, u8 sp_reg);
 
+bool arch_is_retpoline(struct symbol *sym);
+
 #endif /* _ARCH_H */
index 6f5a45754ad81cac368f8e27a6d53fc942e73978..a540c8cda8e1ca77b9c4b41c8ac810232f702ea3 100644 (file)
@@ -620,3 +620,8 @@ int arch_decode_hint_reg(struct instruction *insn, u8 sp_reg)
 
        return 0;
 }
+
+bool arch_is_retpoline(struct symbol *sym)
+{
+       return !strncmp(sym->name, "__x86_indirect_", 15);
+}
index da78811ffda5e8f6d4cd10fd3c726ea070d92883..5e407ec95949b1e4d1bd19105f9d33841be46e29 100644 (file)
@@ -778,6 +778,11 @@ static int add_ignore_alternatives(struct objtool_file *file)
        return 0;
 }
 
+__weak bool arch_is_retpoline(struct symbol *sym)
+{
+       return false;
+}
+
 /*
  * Find the destination instructions for all jumps.
  */
@@ -800,7 +805,7 @@ static int add_jump_destinations(struct objtool_file *file)
                } else if (reloc->sym->type == STT_SECTION) {
                        dest_sec = reloc->sym->sec;
                        dest_off = arch_dest_reloc_offset(reloc->addend);
-               } else if (!strncmp(reloc->sym->name, "__x86_indirect_thunk_", 21)) {
+               } else if (arch_is_retpoline(reloc->sym)) {
                        /*
                         * Retpoline jumps are really dynamic jumps in
                         * disguise, so convert them accordingly.
@@ -954,7 +959,7 @@ static int add_call_destinations(struct objtool_file *file)
                                return -1;
                        }
 
-               } else if (!strncmp(reloc->sym->name, "__x86_indirect_thunk_", 21)) {
+               } else if (arch_is_retpoline(reloc->sym)) {
                        /*
                         * Retpoline calls are really dynamic calls in
                         * disguise, so convert them accordingly.