[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen stable-4.20] xen/dt: Only parse direct child nodes of /reserved-memory



commit 52ecf6589d2e0096f4ccc9284c0a23595058e353
Author:     Kuan-Wei Chiu <visitorckw@xxxxxxxxx>
AuthorDate: Tue Oct 27 04:18:55 2026 +0100
Commit:     Michal Orzel <michal.orzel@xxxxxxx>
CommitDate: Thu Nov 12 11:56:45 2026 +0100

    xen/dt: Only parse direct child nodes of /reserved-memory
    
    process_reserved_memory() uses device_tree_for_each_node(), which walks
    all descendants of /reserved-memory rather than just its direct children.
    However, a child node such as nvmem-rmem can contain nvmem-layout and
    cell subnodes whose reg properties specify internal offsets rather than
    physical memory addresses. Parsing these subnodes records invalid
    reserved memory regions and fails the overlap check when bitfield cells
    share the same offset.
    
    Ignore nodes with depth != 1 in process_reserved_memory_node().
    
    Fixes: d96594eef39a ("xen/arm: keep track of reserved-memory regions")
    Signed-off-by: Kuan-Wei Chiu <visitorckw@xxxxxxxxx>
    Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>
    [michal: adjust for a different file]
    Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
    (cherry picked from commit b11a4e5bdaeebcd4029b54c19d6aaf80dd4e0fca)
---
 xen/common/device-tree/bootfdt.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/xen/common/device-tree/bootfdt.c b/xen/common/device-tree/bootfdt.c
index 70d79cfc06..c551be701f 100644
--- a/xen/common/device-tree/bootfdt.c
+++ b/xen/common/device-tree/bootfdt.c
@@ -295,8 +295,14 @@ static int __init process_reserved_memory_node(const void 
*fdt, int node,
                                                u32 size_cells,
                                                void *data)
 {
-    int rc = process_memory_node(fdt, node, name, depth, address_cells,
-                                 size_cells, data);
+    int rc;
+
+    /* Only direct children of /reserved-memory describe memory regions */
+    if ( depth != 1 )
+        return 0;
+
+    rc = process_memory_node(fdt, node, name, depth, address_cells,
+                             size_cells, data);
 
     if ( rc == -ENOSPC )
         panic("Max number of supported reserved-memory regions reached.\n");
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.20



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.