Skip to contentSkip to conversation

xen/arm: dom0less: cope with missing /gic phandle

PATCH In review Stewart Hildebrand 3 participants 3 messages Oct 11, 2024 – Oct 17, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: dom0less: cope with missing /gic phandle

If a partial DT has a /gic node, but no references to it, dtc may omit the phandle property. With the phandle property missing, fdt_get_phandle() returns 0, leading Xen to generate a malformed domU dtb due to invalid interrupt-parent phandle references. 0 is an invalid phandle value. Add a zero check, and fall back to GUEST_PHANDLE_GIC.

---
 xen/arch/arm/dom0less-build.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
xen/arch/arm/dom0less-build.c +4 -1
index 09b65e44aed3..f328a044e9d3 100644
@@ -554,7 +554,10 @@ static int __init domain_handle_dtb_bootmodule(struct domain *d,
          */
         if ( dt_node_cmp(name, "gic") == 0 )
         {
-            kinfo->phandle_gic = fdt_get_phandle(pfdt, node_next);
+            uint32_t phandle_gic = fdt_get_phandle(pfdt, node_next);
+
+            if ( phandle_gic != 0 )
+                kinfo->phandle_gic = phandle_gic;
             continue;
         }
 

base-commit: 76a54badf890f56ff72644593c0fbc72138e13aa

Signature · 1 line
2.47.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Stewart Hildebrand

If a partial DT has a /gic node, but no references to it, dtc may omit the phandle property. With the phandle property missing, fdt_get_phandle() returns 0, leading Xen to generate a malformed domU dtb due to invalid interrupt-parent phandle references. 0 is an invalid phandle value. Add a zero check, and fall back to GUEST_PHANDLE_GIC.

Quoted 25 lines
---
 xen/arch/arm/dom0less-build.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
xen/arch/arm/dom0less-build.c +4 -1
index 09b65e44aed3..f328a044e9d3 100644
@@ -554,7 +554,10 @@ static int __init domain_handle_dtb_bootmodule(struct domain *d,
          */
         if ( dt_node_cmp(name, "gic") == 0 )
         {
-            kinfo->phandle_gic = fdt_get_phandle(pfdt, node_next);
+            uint32_t phandle_gic = fdt_get_phandle(pfdt, node_next);
+
+            if ( phandle_gic != 0 )
+                kinfo->phandle_gic = phandle_gic;
             continue;
         }
 

base-commit: 76a54badf890f56ff72644593c0fbc72138e13aa

Signature · 1 line
2.47.0
#2 lore raw

Hi,

Quoted 10 lines · Stefano Stabellini
Quoted 7 lines · Stewart Hildebrand

If a partial DT has a /gic node, but no references to it, dtc may omit the phandle property. With the phandle property missing, fdt_get_phandle() returns 0, leading Xen to generate a malformed domU dtb due to invalid interrupt-parent phandle references. 0 is an invalid phandle value. Add a zero check, and fall back to GUEST_PHANDLE_GIC.

This is now committed.

Cheers,

Signature · 1 line
Julien Grall