Re: [PATCH] x86/retpoline: Fill return stack buffer on vmexit

From: Peter Zijlstra
Date: Thu Jan 11 2018 - 04:58:49 EST


On Thu, Jan 11, 2018 at 10:47:59AM +0100, Borislav Petkov wrote:
> On Thu, Jan 11, 2018 at 10:32:31AM +0100, Peter Zijlstra wrote:
> > can't you do lovely things like:
> >
> > volatile asm ("call __fill_rsb_thunk_%1" : : "r" (dummy))
> >
> > which would still let gcc select the register ?
>
> Calling a function from asm is nasty because you need to pay attention
> to clobbered registers as gcc doesn't see the function.

The point is that this is an asm function, much like the retpoline
thunks, replicated for each register.

And by stuffing the register in the function name and using a dummy
argument you let GCC pick which register to clobber.

Heck we could even pass in the actual stuff-count instead of treating it
as a pure dummy.