Re: [PATCH 2/2] objtool: Optimize/fix retpoline alternative generation

From: Josh Poimboeuf
Date: Fri Oct 08 2021 - 03:23:44 EST


On Thu, Oct 07, 2021 at 11:22:13PM +0200, Peter Zijlstra wrote:
> When re-running objtool it will generate alterantives for all

"alternatives"

> retpoline hunks, even if they are already present.
>
> Discard the retpoline alternatives later so we can mark the

Discard? or mark as ignored?

> +++ b/tools/objtool/check.c
> @@ -1468,6 +1468,14 @@ static int add_special_section_alts(stru
> ret = -1;
> goto out;
> }
> + /*
> + * Skip (but mark) the retpoline alternatives so that we
> + * don't generate them again.
> + */

I'm having a lot of trouble following this comment. In my half-sleeping
state I'm theorizing this serves two purposes:

1) skip validating the alt (because why?)

and

2) if re-running objtool on the object, don't generate a duplicate
alternative? or maybe it also avoids duplicates for retpoline
alternatives which were created in asm code?

Not sure if I'm right but either way the comment needs more content.

Also not sure about $SUBJECT, maybe it can be more specific.

BTW, this "re-running objtool" thing is probably a bigger problem that
can be handled more broadly. When writing an object, we could write a
dummy discard section ".discard.objtool_wuz_here" which tells it not to
touch it a second time as weird things could happen.

--
Josh