Dirk Müller <[email protected]> writes:

>> I added the warning so that we catch if the next_rip field is being written
>> to (even if the feature isn't supported) by a buggy L1 hypervisor.
>
> Interesting, so how about this patch?
>
>
> From c5c8ea255d680f972cbdfc835cdf352fa78897ae Mon Sep 17 00:00:00 2001
> From: Dirk Mueller <[email protected]>
> Date: Fri, 2 Oct 2015 08:35:24 +0200
> Subject: [PATCH] KVM: nSVM: Check for NRIP support before accepting
>  control.next_rip
>
> NRIP support itself depends on cpuid Fn8000_000A_EDX[NRIPS], remove
> a WARN_ON_(once) and check for it directly.
>
> Signed-off-by: Dirk Mueller <[email protected]>
> ---
>  arch/x86/kvm/svm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 0a42859..33d36da 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -513,8 +513,8 @@ static void skip_emulated_instruction(struct kvm_vcpu 
> *vcpu)
>  {
>       struct vcpu_svm *svm = to_svm(vcpu);
>  
> -     if (svm->vmcb->control.next_rip != 0) {
> -             WARN_ON_ONCE(!static_cpu_has(X86_FEATURE_NRIPS));
> +     if (static_cpu_has(X86_FEATURE_NRIPS) &&
> +         svm->vmcb->control.next_rip != 0) {
>               svm->next_rip = svm->vmcb->control.next_rip;
>       }

Ok, looks good to me. Still, probably a good idea to let the user know if this 
condition is
hit.

Bandan

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to