Skip to contentSkip to conversation

xen/arm: setup_dt_irq: don't enable the IRQ if the creation has failed

PATCH In review Julien Grall 2 participants 7 messages Jan 10, 2014 – Jan 24, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: setup_dt_irq: don't enable the IRQ if the creation has failed

For now __setup_dt_irq can only fail if the action is already set. If in the future, the function is updated we don't want to enable the IRQ.

Assuming the function can fail with action = NULL, when Xen will receive the IRQ it will segfault because do_IRQ doesn't check if action is NULL.

---
 xen/arch/arm/gic.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/gic.c +2 -2
index e6257a7..62510e3 100644
@@ -605,8 +605,8 @@ int __init setup_dt_irq(const struct dt_irq *irq, struct irqaction *new)
     rc = __setup_irq(desc, irq->irq, new);
     spin_unlock_irqrestore(&desc->lock, flags);
 
-    desc->handler->startup(desc);
-
+    if ( !rc )
+        desc->handler->startup(desc);
 
     return rc;
 }
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 1 line · Julien Grall

For now __setup_dt_irq can only fail if the action is already set.

Can this ever happen with the current code base?

Quoted 1 line

If in the future, the function is updated we don't want to enable the IRQ.

Such an update is likely to be post-4.4 (unless there is a relationship with "IRQ: Protect IRQ to be shared between domains and XEN" AND the RM becomes convinced to grant a freeze exception for that patch).

On that basis this patch could also easily be post-4.4.

Quoted 2 lines

Assuming the function can fail with action = NULL, when Xen will receive the IRQ it will segfault because do_IRQ doesn't check if action is NULL.

It seems unlikely that the system would be fully functional after such an error even with this patch -- it would have failed to register either timer, maintenance or the console interrupt.

Quoted 21 lines
---
 xen/arch/arm/gic.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/gic.c +2 -2
index e6257a7..62510e3 100644
@@ -605,8 +605,8 @@ int __init setup_dt_irq(const struct dt_irq *irq, struct irqaction *new)
     rc = __setup_irq(desc, irq->irq, new);
     spin_unlock_irqrestore(&desc->lock, flags);
 
-    desc->handler->startup(desc);
-
+    if ( !rc )
+        desc->handler->startup(desc);
 
     return rc;
 }
#2 lore raw
Quoted 4 lines · Ian Campbell
Quoted 1 line · Julien Grall

For now __setup_dt_irq can only fail if the action is already set.

Can this ever happen with the current code base?

No, that why I didn't ask for a freeze exception for Xen 4.4.

Quoted 7 lines
Quoted 2 lines

If in the future, the function is updated we don't want to enable the IRQ.

Such an update is likely to be post-4.4 (unless there is a relationship with "IRQ: Protect IRQ to be shared between domains and XEN" AND the RM becomes convinced to grant a freeze exception for that patch).

Quoted 8 lines

On that basis this patch could also easily be post-4.4.

Quoted 2 lines

Assuming the function can fail with action = NULL, when Xen will receive the IRQ it will segfault because do_IRQ doesn't check if action is NULL.

It seems unlikely that the system would be fully functional after such an error even with this patch -- it would have failed to register either timer, maintenance or the console interrupt.

Timer and maintenance code don't check the return of request_dt_irq (which call setup_dt_irq).

For the console interrupt, the callback which initialize the interrupt doesn't return an error... On every serial driver, only an error message is printed.

In any case, it's wrong to enable this IRQ if the descriptor is not correctly setup.

Quoted 24 lines
Quoted 22 lines
---
 xen/arch/arm/gic.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/gic.c +2 -2
index e6257a7..62510e3 100644
@@ -605,8 +605,8 @@ int __init setup_dt_irq(const struct dt_irq *irq, struct irqaction *new)
     rc = __setup_irq(desc, irq->irq, new);
     spin_unlock_irqrestore(&desc->lock, flags);
 
-    desc->handler->startup(desc);
-
+    if ( !rc )
+        desc->handler->startup(desc);
 
     return rc;
 }
Signature · 1 line
Julien Grall
#3 lore raw
Quoted 7 lines · Julien Grall
Quoted 4 lines · Ian Campbell
Quoted 1 line · Julien Grall

For now __setup_dt_irq can only fail if the action is already set.

Can this ever happen with the current code base?

No, that why I didn't ask for a freeze exception for Xen 4.4.

Ah ok. It is useful to tag patches which aren't for consideration (and those which are for that matter, although the exception request suffices there).

I'll put this in my 4.5 queue and consider it again later. Please ping me a little while after 4.4 branches if I haven't done so.

#4 lore raw
Quoted 5 lines · Ian Campbell
Quoted 4 lines · Julien Grall
Quoted 3 lines · Ian Campbell
Quoted 1 line · Julien Grall

For now __setup_dt_irq can only fail if the action is already set.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Can this ever happen with the current code base?

No, that why I didn't ask for a freeze exception for Xen 4.4.

Ah ok. It is useful to tag patches which aren't for consideration (and those which are for that matter, although the exception request suffices there).

Do you have a specific tag in my mind for this purpose?

Quoted 2 lines

I'll put this in my 4.5 queue and consider it again later. Please ping me a little while after 4.4 branches if I haven't done so.

Thanks.

Signature · 1 line
Julien Grall
#5 lore raw
Quoted 8 lines · Julien Grall
Quoted 7 lines · Ian Campbell
Quoted 6 lines · Julien Grall
Quoted 4 lines · Ian Campbell
Quoted 1 line · Julien Grall

For now __setup_dt_irq can only fail if the action is already set.

Can this ever happen with the current code base?

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

No, that why I didn't ask for a freeze exception for Xen 4.4.

Ah ok. It is useful to tag patches which aren't for consideration (and those which are for that matter, although the exception request suffices there).

Do you have a specific tag in my mind for this purpose?

Anything would do, either [PATCH for-4.5] in $subject or:
---
This patch is for 4.5
after the commit message etc.

Ian.

#6 lore raw
In reply to Ian Campbell
Quoted 3 lines · Ian Campbell

I'll put this in my 4.5 queue and consider it again later. Please ping me a little while after 4.4 branches if I haven't done so.

I plan to send a bigger patch series today on interrupt management for ARM. The patch will be include in this serie. You can remove the patch from your 4.5 queue for now.

Signature · 1 line
Julien Grall