From: Mohammed Gamal Subject: [PATCH] VMX: Return to userspace on invalid state emulation failure Date: Tue, 25 Aug 2009 01:37:19 +0300 Message-ID: <1251153439-17078-1-git-send-email-m.gamal005@gmail.com> Cc: kvm@vger.kernel.org, Mohammed Gamal To: avi@redhat.com Return-path: Received: from mail-fx0-f217.google.com ([209.85.220.217]:51344 "EHLO mail-fx0-f217.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753486AbZHXWhX (ORCPT ); Mon, 24 Aug 2009 18:37:23 -0400 Received: by fxm17 with SMTP id 17so1735307fxm.37 for ; Mon, 24 Aug 2009 15:37:24 -0700 (PDT) Sender: kvm-owner@vger.kernel.org List-ID: Return to userspace instead of repeatedly trying to emulate instructions that have already failed Signed-off-by: Mohammed Gamal --- arch/x86/kvm/vmx.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 6b57eed..c559bb7 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3337,6 +3337,8 @@ static void handle_invalid_guest_state(struct kvm_vcpu *vcpu) if (err != EMULATE_DONE) { kvm_report_emulation_failure(vcpu, "emulation failure"); + vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; + vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION; break; } @@ -3607,7 +3609,9 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu) vmx->entry_time = ktime_get(); /* Handle invalid guest state instead of entering VMX */ - if (vmx->emulation_required && emulate_invalid_guest_state) { + if (vmx->emulation_required && emulate_invalid_guest_state + && !(vcpu->run->exit_reason == KVM_EXIT_INTERNAL_ERROR && + vcpu->run->internal.suberror == KVM_INTERNAL_ERROR_EMULATION)) { handle_invalid_guest_state(vcpu); return; } -- 1.6.0.4