Skip to contentSkip to conversation

xen/arm: Check return code from recursive calls to scan_pfdt_node()

PATCH In review Michal Orzel 4 participants 4 messages Oct 16, 2023 – Oct 17, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: Check return code from recursive calls to scan_pfdt_node()

At the moment, we do not check a return code from scan_pfdt_node() called recursively. This means that any issue that may occur while parsing and copying the passthrough nodes is hidden and Xen continues to boot a domain despite errors. This may lead to incorrect device tree generation and various guest issues (e.g. trap on attempt to access MMIO not mapped in P2M). Fix it.

Fixes 669ecdf8d6cd ("xen/arm: copy dtb fragment to guest dtb")

---
@Henry:
This is a bug fix, so I think we should have it in 4.18 given the possible consequences I described in the commit msg. I don't see any risks as this change only checks the return code for an error.

---
 xen/arch/arm/domain_build.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
xen/arch/arm/domain_build.c +5 -2
index 24c9019cc43c..49792dd590ee 100644
@@ -2872,8 +2872,11 @@ static int __init scan_pfdt_node(struct kernel_info *kinfo, const void *pfdt,
     node_next = fdt_first_subnode(pfdt, nodeoff);
     while ( node_next > 0 )
     {
-        scan_pfdt_node(kinfo, pfdt, node_next, address_cells, size_cells,
-                       scan_passthrough_prop);
+        rc = scan_pfdt_node(kinfo, pfdt, node_next, address_cells, size_cells,
+                            scan_passthrough_prop);
+        if ( rc )
+            return rc;
+
         node_next = fdt_next_subnode(pfdt, node_next);
     }
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Michal Orzel

At the moment, we do not check a return code from scan_pfdt_node() called recursively. This means that any issue that may occur while parsing and copying the passthrough nodes is hidden and Xen continues to boot a domain despite errors. This may lead to incorrect device tree generation and various guest issues (e.g. trap on attempt to access MMIO not mapped in P2M). Fix it.

Quoted 2 lines
Fixes 669ecdf8d6cd ("xen/arm: copy dtb fragment to guest dtb")

Hi Michal,

Yes makes sense!

Quoted 31 lines

---
@Henry:
This is a bug fix, so I think we should have it in 4.18 given the possible consequences I described in the commit msg. I don't see any risks as this change only checks the return code for an error.
---
xen/arch/arm/domain_build.c | 7 +++++--

1 file changed, 5 insertions(+), 2 deletions(-)
xen/arch/arm/domain_build.c +5 -2
index 24c9019cc43c..49792dd590ee 100644
@@ -2872,8 +2872,11 @@ static int __init scan_pfdt_node(struct kernel_info *kinfo, const void *pfdt,
    node_next = fdt_first_subnode(pfdt, nodeoff);
    while ( node_next > 0 )
    {
-        scan_pfdt_node(kinfo, pfdt, node_next, address_cells, size_cells,
-                       scan_passthrough_prop);
+        rc = scan_pfdt_node(kinfo, pfdt, node_next, address_cells, size_cells,
+                            scan_passthrough_prop);
+        if ( rc )
+            return rc;
+
        node_next = fdt_next_subnode(pfdt, node_next);
    }
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#2 lore raw
In reply to Michal Orzel

Hi Michal,

Quoted 11 lines · Michal Orzel

At the moment, we do not check a return code from scan_pfdt_node() called recursively. This means that any issue that may occur while parsing and copying the passthrough nodes is hidden and Xen continues to boot a domain despite errors. This may lead to incorrect device tree generation and various guest issues (e.g. trap on attempt to access MMIO not mapped in P2M). Fix it.

Fixes 669ecdf8d6cd ("xen/arm: copy dtb fragment to guest dtb")

Good finding :-)

Cheers
Bertrand

Quoted 30 lines

---
@Henry:
This is a bug fix, so I think we should have it in 4.18 given the possible consequences I described in the commit msg. I don't see any risks as this change only checks the return code for an error.
---
xen/arch/arm/domain_build.c | 7 +++++--

1 file changed, 5 insertions(+), 2 deletions(-)
xen/arch/arm/domain_build.c +5 -2
index 24c9019cc43c..49792dd590ee 100644
@@ -2872,8 +2872,11 @@ static int __init scan_pfdt_node(struct kernel_info *kinfo, const void *pfdt,
    node_next = fdt_first_subnode(pfdt, nodeoff);
    while ( node_next > 0 )
    {
-        scan_pfdt_node(kinfo, pfdt, node_next, address_cells, size_cells,
-                       scan_passthrough_prop);
+        rc = scan_pfdt_node(kinfo, pfdt, node_next, address_cells, size_cells,
+                            scan_passthrough_prop);
+        if ( rc )
+            return rc;
+
        node_next = fdt_next_subnode(pfdt, node_next);
    }
 
Signature · 1 line
2.25.1
#3 lore raw

Hi Michal,

Quoted 13 lines · Bertrand Marquis

Hi Michal,

Quoted 9 lines · Michal Orzel

At the moment, we do not check a return code from scan_pfdt_node() called recursively. This means that any issue that may occur while parsing and copying the passthrough nodes is hidden and Xen continues to boot a domain despite errors. This may lead to incorrect device tree generation and various guest issues (e.g. trap on attempt to access MMIO not mapped in P2M). Fix it.

Quoted 6 lines
Quoted 2 lines
Fixes 669ecdf8d6cd ("xen/arm: copy dtb fragment to guest dtb")

Good finding :-)

Kind regards,
Henry

Quoted 35 lines

Cheers
Bertrand

Quoted 30 lines

---
@Henry:
This is a bug fix, so I think we should have it in 4.18 given the possible consequences I described in the commit msg. I don't see any risks as this change only checks the return code for an error.
---
xen/arch/arm/domain_build.c | 7 +++++--

1 file changed, 5 insertions(+), 2 deletions(-)
xen/arch/arm/domain_build.c +5 -3
index 24c9019cc43c..49792dd590ee 100644
@@ -2872,8 +2872,11 @@ static int __init scan_pfdt_node(struct kernel_info *kinfo, const void *pfdt,
   node_next = fdt_first_subnode(pfdt, nodeoff);
   while ( node_next > 0 )
   {
-        scan_pfdt_node(kinfo, pfdt, node_next, address_cells, size_cells,
-                       scan_passthrough_prop);
+        rc = scan_pfdt_node(kinfo, pfdt, node_next, address_cells, size_cells,
+                            scan_passthrough_prop);
+        if ( rc )
+            return rc;
+
       node_next = fdt_next_subnode(pfdt, node_next);
   }
 
--

2.25.1