[PATCH] xen/arm: dom0less: cope with missing /gic phandle

Stewart Hildebrand posted 1 patch 1 month, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20241011211957.447290-1-stewart.hildebrand@amd.com
xen/arch/arm/dom0less-build.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
[PATCH] xen/arm: dom0less: cope with missing /gic phandle
Posted by Stewart Hildebrand 1 month, 1 week ago
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.

Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
---
 xen/arch/arm/dom0less-build.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c
index 09b65e44aed3..f328a044e9d3 100644
--- a/xen/arch/arm/dom0less-build.c
+++ b/xen/arch/arm/dom0less-build.c
@@ -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
-- 
2.47.0
Re: [PATCH] xen/arm: dom0less: cope with missing /gic phandle
Posted by Stefano Stabellini 1 month, 1 week ago
On Fri, 11 Oct 2024, Stewart Hildebrand wrote:
> 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.
> 
> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
>  xen/arch/arm/dom0less-build.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c
> index 09b65e44aed3..f328a044e9d3 100644
> --- a/xen/arch/arm/dom0less-build.c
> +++ b/xen/arch/arm/dom0less-build.c
> @@ -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
> -- 
> 2.47.0
>
Re: [PATCH] xen/arm: dom0less: cope with missing /gic phandle
Posted by Julien Grall 1 month ago
Hi,

On 11/10/2024 22:28, Stefano Stabellini wrote:
> On Fri, 11 Oct 2024, Stewart Hildebrand wrote:
>> 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.
>>
>> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
> 
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

This is now committed.

Cheers,

-- 
Julien Grall