From patchwork Thu Feb 18 11:38:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 80279 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1IBf5Lj028103 for ; Thu, 18 Feb 2010 11:41:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757870Ab0BRLi4 (ORCPT ); Thu, 18 Feb 2010 06:38:56 -0500 Received: from va3ehsobe002.messaging.microsoft.com ([216.32.180.12]:43594 "EHLO VA3EHSOBE002.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757822Ab0BRLix (ORCPT ); Thu, 18 Feb 2010 06:38:53 -0500 Received: from mail196-va3-R.bigfish.com (10.7.14.251) by VA3EHSOBE002.bigfish.com (10.7.40.22) with Microsoft SMTP Server id 8.1.240.5; Thu, 18 Feb 2010 11:38:52 +0000 Received: from mail196-va3 (localhost [127.0.0.1]) by mail196-va3-R.bigfish.com (Postfix) with ESMTP id 47D4D1BA8234; Thu, 18 Feb 2010 11:38:52 +0000 (UTC) X-SpamScore: -4 X-BigFish: VPS-4(zz936eMab9bhzz1202hzzz32i87h6bh62h) X-Spam-TCS-SCL: 1:0 X-FB-DOMAIN-IP-MATCH: fail Received: from mail196-va3 (localhost.localdomain [127.0.0.1]) by mail196-va3 (MessageSwitch) id 1266493131784187_7674; Thu, 18 Feb 2010 11:38:51 +0000 (UTC) Received: from VA3EHSMHS017.bigfish.com (unknown [10.7.14.254]) by mail196-va3.bigfish.com (Postfix) with ESMTP id AE50AFB804E; Thu, 18 Feb 2010 11:38:51 +0000 (UTC) Received: from ausb3extmailp02.amd.com (163.181.251.22) by VA3EHSMHS017.bigfish.com (10.7.99.27) with Microsoft SMTP Server (TLS) id 14.0.482.39; Thu, 18 Feb 2010 11:38:50 +0000 Received: from ausb3twp01.amd.com (ausb3twp01.amd.com [163.181.250.37]) by ausb3extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id o1IBfMNn005077; Thu, 18 Feb 2010 05:41:27 -0600 X-WSS-ID: 0KY1CCF-01-N2N-02 X-M-MSG: Received: from sausexbh2.amd.com (SAUSEXBH2.amd.com [163.181.22.102]) by ausb3twp01.amd.com (Tumbleweed MailGate 3.7.2) with ESMTP id 22C2D1028B3D; Thu, 18 Feb 2010 05:38:39 -0600 (CST) Received: from sausexmb1.amd.com ([163.181.3.156]) by sausexbh2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 18 Feb 2010 05:38:42 -0600 Received: from seurexmb1.amd.com ([165.204.9.130]) by sausexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 18 Feb 2010 05:38:41 -0600 Received: from lemmy.osrc.amd.com ([165.204.15.93]) by seurexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 18 Feb 2010 12:38:37 +0100 Received: by lemmy.osrc.amd.com (Postfix, from userid 41430) id 4EB80C9AFE; Thu, 18 Feb 2010 12:38:37 +0100 (CET) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti CC: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joerg Roedel , stable@kernel.org Subject: [PATCH 03/10] KVM: SVM: Fix schedule-while-atomic on nested exception handling Date: Thu, 18 Feb 2010 12:38:28 +0100 Message-ID: <1266493115-28386-4-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.6.6 In-Reply-To: <1266493115-28386-1-git-send-email-joerg.roedel@amd.com> References: <1266493115-28386-1-git-send-email-joerg.roedel@amd.com> X-OriginalArrivalTime: 18 Feb 2010 11:38:37.0421 (UTC) FILETIME=[E8FCD9D0:01CAB08E] MIME-Version: 1.0 X-Reverse-DNS: ausb3extmailp02.amd.com Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 18 Feb 2010 11:41:06 +0000 (UTC) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 7c96b8b..25d26ec 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -128,6 +128,7 @@ static void svm_flush_tlb(struct kvm_vcpu *vcpu); static void svm_complete_interrupts(struct vcpu_svm *svm); static int nested_svm_exit_handled(struct vcpu_svm *svm); +static int nested_svm_exit_handled_atomic(struct vcpu_svm *svm); static int nested_svm_vmexit(struct vcpu_svm *svm); static int nested_svm_check_exception(struct vcpu_svm *svm, unsigned nr, bool has_error_code, u32 error_code); @@ -1386,7 +1387,7 @@ static int nested_svm_check_exception(struct vcpu_svm *svm, unsigned nr, svm->vmcb->control.exit_info_1 = error_code; svm->vmcb->control.exit_info_2 = svm->vcpu.arch.cr2; - return nested_svm_exit_handled(svm); + return nested_svm_exit_handled_atomic(svm); } /* This function returns true if it is save to enable the irq window */ @@ -1520,7 +1521,7 @@ static int nested_svm_exit_special(struct vcpu_svm *svm) /* * If this function returns true, this #vmexit was already handled */ -static int nested_svm_exit_handled(struct vcpu_svm *svm) +static int __nested_svm_exit_handled(struct vcpu_svm *svm, bool atomic) { u32 exit_code = svm->vmcb->control.exit_code; int vmexit = NESTED_EXIT_HOST; @@ -1567,12 +1568,25 @@ static int nested_svm_exit_handled(struct vcpu_svm *svm) } if (vmexit == NESTED_EXIT_DONE) { - nested_svm_vmexit(svm); + if (!atomic) + nested_svm_vmexit(svm); + else + svm->nested.exit_required = true; } return vmexit; } +static int nested_svm_exit_handled(struct vcpu_svm *svm) +{ + return __nested_svm_exit_handled(svm, false); +} + +static int nested_svm_exit_handled_atomic(struct vcpu_svm *svm) +{ + return __nested_svm_exit_handled(svm, true); +} + static inline void copy_vmcb_control_area(struct vmcb *dst_vmcb, struct vmcb *from_vmcb) { struct vmcb_control_area *dst = &dst_vmcb->control;