stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* KVM: nSVM: Check for NRIPS support before updating control field
@ 2015-06-29 19:18 Bandan Das
  2015-06-29 19:28 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Bandan Das @ 2015-06-29 19:18 UTC (permalink / raw)
  To: stable; +Cc: Paolo Bonzini


Commit f104765b4f81fd74d69e0eb161e89096deade2db upstream.

This causes the L1 guest to crash when running a nested guest
with an AMD processor that doesn't support NRIPS.

If hardware doesn't support DecodeAssist - a feature that provides
more information about the intercept in the VMCB, KVM decodes the
instruction and then updates the next_rip vmcb control field.
However, NRIP support itself depends on cpuid Fn8000_000A_EDX[NRIPS].
Since skip_emulated_instruction() doesn't verify nrip support
before accepting control.next_rip as valid, avoid writing this
field if support isn't present.

Signed-off-by: Bandan Das <bsd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/x86/kvm/svm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 6807531..e7685af 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -511,8 +511,10 @@ static void skip_emulated_instruction(struct kvm_vcpu *vcpu)
 {
 	struct vcpu_svm *svm = to_svm(vcpu);
 
-	if (svm->vmcb->control.next_rip != 0)
+	if (svm->vmcb->control.next_rip != 0) {
+		WARN_ON(!static_cpu_has(X86_FEATURE_NRIPS));
 		svm->next_rip = svm->vmcb->control.next_rip;
+	}
 
 	if (!svm->next_rip) {
 		if (emulate_instruction(vcpu, EMULTYPE_SKIP) !=
@@ -4329,7 +4331,9 @@ static int svm_check_intercept(struct kvm_vcpu *vcpu,
 		break;
 	}
 
-	vmcb->control.next_rip  = info->next_rip;
+	/* TODO: Advertise NRIPS to guest hypervisor unconditionally */
+	if (static_cpu_has(X86_FEATURE_NRIPS))
+		vmcb->control.next_rip  = info->next_rip;
 	vmcb->control.exit_code = icpt_info.exit_code;
 	vmexit = nested_svm_exit_handled(svm);
 
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: KVM: nSVM: Check for NRIPS support before updating control field
  2015-06-29 19:18 KVM: nSVM: Check for NRIPS support before updating control field Bandan Das
@ 2015-06-29 19:28 ` Greg KH
  2015-06-29 20:22   ` Bandan Das
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2015-06-29 19:28 UTC (permalink / raw)
  To: Bandan Das; +Cc: stable, Paolo Bonzini

On Mon, Jun 29, 2015 at 03:18:51PM -0400, Bandan Das wrote:
> 
> Commit f104765b4f81fd74d69e0eb161e89096deade2db upstream.
> 
> This causes the L1 guest to crash when running a nested guest
> with an AMD processor that doesn't support NRIPS.
> 
> If hardware doesn't support DecodeAssist - a feature that provides
> more information about the intercept in the VMCB, KVM decodes the
> instruction and then updates the next_rip vmcb control field.
> However, NRIP support itself depends on cpuid Fn8000_000A_EDX[NRIPS].
> Since skip_emulated_instruction() doesn't verify nrip support
> before accepting control.next_rip as valid, avoid writing this
> field if support isn't present.
> 
> Signed-off-by: Bandan Das <bsd@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  arch/x86/kvm/svm.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

What stable kernel trees do you want this applied to?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: KVM: nSVM: Check for NRIPS support before updating control field
  2015-06-29 19:28 ` Greg KH
@ 2015-06-29 20:22   ` Bandan Das
  2015-07-01  9:23     ` Luis Henriques
  0 siblings, 1 reply; 4+ messages in thread
From: Bandan Das @ 2015-06-29 20:22 UTC (permalink / raw)
  To: Greg KH; +Cc: stable, Paolo Bonzini

Greg KH <gregkh@linuxfoundation.org> writes:

> On Mon, Jun 29, 2015 at 03:18:51PM -0400, Bandan Das wrote:
>> 
>> Commit f104765b4f81fd74d69e0eb161e89096deade2db upstream.
>> 
>> This causes the L1 guest to crash when running a nested guest
>> with an AMD processor that doesn't support NRIPS.
>> 
>> If hardware doesn't support DecodeAssist - a feature that provides
>> more information about the intercept in the VMCB, KVM decodes the
>> instruction and then updates the next_rip vmcb control field.
>> However, NRIP support itself depends on cpuid Fn8000_000A_EDX[NRIPS].
>> Since skip_emulated_instruction() doesn't verify nrip support
>> before accepting control.next_rip as valid, avoid writing this
>> field if support isn't present.
>> 
>> Signed-off-by: Bandan Das <bsd@redhat.com>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>  arch/x86/kvm/svm.c | 8 ++++++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> What stable kernel trees do you want this applied to?

Sorry, I missed that part. I believe this bug is present
since commit cfec82cb7d3 which makes it applicable to
#3.0+

Bandan
> thanks,
>
> greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: KVM: nSVM: Check for NRIPS support before updating control field
  2015-06-29 20:22   ` Bandan Das
@ 2015-07-01  9:23     ` Luis Henriques
  0 siblings, 0 replies; 4+ messages in thread
From: Luis Henriques @ 2015-07-01  9:23 UTC (permalink / raw)
  To: Bandan Das; +Cc: Greg KH, stable, Paolo Bonzini

On Mon, Jun 29, 2015 at 04:22:42PM -0400, Bandan Das wrote:
> Greg KH <gregkh@linuxfoundation.org> writes:
> 
> > On Mon, Jun 29, 2015 at 03:18:51PM -0400, Bandan Das wrote:
> >> 
> >> Commit f104765b4f81fd74d69e0eb161e89096deade2db upstream.
> >> 
> >> This causes the L1 guest to crash when running a nested guest
> >> with an AMD processor that doesn't support NRIPS.
> >> 
> >> If hardware doesn't support DecodeAssist - a feature that provides
> >> more information about the intercept in the VMCB, KVM decodes the
> >> instruction and then updates the next_rip vmcb control field.
> >> However, NRIP support itself depends on cpuid Fn8000_000A_EDX[NRIPS].
> >> Since skip_emulated_instruction() doesn't verify nrip support
> >> before accepting control.next_rip as valid, avoid writing this
> >> field if support isn't present.
> >> 
> >> Signed-off-by: Bandan Das <bsd@redhat.com>
> >> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> >> ---
> >>  arch/x86/kvm/svm.c | 8 ++++++--
> >>  1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > What stable kernel trees do you want this applied to?
> 
> Sorry, I missed that part. I believe this bug is present
> since commit cfec82cb7d3 which makes it applicable to
> #3.0+
> 

Thanks, queuing it for the 3.16 kernel.

Cheers,
--
Lu�s

> Bandan
> > thanks,
> >
> > greg k-h
> --
> To unsubscribe from this list: send the line "unsubscribe stable" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-07-01  9:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-29 19:18 KVM: nSVM: Check for NRIPS support before updating control field Bandan Das
2015-06-29 19:28 ` Greg KH
2015-06-29 20:22   ` Bandan Das
2015-07-01  9:23     ` Luis Henriques

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).