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

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


  • To: Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • Date: Wed, 1 Apr 2026 08:41:37 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=epam.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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=s4UkN+7fTYVnKhgG0cXQ4SEnlwNdVk3op25ukMyHf0A=; b=VYf2eO8+h6jdjiAU0hTTcQEti5gMNN1gxg8mfO/2GBfGrqG8W8lFu6q8IoQtpUOlYHR6wLZP8vYLjNd0KwE4QvW9bucvjAXJ1eeecPMDXkrGqg5sWAWZJq4qIEDwP77APx4K8IGJtoL0j4E5rtl43ULv7+LM3mcTXrSy/8sYakqa/xML2CvTtqo0Rz8rIzW3mDWcDfH0Gez2kbN/kJh5YHpMu7WXfNYyDBBn1xeJBBWRVUxclB9s3A9/CsLJQNGpvtEmtATHVhyCMEa9Y69Y/gDiEviYFHC8+etkqvYvNfeuWQh2q3A192EpiOVQsjjUNbUwKp9lmIzW0eohCzc2/w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o6us/gOvgPv94gROrBjlXupBHM+qtmB3Tirfg0ZTe6ptsLJgy9jyEo8h37MgPe1M9sueMcc21v6N7Rx3Szj156TCkcjS5epmGnTpA3jriTi11c+eIa+7cd2s9wfBPVVrMeHBOR45t5bhQPx8tBDN1Iuzk5WIaMRwFWzYbfM0nKxY+fJw9BokcpNAZDErnjCDfkbJRcCmo/rtHJsQ5aU0lvo511EUbZNNRSJSIWDngebblO9BZbDdREbI646IeBV8IiyNjgecY6jkSipTOnZPHFJMB2CafETOLIB6W/hmiVTQKIadLcV9Mvvb2PvZ2O4xMmGkm/9DW5jIL+Z83WrWPQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Wed, 01 Apr 2026 06:42:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 31/03/2026 17:43, Oleksandr Tyshchenko wrote:
> 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) +                    \
NIT: alignment. I'll fix on commit

Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>

~Michal




 


Rackspace

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