xen/tools: Widen the machine_irq in xc_domain_*bind_pt_irq_int
PATCH 1/1 xen/tools: Widen the machine_irq in xc_domain_*bind_pt_irq_int
The DOMCTLs {,un}bind_pt_irq are using uint32_t for the machine_irq while the helper is using uint8_t.
Currently on ARM, we are supporting SPIs whose irq number can go up to 1019 which doesn't fit in an uint8_t. The helpers xc_domain_bind_pt_spi and xc_domain_unbint_pt_spi are correctly taking an uint16_t so the libxc was truncating without noticing the user which may end up to route the wrong IRQ.
Fix the problem by widening the machine_irq parameter in xc_domain_*bind_pt_irq_int.
Note that XEN_DOMCTL_irq_permission has the same problem but it's not used at the moment on ARM. So we can defer the changes after the release of Xen 4.7.
---
This is based on the patch "arm: irq: increase size of irq from uint8_t to uint32_t" [1] by Iurii few months ago.
The bug has been introduced by the device passthrough series pushed in Xen 2 months ago. It prevents to route any IRQ number > 256 on ARM.
The changes are minimal in order to get it fixed for Xen 4.6. There is technically change for x86 as the machine_irq field in the DOMCTL was already uint32_t. Only the parameter of the internal helper is widen.
[1] http://lists.xen.org/archives/html/xen-devel/2015-04/msg00681.html
--- tools/libxc/xc_domain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/libxc/xc_domain.c +2 -2
@@ -1880,7 +1880,7 @@ int xc_domain_unbind_msi_irq( static int xc_domain_bind_pt_irq_int( xc_interface *xch, uint32_t domid, - uint8_t machine_irq, + uint32_t machine_irq, uint8_t irq_type, uint8_t bus, uint8_t device,
@@ -1939,7 +1939,7 @@ int xc_domain_bind_pt_irq( static int xc_domain_unbind_pt_irq_int( xc_interface *xch, uint32_t domid, - uint8_t machine_irq, + uint32_t machine_irq, uint8_t irq_type, uint8_t bus, uint8_t device,
Signature · 1 line
2.1.4
Quoted 14 lines · Julien Grall
The DOMCTLs {,un}bind_pt_irq are using
uint32_tfor themachine_irqwhile the helper is usinguint8_t.Currently on ARM, we are supporting SPIs whose irq number can go up to
1019 which doesn't fit in anuint8_t. The helpersxc_domain_bind_pt_spi
andxc_domain_unbint_pt_spiare correctly taking anuint16_tso the libxc was truncating without noticing the user which may end up to route the wrong IRQ.Fix the problem by widening the
machine_irqparameter in xc_domain_*bind_pt_irq_int.
Quoted 7 lines
Note that
XEN_DOMCTL_irq_permissionhas the same problem but it's not used at the moment on ARM. So we can defer the changes after the release
of Xen 4.7.Reported-by Iurii Konovalenko <[email protected]>Signed-off-by Julien Grall <[email protected]>
I think this is a bugfix and should be applied for 4.6.
Ian.
Quoted 45 lines
---
This is based on the patch "arm: irq: increase size of irq fromuint8_t
touint32_t" [1] by Iurii few months ago.The bug has been introduced by the device passthrough series
pushed
in Xen 2 months ago. It prevents to route any IRQ number > 256 on
ARM.The changes are minimal in order to get it fixed for Xen 4.6.
There
is technically change for x86 as themachine_irqfield in the DOMCTL was alreadyuint32_t. Only the parameter of the internal helper is widen.[1]
http://lists.xen.org/archives/html/xen-devel/2015-04/msg00681.html--- tools/libxc/xc_domain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/libxc/xc_domain.c +2
-2@@ -1880,7 +1880,7 @@ int xc_domain_unbind_msi_irq( static int xc_domain_bind_pt_irq_int( xc_interface *xch, uint32_t domid, - uint8_t machine_irq, + uint32_t machine_irq, uint8_t irq_type, uint8_t bus, uint8_t device,@@ -1939,7 +1939,7 @@ int xc_domain_bind_pt_irq( static int xc_domain_unbind_pt_irq_int( xc_interface *xch, uint32_t domid, - uint8_t machine_irq, + uint32_t machine_irq, uint8_t irq_type, uint8_t bus, uint8_t device,
Quoted 22 lines · Ian Campbell
Quoted 21 lines · Julien Grall
The DOMCTLs {,un}bind_pt_irq are using
uint32_tfor themachine_irqwhile the helper is usinguint8_t.Currently on ARM, we are supporting SPIs whose irq number can go up
to
1019 which doesn't fit in anuint8_t. The helpersxc_domain_bind_pt_spi
andxc_domain_unbint_pt_spiare correctly taking anuint16_tso the libxc was truncating without noticing the user which may end up to route the wrong IRQ.Fix the problem by widening the
machine_irqparameter in xc_domain_*bind_pt_irq_int.Note that
XEN_DOMCTL_irq_permissionhas the same problem but it's not
used at the moment on ARM. So we can defer the changes after the release
of Xen 4.7.
Quoted 6 lines
Quoted 2 lines
Reported-by Iurii Konovalenko <[email protected]>Signed-off-by Julien Grall <[email protected]>Acked-by Ian Campbell <[email protected]>I think this is a bugfix and should be applied for 4.6.
Done.