Skip to content

Commit 2d49b72

Browse files
author
Peter Zijlstra
committed
objtool: Only rewrite unconditional retpoline thunk calls
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 <[email protected]> Reported-by: Nathan Chancellor <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Nathan Chancellor <[email protected]>
1 parent 584fd3b commit 2d49b72

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tools/objtool/arch/x86/decode.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,10 @@ int arch_rewrite_retpolines(struct objtool_file *file)
747747

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

750+
if (insn->type != INSN_JUMP_DYNAMIC &&
751+
insn->type != INSN_CALL_DYNAMIC)
752+
continue;
753+
750754
if (!strcmp(insn->sec->name, ".text.__x86.indirect_thunk"))
751755
continue;
752756

0 commit comments

Comments
 (0)