Skip to content

Commit

Permalink
objtool: Only rewrite unconditional retpoline thunk calls
Browse files Browse the repository at this point in the history
It turns out that the compilers generate conditional branches to the
retpoline thunks like:

  5d5:   0f 85 00 00 00 00       jne    5db <cpuidle_reflect+0x22>
	5d7: R_X86_64_PLT32     __x86_indirect_thunk_r11-0x4

while the rewrite can only handle JMP/CALL to the thunks. The result
is the alternative wrecking the code. Make sure to skip writing the
alternatives for conditional branches.

Fixes: 9bc0bb5 ("objtool/x86: Rewrite retpoline thunk calls")
Reported-by: Lukasz Majczak <lma@semihalf.com>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
  • Loading branch information
Peter Zijlstra committed Jun 11, 2021
1 parent 584fd3b commit 2d49b72
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tools/objtool/arch/x86/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,10 @@ int arch_rewrite_retpolines(struct objtool_file *file)

list_for_each_entry(insn, &file->retpoline_call_list, call_node) {

if (insn->type != INSN_JUMP_DYNAMIC &&
insn->type != INSN_CALL_DYNAMIC)
continue;

if (!strcmp(insn->sec->name, ".text.__x86.indirect_thunk"))
continue;

Expand Down

0 comments on commit 2d49b72

Please sign in to comment.