Re: [PATCH 3/5] x86/ibrs: Add direct access support for MSR_IA32_SPEC_CTRL

2018-01-15 Thread Peter Zijlstra
On Mon, Jan 15, 2018 at 02:59:22PM +0100, David Woodhouse wrote: > #define IF_FEATURE(ftr) if (static_cpu_has(ftr)) arch_static_assert,  > >    IF_FEATURE(key) { >        stuff(); >    } > > There might not be a sane way to do that though. And it's OK to have to > manually annotate the call sites

Re: [PATCH 3/5] x86/ibrs: Add direct access support for MSR_IA32_SPEC_CTRL

2018-01-15 Thread David Woodhouse
On Mon, 2018-01-15 at 14:45 +0100, Peter Zijlstra wrote: > On Fri, Jan 12, 2018 at 10:09:08AM +, David Woodhouse wrote: > > static_cpu_has() + asm-goto is NOT SUFFICIENT. > >  > > It's still *possible* for a missed optimisation in GCC to still leave > > us with a conditional branch around the w

Re: [PATCH 3/5] x86/ibrs: Add direct access support for MSR_IA32_SPEC_CTRL

2018-01-15 Thread Peter Zijlstra
On Fri, Jan 12, 2018 at 10:09:08AM +, David Woodhouse wrote: > static_cpu_has() + asm-goto is NOT SUFFICIENT. > > It's still *possible* for a missed optimisation in GCC to still leave > us with a conditional branch around the wrmsr, letting the CPU > speculate around it too. OK, so GCC would

Re: [PATCH 3/5] x86/ibrs: Add direct access support for MSR_IA32_SPEC_CTRL

2018-01-12 Thread David Woodhouse
On Fri, 2018-01-12 at 10:51 +0100, Peter Zijlstra wrote: > On Thu, Jan 11, 2018 at 05:58:11PM -0800, Dave Hansen wrote: > > On 01/11/2018 05:32 PM, Ashok Raj wrote: > > > +static void save_guest_spec_ctrl(struct vcpu_vmx *vmx) > > > +{ > > > +   if (boot_cpu_has(X86_FEATURE_SPEC_CTRL)) { > > > +   

Re: [PATCH 3/5] x86/ibrs: Add direct access support for MSR_IA32_SPEC_CTRL

2018-01-12 Thread Peter Zijlstra
On Thu, Jan 11, 2018 at 05:58:11PM -0800, Dave Hansen wrote: > On 01/11/2018 05:32 PM, Ashok Raj wrote: > > +static void save_guest_spec_ctrl(struct vcpu_vmx *vmx) > > +{ > > + if (boot_cpu_has(X86_FEATURE_SPEC_CTRL)) { > > + vmx->spec_ctrl = spec_ctrl_get(); > > + spec_ctrl_r

Re: [PATCH 3/5] x86/ibrs: Add direct access support for MSR_IA32_SPEC_CTRL

2018-01-11 Thread Raj, Ashok
On Thu, Jan 11, 2018 at 05:58:11PM -0800, Dave Hansen wrote: > On 01/11/2018 05:32 PM, Ashok Raj wrote: > > +static void save_guest_spec_ctrl(struct vcpu_vmx *vmx) > > +{ > > + if (boot_cpu_has(X86_FEATURE_SPEC_CTRL)) { > > + vmx->spec_ctrl = spec_ctrl_get(); > > + spec_ctrl_r

Re: [PATCH 3/5] x86/ibrs: Add direct access support for MSR_IA32_SPEC_CTRL

2018-01-11 Thread Dave Hansen
On 01/11/2018 05:32 PM, Ashok Raj wrote: > +static void save_guest_spec_ctrl(struct vcpu_vmx *vmx) > +{ > + if (boot_cpu_has(X86_FEATURE_SPEC_CTRL)) { > + vmx->spec_ctrl = spec_ctrl_get(); > + spec_ctrl_restriction_on(); > + } else > + rmb(); > +} Does t