From patchwork Wed Sep 16 13:24:15 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 47985 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 n8GDTPRY004915 for ; Wed, 16 Sep 2009 13:29:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754082AbZIPNZF (ORCPT ); Wed, 16 Sep 2009 09:25:05 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753518AbZIPNZA (ORCPT ); Wed, 16 Sep 2009 09:25:00 -0400 Received: from va3ehsobe001.messaging.microsoft.com ([216.32.180.11]:34064 "EHLO VA3EHSOBE001.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752501AbZIPNYx (ORCPT ); Wed, 16 Sep 2009 09:24:53 -0400 Received: from mail134-va3-R.bigfish.com (10.7.14.249) by VA3EHSOBE001.bigfish.com (10.7.40.21) with Microsoft SMTP Server id 8.1.340.0; Wed, 16 Sep 2009 13:24:56 +0000 Received: from mail134-va3 (localhost.localdomain [127.0.0.1]) by mail134-va3-R.bigfish.com (Postfix) with ESMTP id A497CF400EA; Wed, 16 Sep 2009 13:24:56 +0000 (UTC) X-SpamScore: 1 X-BigFish: VPS1(zzzz1202hzzz32i203h64h) X-Spam-TCS-SCL: 3:0 X-FB-SS: 5, Received: by mail134-va3 (MessageSwitch) id 1253107485945019_22142; Wed, 16 Sep 2009 13:24:45 +0000 (UCT) Received: from ausb3extmailp02.amd.com (ausb3extmailp02.amd.com [163.181.251.22]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail134-va3.bigfish.com (Postfix) with ESMTP id CCE3F1338050; Wed, 16 Sep 2009 13:24:45 +0000 (UTC) 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 n8GDOgPW029215; Wed, 16 Sep 2009 08:24:45 -0500 X-WSS-ID: 0KQ2FX2-01-3ND-02 X-M-MSG: Received: from sausexbh1.amd.com (sausexbh1.amd.com [163.181.22.101]) by ausb3twp01.amd.com (Tumbleweed MailGate 3.7.0) with ESMTP id 209651028501; Wed, 16 Sep 2009 08:24:38 -0500 (CDT) Received: from sausexmb4.amd.com ([163.181.3.15]) by sausexbh1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 16 Sep 2009 08:24:41 -0500 Received: from SDRSEXMB1.amd.com ([172.20.3.116]) by sausexmb4.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 16 Sep 2009 08:24:40 -0500 Received: from seurexmb1.amd.com ([165.204.9.130]) by SDRSEXMB1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 16 Sep 2009 15:24:29 +0200 Received: from lemmy.amd.com ([165.204.15.93]) by seurexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 16 Sep 2009 15:24:23 +0200 Received: by lemmy.amd.com (Postfix, from userid 41430) id BD9BAC9ACA; Wed, 16 Sep 2009 15:24:22 +0200 (CEST) From: Joerg Roedel To: Avi Kivity CC: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Alexander Graf , Joerg Roedel Subject: [PATCH 1/5] KVM: SVM: reorganize svm_interrupt_allowed Date: Wed, 16 Sep 2009 15:24:15 +0200 Message-ID: <1253107459-8967-2-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1253107459-8967-1-git-send-email-joerg.roedel@amd.com> References: <1253107459-8967-1-git-send-email-joerg.roedel@amd.com> X-OriginalArrivalTime: 16 Sep 2009 13:24:23.0156 (UTC) FILETIME=[014FEB40:01CA36D1] MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This patch reorganizes the logic in svm_interrupt_allowed to make it better to read. This is important because the logic is a lot more complicated with Nested SVM. Signed-off-by: Joerg Roedel --- arch/x86/kvm/svm.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index a2f2d43..668460c 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -2454,10 +2454,18 @@ static int svm_interrupt_allowed(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); struct vmcb *vmcb = svm->vmcb; - return (vmcb->save.rflags & X86_EFLAGS_IF) && - !(vmcb->control.int_state & SVM_INTERRUPT_SHADOW_MASK) && - gif_set(svm) && - !(is_nested(svm) && (svm->vcpu.arch.hflags & HF_VINTR_MASK)); + int ret; + + if (!gif_set(svm) || + (vmcb->control.int_state & SVM_INTERRUPT_SHADOW_MASK)) + return 0; + + ret = !!(vmcb->save.rflags & X86_EFLAGS_IF); + + if (is_nested(svm)) + return ret && !(svm->vcpu.arch.hflags & HF_VINTR_MASK); + + return ret; } static void enable_irq_window(struct kvm_vcpu *vcpu)