xen/common/device-tree/bootinfo-fdt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
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@gmail.com>
---
xen/common/device-tree/bootinfo-fdt.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/xen/common/device-tree/bootinfo-fdt.c b/xen/common/device-tree/bootinfo-fdt.c
index ca64daf4cd..eea35325f7 100644
--- a/xen/common/device-tree/bootinfo-fdt.c
+++ b/xen/common/device-tree/bootinfo-fdt.c
@@ -185,8 +185,13 @@ 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;
+
+ 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");
--
2.56.0.307.g5fe7bd680c-goog
On 27-Oct-26 04:18, Kuan-Wei Chiu wrote:
> 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@gmail.com>
> ---
> xen/common/device-tree/bootinfo-fdt.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/xen/common/device-tree/bootinfo-fdt.c b/xen/common/device-tree/bootinfo-fdt.c
> index ca64daf4cd..eea35325f7 100644
> --- a/xen/common/device-tree/bootinfo-fdt.c
> +++ b/xen/common/device-tree/bootinfo-fdt.c
> @@ -185,8 +185,13 @@ 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;
> +
It would be easier to understand with the comment like:
/* 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");
I will change on commit. Thanks for the submission.
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
~Michal
© 2016 - 2026 Red Hat, Inc.