[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] hvm: Fix evtchn-to-fake-pci interrupt propagation.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1199807729 0
# Node ID 9865d5e82802fda2ac842c0c28a0833f2126551f
# Parent  1ffa3c1335a460877ca10d780d9783a496fabb4d
hvm: Fix evtchn-to-fake-pci interrupt propagation.

Previously the evtchn_upcall_pending flag would only ever be sampled
on VCPU0, possibly leading to long delays in deasserting the
fake-pci-device INTx line if the interrupt is actually delivered to
other than VCPU0.

Diagnosed by Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 xen/arch/x86/hvm/irq.c        |   34 ++++++++++++++++++++--------------
 xen/arch/x86/hvm/svm/intr.c   |    2 +-
 xen/arch/x86/hvm/vmx/intr.c   |    4 +---
 xen/include/asm-x86/event.h   |    7 ++++++-
 xen/include/asm-x86/hvm/irq.h |    3 ++-
 5 files changed, 30 insertions(+), 20 deletions(-)

diff -r 1ffa3c1335a4 -r 9865d5e82802 xen/arch/x86/hvm/irq.c
--- a/xen/arch/x86/hvm/irq.c    Tue Jan 08 14:35:18 2008 +0000
+++ b/xen/arch/x86/hvm/irq.c    Tue Jan 08 15:55:29 2008 +0000
@@ -125,17 +125,13 @@ void hvm_isa_irq_deassert(
     spin_unlock(&d->arch.hvm_domain.irq_lock);
 }
 
-void hvm_set_callback_irq_level(void)
-{
-    struct vcpu *v = current;
+static void hvm_set_callback_irq_level(struct vcpu *v)
+{
     struct domain *d = v->domain;
     struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq;
     unsigned int gsi, pdev, pintx, asserted;
 
-    /* Fast lock-free tests. */
-    if ( (v->vcpu_id != 0) ||
-         (hvm_irq->callback_via_type == HVMIRQ_callback_none) )
-        return;
+    ASSERT(v->vcpu_id == 0);
 
     spin_lock(&d->arch.hvm_domain.irq_lock);
 
@@ -175,6 +171,22 @@ void hvm_set_callback_irq_level(void)
 
  out:
     spin_unlock(&d->arch.hvm_domain.irq_lock);
+}
+
+void hvm_maybe_deassert_evtchn_irq(void)
+{
+    struct domain *d = current->domain;
+    struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq;
+
+    if ( hvm_irq->callback_via_asserted &&
+         !vcpu_info(d->vcpu[0], evtchn_upcall_pending) )
+        hvm_set_callback_irq_level(d->vcpu[0]);
+}
+
+void hvm_assert_evtchn_irq(struct vcpu *v)
+{
+    if ( v->vcpu_id == 0 )
+        hvm_set_callback_irq_level(v);
 }
 
 void hvm_set_pci_link_route(struct domain *d, u8 link, u8 isa_irq)
@@ -349,13 +361,7 @@ struct hvm_intack hvm_vcpu_ack_pending_i
 
 int hvm_local_events_need_delivery(struct vcpu *v)
 {
-    struct hvm_intack intack;
-
-    /* TODO: Get rid of event-channel special case. */
-    if ( vcpu_info(v, evtchn_upcall_pending) )
-        intack = hvm_intack_pic(0);
-    else
-        intack = hvm_vcpu_has_pending_irq(v);
+    struct hvm_intack intack = hvm_vcpu_has_pending_irq(v);
 
     if ( likely(intack.source == hvm_intsrc_none) )
         return 0;
diff -r 1ffa3c1335a4 -r 9865d5e82802 xen/arch/x86/hvm/svm/intr.c
--- a/xen/arch/x86/hvm/svm/intr.c       Tue Jan 08 14:35:18 2008 +0000
+++ b/xen/arch/x86/hvm/svm/intr.c       Tue Jan 08 15:55:29 2008 +0000
@@ -102,7 +102,7 @@ asmlinkage void svm_intr_assist(void)
 
     /* Crank the handle on interrupt state. */
     pt_update_irq(v);
-    hvm_set_callback_irq_level();
+    hvm_maybe_deassert_evtchn_irq();
 
     do {
         intack = hvm_vcpu_has_pending_irq(v);
diff -r 1ffa3c1335a4 -r 9865d5e82802 xen/arch/x86/hvm/vmx/intr.c
--- a/xen/arch/x86/hvm/vmx/intr.c       Tue Jan 08 14:35:18 2008 +0000
+++ b/xen/arch/x86/hvm/vmx/intr.c       Tue Jan 08 15:55:29 2008 +0000
@@ -156,10 +156,8 @@ asmlinkage void vmx_intr_assist(void)
 
     /* Crank the handle on interrupt state. */
     pt_update_irq(v);
-
     vmx_dirq_assist(v);
-  
-    hvm_set_callback_irq_level();
+    hvm_maybe_deassert_evtchn_irq();
 
     do {
         intack = hvm_vcpu_has_pending_irq(v);
diff -r 1ffa3c1335a4 -r 9865d5e82802 xen/include/asm-x86/event.h
--- a/xen/include/asm-x86/event.h       Tue Jan 08 14:35:18 2008 +0000
+++ b/xen/include/asm-x86/event.h       Tue Jan 08 15:55:29 2008 +0000
@@ -30,7 +30,12 @@ static inline void vcpu_kick(struct vcpu
 
 static inline void vcpu_mark_events_pending(struct vcpu *v)
 {
-    if ( !test_and_set_bit(0, &vcpu_info(v, evtchn_upcall_pending)) )
+    if ( test_and_set_bit(0, &vcpu_info(v, evtchn_upcall_pending)) )
+        return;
+
+    if ( is_hvm_vcpu(v) )
+        hvm_assert_evtchn_irq(v);
+    else
         vcpu_kick(v);
 }
 
diff -r 1ffa3c1335a4 -r 9865d5e82802 xen/include/asm-x86/hvm/irq.h
--- a/xen/include/asm-x86/hvm/irq.h     Tue Jan 08 14:35:18 2008 +0000
+++ b/xen/include/asm-x86/hvm/irq.h     Tue Jan 08 15:55:29 2008 +0000
@@ -152,7 +152,8 @@ void hvm_isa_irq_deassert(
 
 void hvm_set_pci_link_route(struct domain *d, u8 link, u8 isa_irq);
 
-void hvm_set_callback_irq_level(void);
+void hvm_maybe_deassert_evtchn_irq(void);
+void hvm_assert_evtchn_irq(struct vcpu *v);
 void hvm_set_callback_via(struct domain *d, uint64_t via);
 
 /* Check/Acknowledge next pending interrupt. */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.