From patchwork Thu Oct 8 10:03:12 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 52478 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 n98A6E5s026091 for ; Thu, 8 Oct 2009 10:06:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757159AbZJHKEZ (ORCPT ); Thu, 8 Oct 2009 06:04:25 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756807AbZJHKEY (ORCPT ); Thu, 8 Oct 2009 06:04:24 -0400 Received: from va3ehsobe005.messaging.microsoft.com ([216.32.180.15]:43550 "EHLO VA3EHSOBE005.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754363AbZJHKEX (ORCPT ); Thu, 8 Oct 2009 06:04:23 -0400 Received: from mail155-va3-R.bigfish.com (10.7.14.236) by VA3EHSOBE005.bigfish.com (10.7.40.25) with Microsoft SMTP Server id 8.1.340.0; Thu, 8 Oct 2009 10:03:46 +0000 Received: from mail155-va3 (localhost.localdomain [127.0.0.1]) by mail155-va3-R.bigfish.com (Postfix) with ESMTP id 6673D3283F4; Thu, 8 Oct 2009 10:03:46 +0000 (UTC) X-SpamScore: 3 X-BigFish: VPS3(zzzz1202hzzz32i6bh43j62h) X-Spam-TCS-SCL: 1:0 X-FB-SS: 5, Received: by mail155-va3 (MessageSwitch) id 125499622413094_10155; Thu, 8 Oct 2009 10:03:44 +0000 (UCT) Received: from VA3EHSMHS029.bigfish.com (unknown [10.7.14.236]) by mail155-va3.bigfish.com (Postfix) with ESMTP id F3C8B1A48051; Thu, 8 Oct 2009 10:03:43 +0000 (UTC) Received: from svlb1extmailp01.amd.com (139.95.251.8) by VA3EHSMHS029.bigfish.com (10.7.99.39) with Microsoft SMTP Server (TLS) id 14.0.482.32; Thu, 8 Oct 2009 10:03:43 +0000 Received: from svlb1twp01.amd.com ([139.95.250.34]) by svlb1extmailp01.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id n98A3ada022669; Thu, 8 Oct 2009 03:03:39 -0700 X-WSS-ID: 0KR6X9Z-03-4RQ-02 X-M-MSG: Received: from SSVLEXBH1.amd.com (ssvlexbh1.amd.com [139.95.53.182]) by svlb1twp01.amd.com (Tumbleweed MailGate 3.7.0) with ESMTP id 2CA1019A014F; Thu, 8 Oct 2009 03:03:34 -0700 (PDT) Received: from ssvlexmb2.amd.com ([139.95.53.7]) by SSVLEXBH1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 8 Oct 2009 03:03:37 -0700 Received: from SF36EXMB1.amd.com ([172.19.4.24]) by ssvlexmb2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 8 Oct 2009 03:03:37 -0700 Received: from seurexmb1.amd.com ([165.204.9.130]) by SF36EXMB1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 8 Oct 2009 12:03:24 +0200 Received: from lemmy.amd.com ([165.204.15.93]) by seurexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 8 Oct 2009 12:03:23 +0200 Received: by lemmy.amd.com (Postfix, from userid 41430) id 66117C9BAF; Thu, 8 Oct 2009 12:03:23 +0200 (CEST) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti CC: Alexander Graf , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joerg Roedel Subject: [PATCH 2/9] KVM: SVM: Move INTR vmexit out of atomic code Date: Thu, 8 Oct 2009 12:03:12 +0200 Message-ID: <1254996199-17667-3-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.6.4.3 In-Reply-To: <1254996199-17667-1-git-send-email-joerg.roedel@amd.com> References: <1254996199-17667-1-git-send-email-joerg.roedel@amd.com> X-OriginalArrivalTime: 08 Oct 2009 10:03:23.0541 (UTC) FILETIME=[924F3450:01CA47FE] MIME-Version: 1.0 X-Reverse-DNS: unknown Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index e372854..884bffc 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -85,6 +85,9 @@ struct nested_state { /* gpa pointers to the real vectors */ u64 vmcb_msrpm; + /* A VMEXIT is required but not yet emulated */ + bool exit_required; + /* cache for intercepts of the guest */ u16 intercept_cr_read; u16 intercept_cr_write; @@ -1379,7 +1382,14 @@ static inline int nested_svm_intr(struct vcpu_svm *svm) svm->vmcb->control.exit_code = SVM_EXIT_INTR; - if (nested_svm_exit_handled(svm)) { + if (svm->nested.intercept & 1ULL) { + /* + * The #vmexit can't be emulated here directly because this + * code path runs with irqs and preemtion disabled. A + * #vmexit emulation might sleep. Only signal request for + * the #vmexit here. + */ + svm->nested.exit_required = true; nsvm_printk("VMexit -> INTR\n"); return 1; } @@ -2340,6 +2350,13 @@ static int handle_exit(struct kvm_vcpu *vcpu) trace_kvm_exit(exit_code, svm->vmcb->save.rip); + if (unlikely(svm->nested.exit_required)) { + nested_svm_vmexit(svm); + svm->nested.exit_required = false; + + return 1; + } + if (is_nested(svm)) { int vmexit; @@ -2615,6 +2632,13 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu) u16 gs_selector; u16 ldt_selector; + /* + * A vmexit emulation is required before the vcpu can be executed + * again. + */ + if (unlikely(svm->nested.exit_required)) + return; + svm->vmcb->save.rax = vcpu->arch.regs[VCPU_REGS_RAX]; svm->vmcb->save.rsp = vcpu->arch.regs[VCPU_REGS_RSP]; svm->vmcb->save.rip = vcpu->arch.regs[VCPU_REGS_RIP];