From: Oleksandr Tyshchenko Date: Fri, 2 Dec 2016 16:38:16 +0000 (+0200) Subject: arm/irq: Reorder check when the IRQ is already used by someone X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~3267 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=02fea427a6ac496d642a8055f5f168e6f985a4f6;p=xen.git arm/irq: Reorder check when the IRQ is already used by someone Call irq_get_domain for the IRQ we are interested in only after making sure that it is the guest IRQ to avoid ASSERT(test_bit(_IRQ_GUEST, &desc->status)) triggering. Signed-off-by: Oleksandr Tyshchenko Signed-off-by: Andrii Anisov Reviewed-by: Stefano Stabellini --- diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c index 06d4843b45..508028b02e 100644 --- a/xen/arch/arm/irq.c +++ b/xen/arch/arm/irq.c @@ -477,26 +477,32 @@ int route_irq_to_guest(struct domain *d, unsigned int virq, */ if ( desc->action != NULL ) { - struct domain *ad = irq_get_domain(desc); - - if ( test_bit(_IRQ_GUEST, &desc->status) && d == ad ) + if ( test_bit(_IRQ_GUEST, &desc->status) ) { - if ( irq_get_guest_info(desc)->virq != virq ) + struct domain *ad = irq_get_domain(desc); + + if ( d == ad ) + { + if ( irq_get_guest_info(desc)->virq != virq ) + { + printk(XENLOG_G_ERR + "d%u: IRQ %u is already assigned to vIRQ %u\n", + d->domain_id, irq, irq_get_guest_info(desc)->virq); + retval = -EBUSY; + } + } + else { - printk(XENLOG_G_ERR - "d%u: IRQ %u is already assigned to vIRQ %u\n", - d->domain_id, irq, irq_get_guest_info(desc)->virq); + printk(XENLOG_G_ERR "IRQ %u is already used by domain %u\n", + irq, ad->domain_id); retval = -EBUSY; } - goto out; } - - if ( test_bit(_IRQ_GUEST, &desc->status) ) - printk(XENLOG_G_ERR "IRQ %u is already used by domain %u\n", - irq, ad->domain_id); else + { printk(XENLOG_G_ERR "IRQ %u is already used by Xen\n", irq); - retval = -EBUSY; + retval = -EBUSY; + } goto out; }