Re: [PATCH] x86/retpoline: Optimize inline assembler for vmexit_fill_RSB

From: David Woodhouse
Date: Thu Jan 18 2018 - 07:41:30 EST


On Wed, 2018-01-17 at 14:53 -0800, Andi Kleen wrote:
> From: Andi Kleen <ak@xxxxxxxxxxxxxxx>
>
> I was looking at the generated assembler for the C fill RSB
> inline asm operations, and noticed several issues:
>
> - The C code sets up the loop register, which
> is then immediately overwritten in __FILL_RETURN_BUFFER
> with the same value again.
>
> - The C code also passes in the iteration count
> in another register, which is not used at all.
>
> Remove these two unnecessary operations. Just rely on
> the single constant passed to the macro for the iterations.
>
> This eliminates several instructions and avoids unnecessarily
> clobbering a register.
>
> Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>

We still clobber the register, but you're right it's now filled in the
__FILL_RETURN_BUFFER macro itself. It was a previous iteration which
had the loop count passed in.

Acked-by: David Woodhouse <dwmw@xxxxxxxxxxxx>

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