From patchwork Mon Aug 24 04:07:54 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammed Gamal X-Patchwork-Id: 43537 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 n7O487nS009126 for ; Mon, 24 Aug 2009 04:08:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750950AbZHXEID (ORCPT ); Mon, 24 Aug 2009 00:08:03 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750984AbZHXEID (ORCPT ); Mon, 24 Aug 2009 00:08:03 -0400 Received: from mail-ew0-f207.google.com ([209.85.219.207]:62646 "EHLO mail-ew0-f207.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750933AbZHXEIC (ORCPT ); Mon, 24 Aug 2009 00:08:02 -0400 Received: by ewy3 with SMTP id 3so2041438ewy.18 for ; Sun, 23 Aug 2009 21:08:02 -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=1BaUG50yivHVJ17NMshnucN56UJuMYNvvji/T0RfYew=; b=e+FIbNsTVHOvy/duYMdmxYKTfEuNOW16RnoLMToRvX0xZWpLqB9R/g00QTiKg2iClr 9hJU+QFssmgvINGSJBwvtSatYpxsxCeB8HRjXEw/G9FTVmn1OTwDkcMV3f6PJBiwjlcc zPj7VJd54v3LRUGbEKbLtVjmCqlaf8nhXU83o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=oCHI/d22nHXe+up4dB8A82L4YTc6dTRAvRd3p4UH+M/ks6Lx2nZ8qViyJ9QpBUb7WS Q1BhuF5Nfkp+E9AqD9zH53oBJLCvU+bVmFhM/Uwun9zsmUVM2+EvxG/NjyZYDmtWwzwb O6EWc9z3EJgtu1KGVLJ351PecmJVnt01MKYEM= Received: by 10.210.11.13 with SMTP id 13mr4296037ebk.52.1251086882813; Sun, 23 Aug 2009 21:08:02 -0700 (PDT) Received: from localhost.localdomain ([188.54.29.63]) by mx.google.com with ESMTPS id 28sm8062890eyg.52.2009.08.23.21.07.59 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 23 Aug 2009 21:08:02 -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: Mon, 24 Aug 2009 07:07:54 +0300 Message-Id: <1251086875-21412-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 | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 1ee811c..6030671 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3341,6 +3341,8 @@ static void handle_invalid_guest_state(struct kvm_vcpu *vcpu, if (err != EMULATE_DONE) { kvm_report_emulation_failure(vcpu, "emulation failure"); + kvm_run->exit_reason = KVM_EXIT_INTERNAL_ERROR; + kvm_run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION; break; } @@ -3612,7 +3614,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 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 + && kvm_run->internal.suberror != KVM_INTERNAL_ERROR_EMULATION) { handle_invalid_guest_state(vcpu, kvm_run); return; }