Skip to content

Commit b68b990

Browse files
jpoimboeKAGA-KOKO
authored andcommitted
objtool: Support conditional retpolines
A Clang-built kernel is showing the following warning: arch/x86/kernel/platform-quirks.o: warning: objtool: x86_early_init_platform_quirks()+0x84: unreachable instruction That corresponds to this code: 7e: 0f 85 00 00 00 00 jne 84 <x86_early_init_platform_quirks+0x84> 80: R_X86_64_PC32 __x86_indirect_thunk_r11-0x4 84: c3 retq This is a conditional retpoline sibling call, which is now possible thanks to retpolines. Objtool hasn't seen that before. It's incorrectly interpreting the conditional jump as an unconditional dynamic jump. Reported-by: Nick Desaulniers <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Nick Desaulniers <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/30d4c758b267ef487fb97e6ecb2f148ad007b554.1563413318.git.jpoimboe@redhat.com
1 parent 9fe7b76 commit b68b990

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

tools/objtool/arch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ enum insn_type {
1515
INSN_JUMP_CONDITIONAL,
1616
INSN_JUMP_UNCONDITIONAL,
1717
INSN_JUMP_DYNAMIC,
18+
INSN_JUMP_DYNAMIC_CONDITIONAL,
1819
INSN_CALL,
1920
INSN_CALL_DYNAMIC,
2021
INSN_RETURN,

tools/objtool/check.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,11 @@ static int add_jump_destinations(struct objtool_file *file)
575575
* Retpoline jumps are really dynamic jumps in
576576
* disguise, so convert them accordingly.
577577
*/
578-
insn->type = INSN_JUMP_DYNAMIC;
578+
if (insn->type == INSN_JUMP_UNCONDITIONAL)
579+
insn->type = INSN_JUMP_DYNAMIC;
580+
else
581+
insn->type = INSN_JUMP_DYNAMIC_CONDITIONAL;
582+
579583
insn->retpoline_safe = true;
580584
continue;
581585
} else {
@@ -2114,13 +2118,17 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
21142118
break;
21152119

21162120
case INSN_JUMP_DYNAMIC:
2121+
case INSN_JUMP_DYNAMIC_CONDITIONAL:
21172122
if (func && is_sibling_call(insn)) {
21182123
ret = validate_sibling_call(insn, &state);
21192124
if (ret)
21202125
return ret;
21212126
}
21222127

2123-
return 0;
2128+
if (insn->type == INSN_JUMP_DYNAMIC)
2129+
return 0;
2130+
2131+
break;
21242132

21252133
case INSN_CONTEXT_SWITCH:
21262134
if (func && (!next_insn || !next_insn->hint)) {

0 commit comments

Comments
 (0)