From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: Enable IRQ windows after exception injection if there are pending virq Date: Tue, 12 May 2009 18:27:14 +0300 Message-ID: <20090512152714.GN19446@redhat.com> References: <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> <9832F13BD22FB94A829F798DA4A8280501B24E5674@pdsmsx503.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Avi Kivity , "kvm@vger.kernel.org" To: "Dong, Eddie" Return-path: Received: from mx2.redhat.com ([66.187.237.31]:60048 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751752AbZELP1Q (ORCPT ); Tue, 12 May 2009 11:27:16 -0400 Content-Disposition: inline In-Reply-To: <9832F13BD22FB94A829F798DA4A8280501B24E5674@pdsmsx503.ccr.corp.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, May 12, 2009 at 11:06:39PM +0800, Dong, Eddie wrote: > > 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. > I already posted patch to do that http://patchwork.kernel.org/patch/21830/ Is you patch different? > 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) -- Gleb.