From patchwork Mon Aug 24 22:37:19 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammed Gamal X-Patchwork-Id: 43671 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7OMbSi8004344 for ; Mon, 24 Aug 2009 22:37:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753604AbZHXWhY (ORCPT ); Mon, 24 Aug 2009 18:37:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753560AbZHXWhY (ORCPT ); Mon, 24 Aug 2009 18:37:24 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=JkHQWvxqUoi8XYnrfPbNvqvVF0zIQAhkj1aB4tXbdzQ=; b=cpu2fISanXOa1WYQDEvM8j1i1G2V7QcEBRN3I6NUsGZDv09Ec0ChvX1fq87AliXfZ3 RcUZ5jGjDyRcSHavgcoHr94/OSXMKJH1FN1OT0Qe8quKV4n9S6orqWbTqtez4H3+1Mk4 0SvS6zDWvK9yJsaL7JNNA+YHaN0iHZCk4VZCE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=wc166c0YODuozqB9zlFPs4YQ3aVZykS3v5D1O/hI3zBXzFq6LmI3SJMzOFFC92OgE7 7l6/poXAAuzmeGptHJT4G0Beq4tNGdeuu0fGc2wSxTvlwD8j3ZryWzH2+ePn9XHNEpS0 m1bCv98bYgSrSToyPPYZOm7mMoxT2mL2F837Q= Received: by 10.204.21.4 with SMTP id h4mr1866904bkb.58.1251153444568; Mon, 24 Aug 2009 15:37:24 -0700 (PDT) Received: from localhost.localdomain ([41.238.115.10]) by mx.google.com with ESMTPS id z15sm6380366fkz.34.2009.08.24.15.37.21 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 24 Aug 2009 15:37:23 -0700 (PDT) From: Mohammed Gamal To: avi@redhat.com Cc: kvm@vger.kernel.org, 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> X-Mailer: git-send-email 1.6.0.4 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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; }