diff options
author | Bandan Das <bsd@redhat.com> | 2015-06-11 02:05:33 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-07-10 12:49:27 -0400 |
commit | aa0b8c72f5c1e0208bfafb383b535bdc9d3b2c6b (patch) | |
tree | b5fb39f4b64586847c6baa164050ab1d054d20c6 /arch | |
parent | 9d281572f2be11afa36e1534da43890cb9a130cc (diff) |
KVM: nSVM: Check for NRIPS support before updating control field
commit f104765b4f81fd74d69e0eb161e89096deade2db upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kvm/svm.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 9afa233b5482..4911bf19122b 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) | |||
511 | { | 511 | { |
512 | struct vcpu_svm *svm = to_svm(vcpu); | 512 | struct vcpu_svm *svm = to_svm(vcpu); |
513 | 513 | ||
514 | if (svm->vmcb->control.next_rip != 0) | 514 | if (svm->vmcb->control.next_rip != 0) { |
515 | WARN_ON(!static_cpu_has(X86_FEATURE_NRIPS)); | ||
515 | svm->next_rip = svm->vmcb->control.next_rip; | 516 | svm->next_rip = svm->vmcb->control.next_rip; |
517 | } | ||
516 | 518 | ||
517 | if (!svm->next_rip) { | 519 | if (!svm->next_rip) { |
518 | if (emulate_instruction(vcpu, EMULTYPE_SKIP) != | 520 | if (emulate_instruction(vcpu, EMULTYPE_SKIP) != |
@@ -4317,7 +4319,9 @@ static int svm_check_intercept(struct kvm_vcpu *vcpu, | |||
4317 | break; | 4319 | break; |
4318 | } | 4320 | } |
4319 | 4321 | ||
4320 | vmcb->control.next_rip = info->next_rip; | 4322 | /* TODO: Advertise NRIPS to guest hypervisor unconditionally */ |
4323 | if (static_cpu_has(X86_FEATURE_NRIPS)) | ||
4324 | vmcb->control.next_rip = info->next_rip; | ||
4321 | vmcb->control.exit_code = icpt_info.exit_code; | 4325 | vmcb->control.exit_code = icpt_info.exit_code; |
4322 | vmexit = nested_svm_exit_handled(svm); | 4326 | vmexit = nested_svm_exit_handled(svm); |
4323 | 4327 | ||