Skip to content

Commit

Permalink
objtool: Skip magical retpoline .altinstr_replacement
Browse files Browse the repository at this point in the history
When the .altinstr_replacement is a retpoline, skip the alternative.
We already special case retpolines anyway.

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/20210326151300.259429287@infradead.org
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Apr 2, 2021
1 parent 7bd2a60 commit 50e7b4a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tools/objtool/special.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ static int get_alt_entry(struct elf *elf, struct special_entry *entry,
return -1;
}

/*
* Skip retpoline .altinstr_replacement... we already rewrite the
* instructions for retpolines anyway, see arch_is_retpoline()
* usage in add_{call,jump}_destinations().
*/
if (arch_is_retpoline(new_reloc->sym))
return 1;

alt->new_sec = new_reloc->sym->sec;
alt->new_off = (unsigned int)new_reloc->addend;

Expand Down Expand Up @@ -154,7 +162,9 @@ int special_get_alts(struct elf *elf, struct list_head *alts)
memset(alt, 0, sizeof(*alt));

ret = get_alt_entry(elf, entry, sec, idx, alt);
if (ret)
if (ret > 0)
continue;
if (ret < 0)
return ret;

list_add_tail(&alt->list, alts);
Expand Down

0 comments on commit 50e7b4a

Please sign in to comment.