xen/arm: Preserve host GIC #interrupt-cells for Dom0
PATCH v2 1/1 xen/arm: Preserve host GIC #interrupt-cells for Dom0
Xen copies device interrupt properties from the host device tree to Dom0, but hardcodes #interrupt-cells to 3 in make_gic_node() and fdt_property_interrupts(). On GICv3 platforms where the host uses 4 cells, Dom0 parses the copied specifiers as 3 cells each and fails to set up device interrupts.
Propagate #interrupt-cells from the host GIC node in make_gic_node() and pad Dom0 interrupt specifiers with trailing zero cells in fdt_property_interrupts().
---
Changes in v2:
- Add a comment in fdt_property_interrupts() explaining why only the hardware domain preserves the host GIC's #interrupt-cells and that extra cells beyond 3 are zero-padded.
xen/arch/arm/domain_build.c | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-)
xen/arch/arm/domain_build.c +34 -3
@@ -654,12 +654,37 @@ static int __init fdt_property_interrupts(const struct kernel_info *kinfo, unsigned int num_irq) {int res; +uint32_t intrcells =ARRAY_SIZE (intr[0 ]); +void *val; +unsigned int i, stride; - res =fdt_property (kinfo->fdt,"interrupts" , - intr,sizeof (intr[0 ]) * num_irq); +/* +* Only the hardware domain preserves the host GIC's #interrupt-cells, +* since its device interrupt properties are copied from the host DT; +* domUs always use a 3-cell virtual GIC. Any extra cells beyond the +* 3-cell specifier, such as the GICv3 PPI affinity partition, are +* zero-padded. +*/ +if (is_hardware_domain (kinfo->bd.d) ) + { +const struct dt_device_node *gic = dt_interrupt_controller; + +if ( !dt_property_read_u32 (gic,"#interrupt-cells" , &intrcells) ) +return -FDT_ERR_XEN (ENOENT ); +if ( intrcells <ARRAY_SIZE (intr[0 ]) ) +return -FDT_ERR_XEN (ERANGE ); + } + + stride = intrcells *sizeof (intr[0 ][0 ]); + res =fdt_property_placeholder (kinfo->fdt,"interrupts" , + stride * num_irq, &val);if ( res )return res; +memset (val,0 , stride * num_irq); +for ( i =0 ; i < num_irq; i++ ) +memcpy ((uint8_t *)val + i * stride, intr[i],sizeof (intr[0 ])); + res =fdt_property_cell (kinfo->fdt,"interrupt-parent" , kinfo->phandle_intc);
@@ -1320,6 +1345,7 @@ static int __init make_gic_node(const struct domain *d, void *fdt,int res =0 ;const void *addrcells, *sizecells;u32 addrcells_len, sizecells_len; +uint32_t intrcells;const char *name;/*
@@ -1370,7 +1396,12 @@ static int __init make_gic_node(const struct domain *d, void *fdt,return res; } - res =fdt_property_cell (fdt,"#interrupt-cells" ,3 ); +if ( !dt_property_read_u32 (gic,"#interrupt-cells" , &intrcells) ) +return -FDT_ERR_XEN (ENOENT ); +if ( intrcells <3 ) +return -FDT_ERR_XEN (ERANGE ); + + res =fdt_property_cell (fdt,"#interrupt-cells" , intrcells);if ( res )return res;
Signature · 1 line
2.56.1.703.gf848ed807c-goog
Quoted 38 lines · Kuan-Wei Chiu
Xen copies device interrupt properties from the host device tree to Dom0, but hardcodes #interrupt-cells to 3 in
make_gic_node()andfdt_property_interrupts(). On GICv3 platforms where the host uses 4 cells, Dom0 parses the copied specifiers as 3 cells each and fails to set up device interrupts.Propagate #interrupt-cells from the host GIC node in
make_gic_node()and pad Dom0 interrupt specifiers with trailing zero cells infdt_property_interrupts().Signed-off-by Kuan-Wei Chiu <[email protected]>Reviewed-by Michal Orzel <[email protected]>---
Changes in v2:
- Add a comment infdt_property_interrupts()explaining why only the hardware domain preserves the host GIC's #interrupt-cells and that extra cells beyond 3 are zero-padded.xen/arch/arm/domain_build.c | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-)xen/arch/arm/domain_build.c +6
-2@@ -654,12 +654,37 @@ static int __init fdt_property_interrupts(const struct kernel_info *kinfo, unsigned int num_irq) {int res; +uint32_t intrcells =ARRAY_SIZE (intr[0 ]); +void *val; +unsigned int i, stride; - res =fdt_property (kinfo->fdt,"interrupts" , - intr,sizeof (intr[0 ]) * num_irq); +/* +* Only the hardware domain preserves the host GIC's #interrupt-cells, +* since its device interrupt properties are copied from the host DT;
xen/arch/arm/domain_build.c static int __init fdt_property_interrupts(const struct kernel_info *kinfo, · line 673
Quoted 10 lines
xen/arch/arm/domain_build.c +10
-0+* domUs always use a 3-cell virtual GIC. Any extra cells beyond the +* 3-cell specifier, such as the GICv3 PPI affinity partition, are +* zero-padded. +*/ +if (is_hardware_domain (kinfo->bd.d) ) + { +const struct dt_device_node *gic = dt_interrupt_controller; + +if ( !dt_property_read_u32 (gic,"#interrupt-cells" , &intrcells) ) +return -FDT_ERR_XEN (ENOENT );
Blank line here.
xen/arch/arm/domain_build.c static int __init fdt_property_interrupts(const struct kernel_info *kinfo, · line 684
Quoted 11 lines
xen/arch/arm/domain_build.c +8
-0+if ( intrcells <ARRAY_SIZE (intr[0 ]) ) +return -FDT_ERR_XEN (ERANGE ); + } + + stride = intrcells *sizeof (intr[0 ][0 ]); + res =fdt_property_placeholder (kinfo->fdt,"interrupts" , + stride * num_irq, &val);if ( res )return res; +memset (val,0 , stride * num_irq);
Blank line here.
Quoted 15 lines
xen/arch/arm/domain_build.c +4
-0+for ( i =0 ; i < num_irq; i++ ) +memcpy ((uint8_t *)val + i * stride, intr[i],sizeof (intr[0 ])); + res =fdt_property_cell (kinfo->fdt,"interrupt-parent" , kinfo->phandle_intc);@@ -1320,6 +1345,7 @@ static int __init make_gic_node(const struct domain *d, void *fdt,int res =0 ;const void *addrcells, *sizecells;u32 addrcells_len, sizecells_len; +uint32_t intrcells;const char *name;/*
xen/arch/arm/domain_build.c static int __init make_gic_node(const struct domain *d, void *fdt, · line 1400
Quoted 6 lines
xen/arch/arm/domain_build.c +2
-1@@ -1370,7 +1396,12 @@ static int __init make_gic_node(const struct domain *d, void *fdt,return res; } - res =fdt_property_cell (fdt,"#interrupt-cells" ,3 ); +if ( !dt_property_read_u32 (gic,"#interrupt-cells" , &intrcells) ) +return -FDT_ERR_XEN (ENOENT );
Blank line here.
With that my tag stands. Can be fixed on commit.
~Michal