lkml.org 
[lkml]   [2018]   [Jan]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] x86/retpoline: Fill return stack buffer on vmexit
On Thu, Jan 11, 2018 at 12:04:35AM +0000, Woodhouse, David wrote:
> 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" );


Or we teach the alternative thing to patch in a jmp to end instead of
NOP padding the entire thing as soon as the jmp (3 bytes) fits ?

\
 
 \ /
  Last update: 2018-01-14 23:22    [W:0.060 / U:0.368 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site