Re: [PATCH 4/9] x86/alternative: Implement .retpoline_sites support

From: Peter Zijlstra
Date: Wed Oct 20 2021 - 04:30:53 EST


On Tue, Oct 19, 2021 at 09:49:13AM -0700, Josh Poimboeuf wrote:

> @@ -1087,9 +1109,7 @@ static int add_jump_destinations(struct objtool_file *file)
> else
> insn->type = INSN_JUMP_DYNAMIC_CONDITIONAL;
>
> - list_add_tail(&insn->call_node,
> - &file->retpoline_call_list);
> -
> + add_call_dest(file, insn, reloc->sym, true);
> insn->retpoline_safe = true;
> continue;
> } else if (insn->func) {
> @@ -1218,20 +1238,14 @@ static int add_call_destinations(struct objtool_file *file)
>
> add_call_dest(file, insn, dest, false);
>
> - } else if (arch_is_retpoline(reloc->sym)) {
> + } else if (reloc->sym->retpoline) {
> /*
> * Retpoline calls are really dynamic calls in
> * disguise, so convert them accordingly.
> */
> insn->type = INSN_CALL_DYNAMIC;
> + add_call_dest(file, insn, reloc->sym, false);
> insn->retpoline_safe = true;
> -
> - list_add_tail(&insn->call_node,
> - &file->retpoline_call_list);
> -
> - remove_insn_ops(insn);
> - continue;
> -
> } else
> add_call_dest(file, insn, reloc->sym, false);
> }

So the problem with add_call_dest() like this, is that the instructions
now get to have ->call_dest set, which is really strange for
INSN_CALL_DYNAMIC etc.. At the very least it makes call_dest_name()
misbehave.

I've added add_retpoline_call() that also does the ->type frobbing and
->retpoline_safe marking instead.