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

From: Woodhouse, David
Date: Wed Jan 10 2018 - 19:06:11 EST


On Wed, 2018-01-10 at 15:47 -0800, Tim Chen wrote:
>
> > +
> > +ÂÂÂÂÂasm volatile (ALTERNATIVE("",
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ __stringify(__FILL_RETURN_BUFFER(%0, %1, _%=)),
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ X86_FEATURE_RETPOLINE)
>
> We'll be patching in a fairly long set of instructions here. Maybe put
> the ALTERNATIVE in the assembly and use a jmp skip_\@ for the ALTERNATIVE.

Perhaps the alternatives.h header could give me a clean way of doing this:

--- a/arch/x86/include/asm/nospec-branch.h
+++ b/arch/x86/include/asm/nospec-branch.h
@@ -177,7 +178,7 @@ static inline void vmexit_fill_RSB(void)
Â{
ÂÂÂÂÂÂÂÂunsigned long dummy;
Â
-ÂÂÂÂÂÂÂasm volatile (ALTERNATIVE("",
+ÂÂÂÂÂÂÂasm volatile (ALTERNATIVE("jmp " alt_end_marker "f",
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ__stringify(__FILL_RETURN_BUFFER(%0, %1, _%=)),
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂX86_FEATURE_RETPOLINE)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ: "=r" (dummy), ASM_CALL_CONSTRAINT : : "memory" );

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