Commit 530b4ddd authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar
Browse files

objtool: Handle per arch retpoline naming



The __x86_indirect_ naming is obviously not generic. Shorten to allow
matching some additional magic names later.

Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Reviewed-by: default avatarMiroslav Benes <mbenes@suse.cz>
Link: https://lkml.kernel.org/r/20210326151259.630296706@infradead.org
parent bcb1b6ff
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -648,3 +648,8 @@ int arch_decode_hint_reg(struct instruction *insn, u8 sp_reg)

	return 0;
}

bool arch_is_retpoline(struct symbol *sym)
{
	return !strncmp(sym->name, "__x86_indirect_", 15);
}
+7 −2
Original line number Diff line number Diff line
@@ -850,6 +850,11 @@ static int add_ignore_alternatives(struct objtool_file *file)
	return 0;
}

__weak bool arch_is_retpoline(struct symbol *sym)
{
	return false;
}

/*
 * Find the destination instructions for all jumps.
 */
@@ -872,7 +877,7 @@ static int add_jump_destinations(struct objtool_file *file)
		} else if (reloc->sym->type == STT_SECTION) {
			dest_sec = reloc->sym->sec;
			dest_off = arch_dest_reloc_offset(reloc->addend);
		} else if (!strncmp(reloc->sym->name, "__x86_indirect_thunk_", 21)) {
		} else if (arch_is_retpoline(reloc->sym)) {
			/*
			 * Retpoline jumps are really dynamic jumps in
			 * disguise, so convert them accordingly.
@@ -1026,7 +1031,7 @@ static int add_call_destinations(struct objtool_file *file)
				return -1;
			}

		} else if (!strncmp(reloc->sym->name, "__x86_indirect_thunk_", 21)) {
		} else if (arch_is_retpoline(reloc->sym)) {
			/*
			 * Retpoline calls are really dynamic calls in
			 * disguise, so convert them accordingly.
+2 −0
Original line number Diff line number Diff line
@@ -86,4 +86,6 @@ const char *arch_nop_insn(int len);

int arch_decode_hint_reg(struct instruction *insn, u8 sp_reg);

bool arch_is_retpoline(struct symbol *sym);

#endif /* _ARCH_H */