Skip to contentSkip to conversation

arm/irq: Reorder check when the IRQ is already used by someone

PATCH Applied Oleksandr Tyshchenko 3 participants 7 messages Dec 2, 2016 – Dec 5, 2016

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 xen/arch/arm/irq.c | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)
xen/arch/arm/irq.c +19 -13
index 06d4843..508028b 100644
@@ -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;
     }
 
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 1/1 Applied
#1 lore raw
Quoted 6 lines · Oleksandr Tyshchenko

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.

Applied to xen-arm-next (queued for the next release).

Quoted 44 lines
 xen/arch/arm/irq.c | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)
xen/arch/arm/irq.c +19 -1
index 06d4843..508028b 100644
@@ -477,26 +477,32 @@ int route_irq_to_guest(struct domain *d, unsigned int virq,
      */
     if ( desc->action != NULL )
     {
+        if ( test_bit(_IRQ_GUEST, &desc->status) )
         {
+            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 "IRQ %u is already used by domain %u\n",
+                       irq, ad->domain_id);
                 retval = -EBUSY;
             }
         }
         else
+        {
             printk(XENLOG_G_ERR "IRQ %u is already used by Xen\n", irq);
-        retval = -EBUSY;
+            retval = -EBUSY;
+        }
         goto out;
     }
 
Signature · 1 line
2.7.4

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw
In reply to Oleksandr Tyshchenko

Hi Oleksandr,

Quoted 19 lines · Oleksandr Tyshchenko

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.

---
 xen/arch/arm/irq.c | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)
xen/arch/arm/irq.c +0 -1
index 06d4843..508028b 100644
@@ -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);

xen/arch/arm/irq.c int route_irq_to_guest(struct domain *d, unsigned int virq, · line 486

Quoted 10 lines
xen/arch/arm/irq.c +6 -3
-
-        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 )

I know that Stefano already reviewed and queued this patch. But 4 layer of if seems a bit too much and could have been avoided by re-ordering the check.

if ( d != ad )
....
else if ( irq_get_guest_info(desc->virq != virq) )
....

Can you please send a follow-up to remove one layer of 1?

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#3 lore raw
Quoted 1 line · Julien Grall

Hi Oleksandr,

Hi Julien

Quoted 40 lines · Oleksandr Tyshchenko
Quoted 22 lines

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.

---
 xen/arch/arm/irq.c | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)
xen/arch/arm/irq.c +0 -2
index 06d4843..508028b 100644
@@ -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);
-

xen/arch/arm/irq.c int route_irq_to_guest(struct domain *d, unsigned · line 488

Quoted 10 lines
xen/arch/arm/irq.c +6 -2
-        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 )
 

I know that Stefano already reviewed and queued this patch. But 4 layer of if seems a bit too much and could have been avoided by re-ordering the check.

Quoted 7 lines

if ( d != ad )
....
else if ( irq_get_guest_info(desc->virq != virq) )
....

Can you please send a follow-up to remove one layer of 1?

Sure

Quoted 6 lines

Regards,

--
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw
In reply to Oleksandr Tyshchenko

Hi Oleksandr,

Quoted 5 lines · Oleksandr Tyshchenko

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.

I forgot to mention that your Signed-off-by does not match the From.
In the future, please make sure that the author e-mail (the From) is listed in the signed-off.

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#5 lore raw
Quoted 2 lines · Julien Grall

Hi Oleksandr,

Hi Julien,

Quoted 7 lines · Oleksandr Tyshchenko
Quoted 5 lines

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.

Quoted 7 lines
Quoted 2 lines

I forgot to mention that your Signed-off-by does not match the From. In the future, please make sure that the author e-mail (the From) is listed in the signed-off.

Got it

Quoted 6 lines

Regards,

--
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#6 lore raw
In reply to Julien Grall
Quoted 7 lines · Julien Grall

Hi Oleksandr,

Quoted 4 lines · Oleksandr Tyshchenko

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.

Quoted 5 lines
Quoted 1 line

I forgot to mention that your Signed-off-by does not match the From. In the future, please make sure that the author e-mail (the From) is listed in the signed-off.

CC'ing Lars.

Actually I don't think this is required: Signed-off-by is about copyright ownership, that is where using the company email is important. But I don't think it is necessary for the authorship, that is what From:
is about. Authorship is just to give credit to the author, it could be a pseudonym, I think. I am pretty sure that I have seen other instances of this on the LKML.

For example:

Alice works for Bob
Alice writes a patch, Bob has copyright ownership Chris takes Alice's patch and sends it to xen-devel

Chris should use its own email address in the email From: field; he uses Alice's email address (doesn't matter which) in the From: field within the patch; he should use Bob's email as Signed-off-by:

From: Chris
Subject: [PATCH] fix something

From: Alice
This patch fixes something

Signed-off-by Bob

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel