Avi:
        This patch may be questionable at least for current VMX.
        If VM_ENTRY_INTR_INFO_FIELD is already set valid by
previous irq injection, next injection will be refused with IRQ window
enabled. This is because current implementation will inject exception
earlier than irq injection and vmx_intr_assist doesn;t know if previous
injected event is external irq (and thus overwrite) or exception. Guest
will see lower priority irq get injected rather than higher priority IRQ
which
arrives later.

        BTW, I didn't see obvious benfit from this patch since 
inject_pending_irq still happens later after IRQ disable. maybe I miss
something.

thx,eddie




[EMAIL PROTECTED] wrote:
> repository: /home/avi/kvm/linux-2.6
> branch: master
> commit 817b54a86b0a3e0e5955714b84577101ffff9c59
> 
>    KVM: Move interrupt injection out of interrupt disabled section
> 
>    Instead of injecting interrupts while we're in the
> critical section during
>    the guest switch, inject them earlier.  In case we had an
> irq raised between
>    the injection point and the switch, we check a bit during
> guest switch and
>    if needed we go back and redo the injection.
> 
>    This improves system latency, and allows sleeping during
> injection (which
>    is needed when injecting real-mode interrupts on Intel).
> 
> diff --git a/drivers/kvm/i8259.c b/drivers/kvm/i8259.c
> index f0dc2ee..fb7176e 100644
> --- a/drivers/kvm/i8259.c
> +++ b/drivers/kvm/i8259.c
> @@ -420,7 +420,7 @@ static void pic_irq_request(void *opaque,
> int level)
> 
>       pic_irqchip(kvm)->output = level;
>       if (vcpu)
> -             kvm_vcpu_kick(vcpu);
> +             kvm_vcpu_kick_request(vcpu, KVM_REQ_INTR);
> }
> 
> struct kvm_pic *kvm_create_pic(struct kvm *kvm)
> diff --git a/drivers/kvm/irq.c b/drivers/kvm/irq.c
> index 7628c7f..851995d 100644
> --- a/drivers/kvm/irq.c
> +++ b/drivers/kvm/irq.c
> @@ -83,6 +83,12 @@ void kvm_vcpu_kick(struct kvm_vcpu *vcpu)
>               smp_call_function_single(ipi_pcpu,
> vcpu_kick_intr, vcpu, 0, 0);
> }
> 
> +void kvm_vcpu_kick_request(struct kvm_vcpu *vcpu, int request) +{
> +     set_bit(request, &vcpu->requests);
> +     kvm_vcpu_kick(vcpu);
> +}
> +
> void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu) {
>       kvm_inject_apic_timer_irqs(vcpu);
> diff --git a/drivers/kvm/irq.h b/drivers/kvm/irq.h
> index 5ad3cfd..0277e3a 100644
> --- a/drivers/kvm/irq.h
> +++ b/drivers/kvm/irq.h
> @@ -134,6 +134,7 @@ do {
>                               \
> #endif
> 
> void kvm_vcpu_kick(struct kvm_vcpu *vcpu);
> +void kvm_vcpu_kick_request(struct kvm_vcpu *vcpu, int request);
> int kvm_apic_has_interrupt(struct kvm_vcpu *vcpu);
> int kvm_apic_accept_pic_intr(struct kvm_vcpu *vcpu);
> int kvm_get_apic_interrupt(struct kvm_vcpu *vcpu);
> diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
> index 1edf8a5..b18d44c 100644
> --- a/drivers/kvm/kvm.h
> +++ b/drivers/kvm/kvm.h
> @@ -68,6 +68,7 @@
>  * vcpu->requests bit members
>  */
> #define KVM_TLB_FLUSH 0
> +#define KVM_REQ_INTR               1
> 
> /*
>  * Address types:
> diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
> index 8eadb6d..9188bde 100644
> --- a/drivers/kvm/kvm_main.c
> +++ b/drivers/kvm/kvm_main.c
> @@ -2174,6 +2174,13 @@ again:
> 
>       local_irq_disable();
> 
> +     kvm_inject_pending_timer_irqs(vcpu);
> +     clear_bit(KVM_REQ_INTR, &vcpu->requests);
> +     if (irqchip_in_kernel(vcpu->kvm))
> +             kvm_x86_ops->inject_pending_irq(vcpu);
> +     else if (!vcpu->mmio_read_completed)
> +             kvm_x86_ops->inject_pending_vectors(vcpu, kvm_run); +
>       if (signal_pending(current)) {
>               local_irq_enable();
>               preempt_enable();
> @@ -2183,18 +2190,20 @@ again:
>               goto out;
>       }
> 
> -     if (irqchip_in_kernel(vcpu->kvm))
> -             kvm_x86_ops->inject_pending_irq(vcpu);
> -     else if (!vcpu->mmio_read_completed)
> -             kvm_x86_ops->inject_pending_vectors(vcpu, kvm_run); +
if
> (vcpu->requests) { +          if (test_and_clear_bit(KVM_TLB_FLUSH,
> &vcpu->requests)) +                   kvm_x86_ops->tlb_flush(vcpu);
> +             if (test_bit(KVM_REQ_INTR, &vcpu->requests)) {
> +                     local_irq_enable();
> +                     preempt_enable();
> +                     r = 1;
> +                     goto out;
> +             }
> +     }
> 
>       vcpu->guest_mode = 1;
>       kvm_guest_enter();
> 
> -     if (vcpu->requests)
> -             if (test_and_clear_bit(KVM_TLB_FLUSH, &vcpu->requests))
> -                     kvm_x86_ops->tlb_flush(vcpu);
> -
>       kvm_x86_ops->run(vcpu, kvm_run);
> 
>       kvm_guest_exit();
> diff --git a/drivers/kvm/lapic.c b/drivers/kvm/lapic.c
> index d24cbfa..1eca94f 100644
> --- a/drivers/kvm/lapic.c
> +++ b/drivers/kvm/lapic.c
> @@ -191,7 +191,7 @@ int kvm_apic_set_irq(struct kvm_lapic *apic, u8
>                       vec, u8 trig) apic_set_vector(vec, apic->regs +
APIC_TMR);
>               else
>                       apic_clear_vector(vec, apic->regs + APIC_TMR);
> -             kvm_vcpu_kick(apic->vcpu);
> +             kvm_vcpu_kick_request(apic->vcpu, KVM_REQ_INTR);
return 1;
>       }
>       return 0;
> @@ -336,7 +336,7 @@ static int __apic_accept_irq(struct
> kvm_lapic *apic, int delivery_mode,
>                       apic_clear_vector(vector, apic->regs +
> APIC_TMR);
> 
>               if (vcpu->mp_state == VCPU_MP_STATE_RUNNABLE)
> -                     kvm_vcpu_kick(vcpu);
> +                     kvm_vcpu_kick_request(vcpu, KVM_REQ_INTR);
>               else if (vcpu->mp_state == VCPU_MP_STATE_HALTED) {
>                       vcpu->mp_state = VCPU_MP_STATE_RUNNABLE;
>                       if (waitqueue_active(&vcpu->wq))
> @@ -364,7 +364,7 @@ static int __apic_accept_irq(struct
> kvm_lapic *apic, int delivery_mode,
>                                      "INIT on a runnable vcpu %d\n",
>                                      vcpu->vcpu_id);
>                       vcpu->mp_state = VCPU_MP_STATE_INIT_RECEIVED;
> -                     kvm_vcpu_kick(vcpu);
> +                     kvm_vcpu_kick_request(vcpu, KVM_REQ_INTR);
>               } else {
>                       printk(KERN_DEBUG
>                              "Ignoring de-assert INIT to vcpu %d\n",
> 
> ---------------------------------------------------------------
> ----------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a
> browser. Download your FREE copy of Splunk now >>
> http://get.splunk.com/ _______________________________________________
> kvm-commits mailing list
> kvm-commits@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/kvm-commits

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
kvm-commits mailing list
kvm-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-commits

Reply via email to