Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-11 Thread Paolo Bonzini
On 11/01/2018 03:47, Tim Chen wrote: > On 01/08/2018 10:08 AM, Paolo Bonzini wrote: > >> @@ -9597,6 +9620,9 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu >> *vcpu) >> >> pt_guest_enter(vmx); >> >> +if (have_spec_ctrl && vmx->spec_ctrl != 0) >> +

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-11 Thread Paolo Bonzini
On 11/01/2018 03:47, Tim Chen wrote: > On 01/08/2018 10:08 AM, Paolo Bonzini wrote: > >> @@ -9597,6 +9620,9 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu >> *vcpu) >> >> pt_guest_enter(vmx); >> >> +if (have_spec_ctrl && vmx->spec_ctrl != 0) >> +

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-10 Thread Tim Chen
On 01/08/2018 10:08 AM, Paolo Bonzini wrote: > @@ -9597,6 +9620,9 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu > *vcpu) > > pt_guest_enter(vmx); > > + if (have_spec_ctrl && vmx->spec_ctrl != 0) > + wrmsrl(MSR_IA32_SPEC_CTRL, vmx->spec_ctrl); > + Say host uses

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-10 Thread Tim Chen
On 01/08/2018 10:08 AM, Paolo Bonzini wrote: > @@ -9597,6 +9620,9 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu > *vcpu) > > pt_guest_enter(vmx); > > + if (have_spec_ctrl && vmx->spec_ctrl != 0) > + wrmsrl(MSR_IA32_SPEC_CTRL, vmx->spec_ctrl); > + Say host uses

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-09 Thread Paolo Bonzini
On 09/01/2018 00:19, Jim Mattson wrote: + vmx_disable_intercept_for_msr(MSR_IA32_SPEC_CTRL, false); + vmx_disable_intercept_for_msr(MSR_IA32_PRED_CMD, false); >>> I have a lot of changes to MSR permission bitmap handling, but these >>> intercepts should only be disabled when

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-09 Thread Paolo Bonzini
On 09/01/2018 00:19, Jim Mattson wrote: + vmx_disable_intercept_for_msr(MSR_IA32_SPEC_CTRL, false); + vmx_disable_intercept_for_msr(MSR_IA32_PRED_CMD, false); >>> I have a lot of changes to MSR permission bitmap handling, but these >>> intercepts should only be disabled when

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-09 Thread Paolo Bonzini
ger.kernel.org, k...@vger.kernel.org >>> Cc: jmatt...@google.com, aligu...@amazon.com, "thomas lendacky" >> <thomas.lenda...@amd.com>, b...@alien8.de >>> Sent: Monday, January 8, 2018 8:41:07 PM >>> Subject: Re: [PATCH 3/7] kvm: vmx: pass MSR_

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-09 Thread Paolo Bonzini
: jmatt...@google.com, aligu...@amazon.com, "thomas lendacky" >> , b...@alien8.de >>> Sent: Monday, January 8, 2018 8:41:07 PM >>> Subject: Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and >> MSR_IA32_PRED_CMD down to the guest >>> &g

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Liran Alon
att...@google.com, aligu...@amazon.com, "thomas lendacky" > <thomas.lenda...@amd.com>, b...@alien8.de > > Sent: Monday, January 8, 2018 8:41:07 PM > > Subject: Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and > MSR_IA32_PRED_CMD down to the guest > > > >

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Liran Alon
> , b...@alien8.de > > Sent: Monday, January 8, 2018 8:41:07 PM > > Subject: Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and > MSR_IA32_PRED_CMD down to the guest > > > > On Mon, 2018-01-08 at 19:08 +0100, Paolo Bonzini wrote: > > > > > > +

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Jim Mattson
On Mon, Jan 8, 2018 at 2:32 PM, Paolo Bonzini wrote: > >> I have: >> >> if (!have_spec_ctrl || >> (!msr_info->host_initiated && >> !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL))) >> return 1; >> msr_info->data = to_vmx(vcpu)->msr_ia32_spec_ctrl; >> break; > >> I

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Jim Mattson
On Mon, Jan 8, 2018 at 2:32 PM, Paolo Bonzini wrote: > >> I have: >> >> if (!have_spec_ctrl || >> (!msr_info->host_initiated && >> !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL))) >> return 1; >> msr_info->data = to_vmx(vcpu)->msr_ia32_spec_ctrl; >> break; > >> I have: >> >> if

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Paolo Bonzini
t; > <thomas.lenda...@amd.com>, b...@alien8.de > Sent: Monday, January 8, 2018 8:41:07 PM > Subject: Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and > MSR_IA32_PRED_CMD down to the guest > > On Mon, 2018-01-08 at 19:08 +0100, Paolo Bonzini wrote: > >

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Paolo Bonzini
, 2018 8:41:07 PM > Subject: Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and > MSR_IA32_PRED_CMD down to the guest > > On Mon, 2018-01-08 at 19:08 +0100, Paolo Bonzini wrote: > > > > +   if (have_spec_ctrl && vmx->spec_ctrl != 0) > > +  

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Paolo Bonzini
> I have: > > if (!have_spec_ctrl || > (!msr_info->host_initiated && > !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL))) > return 1; > msr_info->data = to_vmx(vcpu)->msr_ia32_spec_ctrl; > break; > I have: > > if (!have_spec_ctrl || > (!msr_info->host_initiated && >

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Paolo Bonzini
> I have: > > if (!have_spec_ctrl || > (!msr_info->host_initiated && > !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL))) > return 1; > msr_info->data = to_vmx(vcpu)->msr_ia32_spec_ctrl; > break; > I have: > > if (!have_spec_ctrl || > (!msr_info->host_initiated && >

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Paolo Bonzini
<thomas.lenda...@amd.com>, d...@amazon.co.uk, b...@alien8.de, "Ashok Raj" > <ashok....@linux.intel.com> > Sent: Monday, January 8, 2018 11:09:53 PM > Subject: Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and > MSR_IA32_PRED_CMD down to the guest >

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Paolo Bonzini
j" > > Sent: Monday, January 8, 2018 11:09:53 PM > Subject: Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and > MSR_IA32_PRED_CMD down to the guest > > Hi Paolo > > Do you assume that host isn't using IBRS and only guest uses it? For now, yes. Patches to add t

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Ashok Raj
Hi Paolo Do you assume that host isn't using IBRS and only guest uses it? On Mon, Jan 8, 2018 at 10:08 AM, Paolo Bonzini wrote: > Direct access to MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD is important > for performance. Allow load/store of MSR_IA32_SPEC_CTRL, restore

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Ashok Raj
Hi Paolo Do you assume that host isn't using IBRS and only guest uses it? On Mon, Jan 8, 2018 at 10:08 AM, Paolo Bonzini wrote: > Direct access to MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD is important > for performance. Allow load/store of MSR_IA32_SPEC_CTRL, restore guest > IBRS on VM entry

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Liran Alon
On 08/01/18 21:18, Jim Mattson wrote: Guest usage of MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD should be predicated on guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL). On Mon, Jan 8, 2018 at 10:08 AM, Paolo Bonzini wrote: Direct access to MSR_IA32_SPEC_CTRL and

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Liran Alon
On 08/01/18 21:18, Jim Mattson wrote: Guest usage of MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD should be predicated on guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL). On Mon, Jan 8, 2018 at 10:08 AM, Paolo Bonzini wrote: Direct access to MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD is important

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread David Woodhouse
On Mon, 2018-01-08 at 19:08 +0100, Paolo Bonzini wrote: > > +   if (have_spec_ctrl && vmx->spec_ctrl != 0) > +   wrmsrl(MSR_IA32_SPEC_CTRL, vmx->spec_ctrl); > + I think this one probably *is* safe even without an 'else lfence', which means that the CPU can speculate around it,

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread David Woodhouse
On Mon, 2018-01-08 at 19:08 +0100, Paolo Bonzini wrote: > > +   if (have_spec_ctrl && vmx->spec_ctrl != 0) > +   wrmsrl(MSR_IA32_SPEC_CTRL, vmx->spec_ctrl); > + I think this one probably *is* safe even without an 'else lfence', which means that the CPU can speculate around it,

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Liran Alon
On 08/01/18 20:08, Paolo Bonzini wrote: Direct access to MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD is important for performance. Allow load/store of MSR_IA32_SPEC_CTRL, restore guest IBRS on VM entry and set it to 0 on VM exit (because Linux does not use it yet). Signed-off-by: Paolo Bonzini

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Liran Alon
On 08/01/18 20:08, Paolo Bonzini wrote: Direct access to MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD is important for performance. Allow load/store of MSR_IA32_SPEC_CTRL, restore guest IBRS on VM entry and set it to 0 on VM exit (because Linux does not use it yet). Signed-off-by: Paolo Bonzini

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Jim Mattson
Guest usage of MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD should be predicated on guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL). On Mon, Jan 8, 2018 at 10:08 AM, Paolo Bonzini wrote: > Direct access to MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD is important > for performance.

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Jim Mattson
Guest usage of MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD should be predicated on guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL). On Mon, Jan 8, 2018 at 10:08 AM, Paolo Bonzini wrote: > Direct access to MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD is important > for performance. Allow load/store of

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Konrad Rzeszutek Wilk
On Mon, Jan 08, 2018 at 07:08:41PM +0100, Paolo Bonzini wrote: > Direct access to MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD is important > for performance. Allow load/store of MSR_IA32_SPEC_CTRL, restore guest > IBRS on VM entry and set it to 0 on VM exit (because Linux does not use > it yet). >

Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Konrad Rzeszutek Wilk
On Mon, Jan 08, 2018 at 07:08:41PM +0100, Paolo Bonzini wrote: > Direct access to MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD is important > for performance. Allow load/store of MSR_IA32_SPEC_CTRL, restore guest > IBRS on VM entry and set it to 0 on VM exit (because Linux does not use > it yet). >

[PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Paolo Bonzini
Direct access to MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD is important for performance. Allow load/store of MSR_IA32_SPEC_CTRL, restore guest IBRS on VM entry and set it to 0 on VM exit (because Linux does not use it yet). Signed-off-by: Paolo Bonzini ---

[PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

2018-01-08 Thread Paolo Bonzini
Direct access to MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD is important for performance. Allow load/store of MSR_IA32_SPEC_CTRL, restore guest IBRS on VM entry and set it to 0 on VM exit (because Linux does not use it yet). Signed-off-by: Paolo Bonzini --- arch/x86/kvm/vmx.c | 32