Re: [PATCH] x86/speculation: Use AMD specific retpoline for inline asm on AMD

2018-09-18 Thread Zhenzhong Duan
On 2018/9/18 21:00, Peter Zijlstra wrote: On Tue, Sep 18, 2018 at 08:04:44PM +0800, Zhenzhong Duan wrote: On 2018/9/18 18:59, Peter Zijlstra wrote: On Tue, Sep 18, 2018 at 06:31:07PM +0800, Zhenzhong Duan wrote: On 2018/9/18 17:50, Peter Zijlstra wrote: On Mon, Sep 17, 2018 at 10:17:30PM -070

Re: [PATCH] x86/speculation: Use AMD specific retpoline for inline asm on AMD

2018-09-18 Thread David Woodhouse
On Tue, 2018-09-18 at 15:03 +0200, Peter Zijlstra wrote: > > > In original code, it will go to "call *%[thunk_target]\n" while > > > we have set SPECTRE_V2_RETPOLINE_MINIMAL or > > > SPECTRE_V2_RETPOLINE_MINIMAL_AMD. Is this expected? > > > > Yes, that is exactly right -- it does that with or with

Re: [PATCH] x86/speculation: Use AMD specific retpoline for inline asm on AMD

2018-09-18 Thread Peter Zijlstra
> > In original code, it will go to "call *%[thunk_target]\n" while > > we have set SPECTRE_V2_RETPOLINE_MINIMAL or > > SPECTRE_V2_RETPOLINE_MINIMAL_AMD. Is this expected? > > Yes, that is exactly right -- it does that with or without your change > though. Soryr, I wrote that before I noticed the

Re: [PATCH] x86/speculation: Use AMD specific retpoline for inline asm on AMD

2018-09-18 Thread Peter Zijlstra
On Tue, Sep 18, 2018 at 08:04:44PM +0800, Zhenzhong Duan wrote: > On 2018/9/18 18:59, Peter Zijlstra wrote: > > On Tue, Sep 18, 2018 at 06:31:07PM +0800, Zhenzhong Duan wrote: > > > On 2018/9/18 17:50, Peter Zijlstra wrote: > > > > On Mon, Sep 17, 2018 at 10:17:30PM -0700, Zhenzhong Duan wrote: > >

Re: [PATCH] x86/speculation: Use AMD specific retpoline for inline asm on AMD

2018-09-18 Thread Zhenzhong Duan
On 2018/9/18 18:59, Peter Zijlstra wrote: On Tue, Sep 18, 2018 at 06:31:07PM +0800, Zhenzhong Duan wrote: On 2018/9/18 17:50, Peter Zijlstra wrote: On Mon, Sep 17, 2018 at 10:17:30PM -0700, Zhenzhong Duan wrote: -#elif defined(CONFIG_X86_32) && defined(CONFIG_RETPOLINE) +#elif defined(CONFIG_R

Re: [PATCH] x86/speculation: Use AMD specific retpoline for inline asm on AMD

2018-09-18 Thread Peter Zijlstra
On Tue, Sep 18, 2018 at 06:31:07PM +0800, Zhenzhong Duan wrote: > On 2018/9/18 17:50, Peter Zijlstra wrote: > > On Mon, Sep 17, 2018 at 10:17:30PM -0700, Zhenzhong Duan wrote: > > > -#elif defined(CONFIG_X86_32) && defined(CONFIG_RETPOLINE) > > > +#elif defined(CONFIG_RETPOLINE) > > > > This doesn

Re: [PATCH] x86/speculation: Use AMD specific retpoline for inline asm on AMD

2018-09-18 Thread Zhenzhong Duan
On 2018/9/18 17:50, Peter Zijlstra wrote: On Mon, Sep 17, 2018 at 10:17:30PM -0700, Zhenzhong Duan wrote: Lfence is preferred than general retpoline on AMD, add this option in C / inline asm just as the ASM code does. For x86_64, it still help to have minimal retpoline for kernel even if gcc do

Re: [PATCH] x86/speculation: Use AMD specific retpoline for inline asm on AMD

2018-09-18 Thread Peter Zijlstra
On Mon, Sep 17, 2018 at 10:17:30PM -0700, Zhenzhong Duan wrote: > Lfence is preferred than general retpoline on AMD, add this option > in C / inline asm just as the ASM code does. > > For x86_64, it still help to have minimal retpoline for kernel even > if gcc doesn't support it, change the inline

[PATCH] x86/speculation: Use AMD specific retpoline for inline asm on AMD

2018-09-17 Thread Zhenzhong Duan
Lfence is preferred than general retpoline on AMD, add this option in C / inline asm just as the ASM code does. For x86_64, it still help to have minimal retpoline for kernel even if gcc doesn't support it, change the inline asm for x86 so that it could also be used by x86_64. Add ANNOTATE_NOSPEC