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

[PATCH V2] xen/arm: Increase DOM0_FDT_EXTRA_SIZE to support max reserved memory banks


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>
  • Date: Tue, 31 Mar 2026 15:43:10 +0000
  • Accept-language: en-US, ru-RU
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KhGP5Po/5+j289yQqaXcApoqaMGwV/q/N5BbRPfqwrY=; b=tX2XTPo1c3cWHJr+thd0q3girU6U2hlh7MeGi3cPMGXjHhAIam528I5+t2S5raXPGmwij7ZOaj0cSn8hvzRDpVnOZibNslGvu/FxelA9iiikSUtNzIXZtbu3ADggzJUt0i76p89GevJ9VGSb8tByi3TSDT5R8nB4sfyVS44IuAGhlC4UytCZO/nRgvq59BT2t1c/VjUSej3l4q6nMKyM3yH/RwiBleKYDuhd4xcIOTISDlShApM3/h1xfHqrGkddeOjCByCNH8uJ6Ni6tOPCXqNwM/0V9oAU5WjHDTaEbjNtLRQqElTD3rvruWe93+dvyoT7fwQ9+zKTLulxeI1sGA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eyVvV+O6BxRgJ0wAmIONJH2Y/t3okqrDee3NFyMHRGaQPICdNCzLdmaPrf7fmsPkIlsTWGDkvgz7EIOAFf/gwk63XNVO+8+W8wJKklc7ZAmCunRmWO0jLZw+PWdUBMeUBshhvctVB8Lfhk7Y55iovI3NVdO3X8D0gtaA/PB8XphpcdQrEKDlmZqlWWRCQfgED0w4F3iIlvgOhR8aAKbGJWOJGVGkblavDpP9Fj+bO5RvgifFeLf4fgMlxgCfITzlFi3aBZW46VGpck7Qg78BhE2qgALQs0ZvlBfPjDe33W654XCXOIKPyyjDoUsY28s4NfV6fsCaXmrOOfx6Qy4gkw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 31 Mar 2026 15:43:24 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcwSUT7254zXLHwUG/lf9z0n/ajQ==
  • Thread-topic: [PATCH V2] xen/arm: Increase DOM0_FDT_EXTRA_SIZE to support max reserved memory banks

From: Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>

Xen fails to construct the hardware domain's device tree with
FDT_ERR_NOSPACE (-3) when the host memory map is highly fragmented
(e.g., numerous reserved memory regions) and the host DTB represents
RAM compactly (e.g., a single reg pair or just a few).

This occurs because DOM0_FDT_EXTRA_SIZE underestimates the space
required for an extra /memory node. While the host DTB might
represent RAM compactly, make_memory_node() aggregates all
reserved regions into a single reg property. With NR_MEM_BANKS (256)
and 64-bit address/size cells, this property can grow up to
4KB (256 * 16), easily exceeding the space originally occupied by
the host DTB's nodes plus the current padding, thereby overflowing
the allocated buffer.

Additionally, the SHM regions require space for discrete sub-nodes
under /reserved-memory node, as well as an appendage to the
main /memory node. Each of the up to NR_SHMEM_BANKS (32) regions
triggers the creation of a sub-node with properties (compatible,
reg, xen,id, and xen,offset). These runtime-generated sub-nodes
require approximately 142 bytes each, while the appendage consumes
an additional 16 bytes per region.

Fix this by increasing DOM0_FDT_EXTRA_SIZE to account for fragmented
reg properties (NR_MEM_BANKS * 16), the discrete SHM sub-nodes, and
the SHM appendage to the /memory node (NR_SHMEM_BANKS * (160 + 16)).
The SHM overhead is conditionally evaluated to avoid over-allocating
memory when CONFIG_STATIC_SHM=n.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
---
  V2:
   - update commit description
   - update in-code comment
   - update macro
---
---
 xen/arch/arm/domain_build.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 3cd251beed..07f331eac8 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -98,11 +98,21 @@ int __init parse_arch_dom0_param(const char *s, const char 
*e)
 #endif
 
 /*
- * Amount of extra space required to dom0's device tree.  No new nodes
- * are added (yet) but one terminating reserve map entry (16 bytes) is
- * added.
+ * Amount of extra space required to dom0's device tree. This covers
+ * nodes generated by Xen, which are not directly copied from the host DTB.
+ * It is calculated as:
+ *  - Space for /hypervisor node (128 bytes).
+ *  - The reserve map terminator (16 bytes).
+ *  - Space for a generated /memory node covering all possible reserved
+ *    memory regions (NR_MEM_BANKS * 16).
+ *  - Space for a generated /reserved-memory node with discrete SHM sub-nodes,
+ *    plus the appendage to the main /memory node (NR_SHMEM_BANKS * (160 + 16)
+ *    bytes). This overhead is dropped when CONFIG_STATIC_SHM is disabled.
  */
-#define DOM0_FDT_EXTRA_SIZE (128 + sizeof(struct fdt_reserve_entry))
+#define DOM0_FDT_EXTRA_SIZE (128 + sizeof(struct fdt_reserve_entry) + \
+                             (NR_MEM_BANKS * 16) +                    \
+                             (IS_ENABLED(CONFIG_STATIC_SHM) ?         \
+                              (NR_SHMEM_BANKS * (160 + 16)) : 0))
 
 unsigned int __init dom0_max_vcpus(void)
 {
-- 
2.34.1



 


Rackspace

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