[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:44:13 +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=4MuEpbxuwR2u1gjamX8XTr2+INk4ugZ4MvjwJIDYpG0=; b=jfLl1LTtmL1r/z976SH6yloobFJr5ed6XO9K4WECb/DrXrP5Pd/OX0hqCeEJoZZ7uZwq+ybkuim/RrBmJtD/SR+Gpa/3DcWo+5RMadP4bRNlh5fkuR++68jW92D8iWW+Oajwozklw6GbuV87mH61XXkdjE2t98B/LNnGX4ngKVhRsPv//TAArRXr9ILwUcIqwTQRCmIwQ2X9aTxqZiqHlEzaWJWbdvoVdl5oKIKCp5XdvyMcGN7FkE+gknDevX8CF4HlrKosQc4DOcNgOrjTkI7ZB5CIz4d9zyEWaoQlV97tNo/xJB/QFBwae6GtIzqc/KOE7PrdKeFgqoWmF1jCag==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q0YPOWUSnG5rvvhGd33hvMqUcMaMYsmUtrGJdsdFIHsjN8NWlzUrpd+18LP/nKlsKiosw0V3TY1XEHFcDO8d9s19jM/UXSjuIs0XB1XvRPCIMGwm0QFLIPJRBr/Xr1gVoGrWg/wY5jE0fa1tpXS2+ubS+X5yxJdQDYj3m2HVcw3ux4bzovoJ5GjXiGbuWwwrNf9VdGg6VzCNqyn+6P2hsQoo/1MJ/ZcjYJHttiABOPdGkAsZzz74K2P4QZ97CeHj3BreIT5/qWxFM8mN+AUEmXjdVU+c2wDSdCwBZhteoB9aPOF0cdRpfLKVVYvLeQmLnl7ZorCioz20QdR1z0CVNQ==
  • 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:44:26 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 01/04/2026 08:41, Orzel, Michal wrote:
> 
> 
> 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
Never mind, the alignment is in fact correct.

~Michal

> 
> 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®.