Re: [PATCH] x86/alternatives: Fix optimize_nops() checking

From: David Woodhouse
Date: Wed Jan 10 2018 - 16:09:21 EST


On Wed, 2018-01-10 at 13:05 -0800, Linus Torvalds wrote:
> On Wed, Jan 10, 2018 at 12:55 PM, Borislav Petkov <bp@xxxxxxxxx>
> wrote:
> >
> > Ok, so the problem was: how to fixup jumps which are not the first
> > instruction which is being replaced but a following one in the
> > instruction bytes with which we replace.
>
> What jumps do you have that need to be fixed up?
>
> I really think we should avoid having things like that.
>
> Any jumps *within* the alternatives should have been handled by the
> assembler already.
>
> And jumps between the alternatives and other places? Why do they
> exist?

There are a few of the form 'call *somefunc'.

The existing code handles them not by virtue of the relocs, as I said,
but by a simple delta of the old and new location of the instruction.

But it only does so for the *first* instruction of the altinstr, if it
happens to be a (4-byte?) branch.

Right now for retpoline I am just studiously avoiding doing anything
that the alternatives mechanism isn't going to get right, or might
change in future. I think ;)

Attachment: smime.p7s
Description: S/MIME cryptographic signature