[PATCH] xen/dt: reject "xen,static-mem" when CONFIG_STATIC_MEMORY is disabled

Michal Orzel posted 1 patch 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20260805121124.150017-1-michal.orzel@amd.com
xen/common/device-tree/bootinfo-fdt.c | 6 ++++++
1 file changed, 6 insertions(+)
[PATCH] xen/dt: reject "xen,static-mem" when CONFIG_STATIC_MEMORY is disabled
Posted by Michal Orzel 1 week ago
process_domain_node() parses "xen,static-mem" regardless of
CONFIG_STATIC_MEMORY. With the feature off, init_staticmem_pages() is a
no-op stub, so boot carries on until construct_domU() reaches the
ASSERT_UNREACHABLE() stubs of allocate_static_memory() /
assign_static_memory_11(): a debug build trips the assertion, a production
build gives the domain no memory at all.

Bail out at parse time instead, like process_shm_node() already does for
CONFIG_STATIC_SHM.

Fixes: 41c031ff437b ("xen/arm: introduce domain on Static Allocation")
Signed-off-by: Michal Orzel <michal.orzel@amd.com>
---
 xen/common/device-tree/bootinfo-fdt.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/xen/common/device-tree/bootinfo-fdt.c b/xen/common/device-tree/bootinfo-fdt.c
index 272b5a6c0ae6..ca64daf4cdc8 100644
--- a/xen/common/device-tree/bootinfo-fdt.c
+++ b/xen/common/device-tree/bootinfo-fdt.c
@@ -349,6 +349,12 @@ static int __init process_domain_node(const void *fdt, int node,
         /* No "xen,static-mem" present. */
         return 0;
 
+    if ( !IS_ENABLED(CONFIG_STATIC_MEMORY) )
+    {
+        printk("CONFIG_STATIC_MEMORY must be enabled for parsing xen,static-mem\n");
+        return -EINVAL;
+    }
+
     return device_tree_get_meminfo(fdt, node, "xen,static-mem", address_cells,
                                    size_cells, bootinfo_get_reserved_mem(),
                                    MEMBANK_STATIC_DOMAIN);
-- 
2.43.0
Re: [PATCH] xen/dt: reject "xen,static-mem" when CONFIG_STATIC_MEMORY is disabled
Posted by Bertrand Marquis 1 week ago
Hi Michal,

> On 5 Aug 2026, at 14:11, Michal Orzel <michal.orzel@amd.com> wrote:
> 
> process_domain_node() parses "xen,static-mem" regardless of
> CONFIG_STATIC_MEMORY. With the feature off, init_staticmem_pages() is a
> no-op stub, so boot carries on until construct_domU() reaches the
> ASSERT_UNREACHABLE() stubs of allocate_static_memory() /
> assign_static_memory_11(): a debug build trips the assertion, a production
> build gives the domain no memory at all.
> 
> Bail out at parse time instead, like process_shm_node() already does for
> CONFIG_STATIC_SHM.
> 
> Fixes: 41c031ff437b ("xen/arm: introduce domain on Static Allocation")
> Signed-off-by: Michal Orzel <michal.orzel@amd.com>

Acked-by: Bertrand Marquis <bertrand.marquis@arm.com>

Cheers
Bertrand

> ---
> xen/common/device-tree/bootinfo-fdt.c | 6 ++++++
> 1 file changed, 6 insertions(+)
> 
> diff --git a/xen/common/device-tree/bootinfo-fdt.c b/xen/common/device-tree/bootinfo-fdt.c
> index 272b5a6c0ae6..ca64daf4cdc8 100644
> --- a/xen/common/device-tree/bootinfo-fdt.c
> +++ b/xen/common/device-tree/bootinfo-fdt.c
> @@ -349,6 +349,12 @@ static int __init process_domain_node(const void *fdt, int node,
>         /* No "xen,static-mem" present. */
>         return 0;
> 
> +    if ( !IS_ENABLED(CONFIG_STATIC_MEMORY) )
> +    {
> +        printk("CONFIG_STATIC_MEMORY must be enabled for parsing xen,static-mem\n");
> +        return -EINVAL;
> +    }
> +
>     return device_tree_get_meminfo(fdt, node, "xen,static-mem", address_cells,
>                                    size_cells, bootinfo_get_reserved_mem(),
>                                    MEMBANK_STATIC_DOMAIN);
> -- 
> 2.43.0
>