Skip to contentSkip to conversation

IRQ: u16 is too narrow for an event channel number

PATCH In review Jan Beulich 3 participants 5 messages Jan 14, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IRQ: u16 is too narrow for an event channel number

FIFO event channels allow ports up to 2^17, so we need to use a wider field in struct pirq. Move "masked" such that it may share the 8-byte slot with struct arch_pirq on 64-bit arches, rather than leaving a 7-byte hole in all cases.

Take the opportunity and also add a comment regarding "arch" placement within the structure.

xen/include/xen/irq.h +3 -2
@@ -127,9 +127,10 @@ struct vcpu;
 
 struct pirq {
     int pirq;
-    u16 evtchn;
-    bool_t masked;
+    evtchn_port_t evtchn;
     struct rcu_head rcu_head;
+    bool masked;
+    /* Architectures may require this field to be last. */
     struct arch_pirq arch;
 };
 

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

#1 lore raw

Hi Jan,

Quoted 13 lines · Jan Beulich

FIFO event channels allow ports up to 2^17, so we need to use a wider field in struct pirq. Move "masked" such that it may share the 8-byte slot with struct arch_pirq on 64-bit arches, rather than leaving a 7-byte hole in all cases.

Take the opportunity and also add a comment regarding "arch" placement within the structure.

xen/include/xen/irq.h struct vcpu; · line 133

Quoted 9 lines
xen/include/xen/irq.h +3 -2
@@ -127,9 +127,10 @@ struct vcpu;
 
  struct pirq {
      int pirq;
-    u16 evtchn;
-    bool_t masked;
+    evtchn_port_t evtchn;
      struct rcu_head rcu_head;
+    bool masked;
+    /* Architectures may require this field to be last. */

I orginally planned to add a comment in struct pirq, but I am not in favor to continue to encourage quirkiness in the code. I sent a series (see [1]) that drop this requirements from x86 and therefore remove the need of this comment.

xen/include/xen/irq.h struct vcpu; · line 136

Quoted 4 lines
xen/include/xen/irq.h +0 -0
      struct arch_pirq arch;
  };
 

Cheers,

[1] https://lists.xenproject.org/archives/html/xen-devel/2020-01/msg00924.html

Signature · 6 lines
Julien Grall

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

Hi Jan,

Quoted 14 lines · Jan Beulich

FIFO event channels allow ports up to 2^17, so we need to use a wider field in struct pirq. Move "masked" such that it may share the 8-byte slot with struct arch_pirq on 64-bit arches, rather than leaving a 7-byte hole in all cases.

Take the opportunity and also add a comment regarding "arch" placement within the structure.

xen/include/xen/irq.h +0 -0
@@ -127,9 +127,10 @@ struct vcpu;
 
Quoted 13 lines

xen/include/xen/irq.h struct vcpu; · line 133

Quoted 8 lines
xen/include/xen/irq.h +3 -2
  struct pirq {
      int pirq;
-    u16 evtchn;
-    bool_t masked;
+    evtchn_port_t evtchn;
      struct rcu_head rcu_head;
+    bool masked;
+    /* Architectures may require this field to be last. */

I orginally planned to add a comment in struct pirq, but I am not in favor to continue to encourage quirkiness in the code. I sent a series (see [1]) that drop this requirements from x86 and therefore remove the need of this comment.

Well, I've found the issue fixed here while doing a first review pass over said patch of yours (I'm yet to make up my mind whether I have reservations, hence I didn't reply yet). The change here will want backporting, so it'll be easier in any event to rebase your patch over this one. This rebasing can then include dropping the comment again.

Jan

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

#3 lore raw

Hi Jan,

Quoted 32 lines · Jan Beulich
Quoted 17 lines · Julien Grall

Hi Jan,

Quoted 14 lines · Jan Beulich

FIFO event channels allow ports up to 2^17, so we need to use a wider field in struct pirq. Move "masked" such that it may share the 8-byte slot with struct arch_pirq on 64-bit arches, rather than leaving a 7-byte hole in all cases.

Take the opportunity and also add a comment regarding "arch" placement within the structure.

xen/include/xen/irq.h +0 -0
@@ -127,9 +127,10 @@ struct vcpu;
 
Quoted 13 lines

xen/include/xen/irq.h struct vcpu; · line 133

Quoted 8 lines
xen/include/xen/irq.h +3 -2
   struct pirq {
       int pirq;
-    u16 evtchn;
-    bool_t masked;
+    evtchn_port_t evtchn;
       struct rcu_head rcu_head;
+    bool masked;
+    /* Architectures may require this field to be last. */

I orginally planned to add a comment in struct pirq, but I am not in favor to continue to encourage quirkiness in the code. I sent a series (see [1]) that drop this requirements from x86 and therefore remove the need of this comment.

Quoted 5 lines

Well, I've found the issue fixed here while doing a first review pass over said patch of yours (I'm yet to make up my mind whether I have reservations, hence I didn't reply yet). The change here will want backporting, so it'll be easier in any event to rebase your patch over this one. This rebasing can then include dropping the comment again.

Fair enough.

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v1 1/1
#4 lore raw
In reply to Jan Beulich
Quoted 9 lines · Jan Beulich

FIFO event channels allow ports up to 2^17, so we need to use a wider field in struct pirq. Move "masked" such that it may share the 8-byte slot with struct arch_pirq on 64-bit arches, rather than leaving a 7-byte hole in all cases.

Take the opportunity and also add a comment regarding "arch" placement within the structure.

Oops.  In fairness, it was entirely reasonable of the FIFO work to presume that all code already used evtchn_port_t for evtchn ports.

Quoted 6 lines
xen/include/xen/irq.h +0 -0
@@ -127,9 +127,10 @@ struct vcpu;
 
 struct pirq {

xen/include/xen/irq.h struct vcpu; · line 136

Quoted 10 lines
xen/include/xen/irq.h +3 -2
     int pirq;
-    u16 evtchn;
-    bool_t masked;
+    evtchn_port_t evtchn;
     struct rcu_head rcu_head;
+    bool masked;
+    /* Architectures may require this field to be last. */
     struct arch_pirq arch;
 };
 

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