Skip to contentSkip to conversation

XenFreeBSD lockup fix

DISCUSSION Kip Macy 1 participant 1 message Apr 22, 2005

lore
Share & tools
lore

Kip Macy

author
#0 lore raw

Old bug.

# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet

#   2005/04/22 15:19:02-07:00 [email protected] 
#   Fix lockup in evtchn_do_upcall
#   Signed-off-by: Kip Macy <[email protected]>
# 
# freebsd-5.3-xen-sparse/i386-xen/i386-xen/evtchn.c
#   2005/04/22 15:18:57-07:00 [email protected] +6 -1
#   Work around potential recursive locking in event channel handler
# 
diff -Nru a/freebsd-5.3-xen-sparse/i386-xen/i386-xen/evtchn.c
b/freebsd-5.3-xen-sparse/i386-xen/i386-xen/e
vtchn.c
--- a/freebsd-5.3-xen-sparse/i386-xen/i386-xen/evtchn.c 2005-04-21
15:24:19 -07:00
+++ b/freebsd-5.3-xen-sparse/i386-xen/i386-xen/evtchn.c 2005-04-21
15:24:19 -07:00
@@ -54,7 +54,7 @@
 {
     unsigned long  l1, l2;
     unsigned int   l1i, l2i, port;
-    int            irq;
+    int            irq, owned;
     unsigned long  flags;
     shared_info_t *s = HYPERVISOR_shared_info;
     vcpu_info_t   *vcpu_info = &s->vcpu_data[smp_processor_id()];
@@ -78,12 +78,17 @@
                 l2 &= ~(1 << l2i);
                 port = (l1i << 5) + l2i;
+               if ((owned = mtx_owned(&sched_lock)) != 0)
+                        mtx_unlock_spin_flags(&sched_lock, MTX_QUIET);
                 if ( (irq = evtchn_to_irq[port]) != -1 ) {
                    struct intsrc *isrc = intr_lookup_source(irq);
                    intr_execute_handlers(isrc, frame);
                } else {
                     evtchn_device_upcall(port);
                }
+               if (owned)
+                   mtx_lock_spin_flags(&sched_lock, MTX_QUIET);
+
             }
         }
     }