diff mbox

Enable IRQ windows after exception injection if there are pending virq

Message ID 9832F13BD22FB94A829F798DA4A8280501B24E5674@pdsmsx503.ccr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dong, Eddie May 12, 2009, 3:06 p.m. UTC
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 <eddie.dong@intel.com>

Comments

Gleb Natapov May 12, 2009, 3:27 p.m. UTC | #1
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 <eddie.dong@intel.com>
> 
> 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.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dong, Eddie May 13, 2009, 7:45 a.m. UTC | #2
Gleb Natapov wrote:
> 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?
> 
Is it base on the idea I mentioned to you in private mail (April 27), or a novel one?

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gleb Natapov May 13, 2009, 10:29 a.m. UTC | #3
On Wed, May 13, 2009 at 03:45:37PM +0800, Dong, Eddie wrote:
> Gleb Natapov wrote:
> > 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?
> > 
> Is it base on the idea I mentioned to you in private mail (April 27), or a novel one?
> 
Yes. It fixes the bug you pointed out.

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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)