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

[Xen-devel] [PATCH] x86: irq: Do not BUG_ON multiple unbind calls for shared pirqs



It is possible to receive multiple __pirq_guest_unbind calls for the same pirq
if the pirq has not yet been removed from the domain's pirq_tree. For a shared
pirq (nr_guests > 1), the first call zaps the current domain from the pirq's
guests[] list, but the action handler is never freed as there are other guests
using this pirq. As a result, on the second call, __pirq_guest_unbind tries
search for the current domain which has been removed from the guests[] list,
and hits a BUG_ON.

Allow xen to continue if a shared pirq has already been unbound from this guest.
It will be cleaned up from the domain's pirq_tree during the destruction in
complete_domain_destroy.

Signed-off-by: Varad Gautam <vrd@xxxxxxxxx>

---

To apply stable-4.11 onwards.

 xen/arch/x86/irq.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index 094c3c5..256f503 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -1711,7 +1711,15 @@ static irq_guest_action_t *__pirq_guest_unbind(
 
     for ( i = 0; (i < action->nr_guests) && (action->guest[i] != d); i++ )
         continue;
-    BUG_ON(i == action->nr_guests);
+    if ( i == action->nr_guests ) {
+        /* In case the pirq was shared, unbound for this domain in an earlier 
call, but still
+         * existed on the domain's pirq_tree, we still reach here if there are 
any later
+         * unbind calls on the same pirq. Return if such an unbind happens. */
+        if ( action->nr_guests > 0 && action->shareable )
+            return NULL;
+        BUG();
+    }
+
     memmove(&action->guest[i], &action->guest[i+1],
             (action->nr_guests-i-1) * sizeof(action->guest[0]));
     action->nr_guests--;
-- 
2.7.4




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Ralf Herbrich
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879




_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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