summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@redhat.com>2019-07-17 21:36:57 -0400
committerThomas Gleixner <tglx@linutronix.de>2019-07-18 15:01:10 -0400
commitb68b9907069a8d3a65bc16a35360bf8f8603c8fa (patch)
treeca8c51c1d05a67376139dd523809d6d84d8ccf57 /tools
parent9fe7b7642fe2c5158904d06fe31b740ca0695a01 (diff)
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 <ndesaulniers@google.com> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Nick Desaulniers <ndesaulniers@google.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/30d4c758b267ef487fb97e6ecb2f148ad007b554.1563413318.git.jpoimboe@redhat.com
Diffstat (limited to 'tools')
-rw-r--r--tools/objtool/arch.h1
-rw-r--r--tools/objtool/check.c12
2 files changed, 11 insertions, 2 deletions
diff --git a/tools/objtool/arch.h b/tools/objtool/arch.h
index 50448c0c4bca..ced3765c4f44 100644
--- a/tools/objtool/arch.h
+++ b/tools/objtool/arch.h
@@ -15,6 +15,7 @@ enum insn_type {
15 INSN_JUMP_CONDITIONAL, 15 INSN_JUMP_CONDITIONAL,
16 INSN_JUMP_UNCONDITIONAL, 16 INSN_JUMP_UNCONDITIONAL,
17 INSN_JUMP_DYNAMIC, 17 INSN_JUMP_DYNAMIC,
18 INSN_JUMP_DYNAMIC_CONDITIONAL,
18 INSN_CALL, 19 INSN_CALL,
19 INSN_CALL_DYNAMIC, 20 INSN_CALL_DYNAMIC,
20 INSN_RETURN, 21 INSN_RETURN,
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 04572a049cfc..5f26620f13f5 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -575,7 +575,11 @@ static int add_jump_destinations(struct objtool_file *file)
575 * Retpoline jumps are really dynamic jumps in 575 * Retpoline jumps are really dynamic jumps in
576 * disguise, so convert them accordingly. 576 * disguise, so convert them accordingly.
577 */ 577 */
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
579 insn->retpoline_safe = true; 583 insn->retpoline_safe = true;
580 continue; 584 continue;
581 } else { 585 } else {
@@ -2114,13 +2118,17 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
2114 break; 2118 break;
2115 2119
2116 case INSN_JUMP_DYNAMIC: 2120 case INSN_JUMP_DYNAMIC:
2121 case INSN_JUMP_DYNAMIC_CONDITIONAL:
2117 if (func && is_sibling_call(insn)) { 2122 if (func && is_sibling_call(insn)) {
2118 ret = validate_sibling_call(insn, &state); 2123 ret = validate_sibling_call(insn, &state);
2119 if (ret) 2124 if (ret)
2120 return ret; 2125 return ret;
2121 } 2126 }
2122 2127
2123 return 0; 2128 if (insn->type == INSN_JUMP_DYNAMIC)
2129 return 0;
2130
2131 break;
2124 2132
2125 case INSN_CONTEXT_SWITCH: 2133 case INSN_CONTEXT_SWITCH:
2126 if (func && (!next_insn || !next_insn->hint)) { 2134 if (func && (!next_insn || !next_insn->hint)) {