From patchwork Tue May 12 15:06:39 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dong, Eddie" X-Patchwork-Id: 23260 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 n4CFBOmQ027638 for ; Tue, 12 May 2009 15:11:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751318AbZELPK5 (ORCPT ); Tue, 12 May 2009 11:10:57 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753916AbZELPK4 (ORCPT ); Tue, 12 May 2009 11:10:56 -0400 Received: from mga01.intel.com ([192.55.52.88]:17870 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751274AbZELPKz (ORCPT ); Tue, 12 May 2009 11:10:55 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 12 May 2009 07:59:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.41,182,1241420400"; d="scan'208";a="689743710" Received: from pgsmsx602.gar.corp.intel.com ([10.221.43.81]) by fmsmga001.fm.intel.com with ESMTP; 12 May 2009 08:14:29 -0700 Received: from pdsmsx601.ccr.corp.intel.com (172.16.12.94) by pgsmsx602.gar.corp.intel.com (10.221.43.81) with Microsoft SMTP Server (TLS) id 8.1.340.0; Tue, 12 May 2009 23:08:41 +0800 Received: from pdsmsx503.ccr.corp.intel.com ([172.16.12.95]) by pdsmsx601.ccr.corp.intel.com ([172.16.12.94]) with mapi; Tue, 12 May 2009 23:08:40 +0800 From: "Dong, Eddie" To: Avi Kivity CC: "kvm@vger.kernel.org" , "Dong, Eddie" , "Dong, Eddie" Date: Tue, 12 May 2009 23:06:39 +0800 Subject: Enable IRQ windows after exception injection if there are pending virq Thread-Topic: Enable IRQ windows after exception injection if there are pending virq Thread-Index: AcnSz3TYpdcxRvC3ROS4DAVk9HBgmAAQeDng Message-ID: <9832F13BD22FB94A829F798DA4A8280501B24E5674@pdsmsx503.ccr.corp.intel.com> References: <9832F13BD22FB94A829F798DA4A8280501A81A8E83@pdsmsx503.ccr.corp.intel.com> <20090508095336.GD25357@redhat.com> <9832F13BD22FB94A829F798DA4A8280501A81A8EFE@pdsmsx503.ccr.corp.intel.com> <9832F13BD22FB94A829F798DA4A8280501A81A8F02@pdsmsx503.ccr.corp.intel.com> <20090508122358.GF25357@redhat.com> <9832F13BD22FB94A829F798DA4A8280501A81A8F2B@pdsmsx503.ccr.corp.intel.com> <20090508184417.GA27255@redhat.com> <9832F13BD22FB94A829F798DA4A8280501A81A9078@pdsmsx503.ccr.corp.intel.com> <20090511060224.GH18554@redhat.com> <9832F13BD22FB94A829F798DA4A8280501B24E53E6@pdsmsx503.ccr.corp.intel.com> <20090512070113.GB1013@redhat.com> In-Reply-To: <20090512070113.GB1013@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org I didn't take many test since our PTS system stop working now due to KVM userspace build changes. But since the logic is pretty simple, so I want to post here to see comments. Thx, eddie If there is pending irq after an virtual exception is injected, KVM needs to enable IRQ window to trap back earlier once the exception is handled. Signed-off-by: Eddie Dong diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 308d8e9..f8ceaea 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3154,15 +3154,18 @@ static void inject_irq(struct kvm_vcpu *vcpu) } } -static void inject_pending_irq(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) +static void inject_pending_irq(struct kvm_vcpu *vcpu) { - bool req_int_win = !irqchip_in_kernel(vcpu->kvm) && - kvm_run->request_interrupt_window; - if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) kvm_x86_ops->drop_interrupt_shadow(vcpu); inject_irq(vcpu); +} + +static void set_pending_virq(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) +{ + bool req_int_win = !irqchip_in_kernel(vcpu->kvm) && + kvm_run->request_interrupt_window; /* enable NMI/IRQ window open exits if needed */ if (vcpu->arch.nmi_pending) @@ -3229,7 +3232,9 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) if (vcpu->arch.exception.pending) __queue_exception(vcpu); else - inject_pending_irq(vcpu, kvm_run); + inject_pending_irq(vcpu); + + set_pending_virq(vcpu, kvm_run); if (kvm_lapic_enabled(vcpu)) { if (!vcpu->arch.apic->vapic_addr)