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

[PATCH v3] xen/dom0less: arm: fix hwdom 1:1 low memory allocation


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Date: Thu, 7 Aug 2025 10:03:25 +0000
  • Accept-language: en-US
  • 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=B7hZ5D3jfW8bkALQeyclhEHdwOVrPtaxLoDxcmg317U=; b=C9iHal1x99cEaRHm7KTdnQHugus/pACk5Nnm8L/yK1qLj7wpD0x9TH0OLRURJsNiJO37llZhfH8NkahanD+FHTj9FyzJ0hOPo5wGUMQQ0mefqLqMIHEU21EyFQz5ZyJST5nZBdZp6Cch8+9tNQiZBCm3SOGVeQzKJvftOKmGynTgp3lz0dQgGYsELbiuF/S3z30zzKbZodOUCKWjKCKzOBMEuskVPmJxt/yvabznbYlA7zcy8C3jF07k+Xv1SPJL53u5DpxvZwaojtiBEfem4AMAEhlcE8RajVKtKNEpKsHW7NIGWRgDCI+hm5PbZ2jCN52hArxXFMmxs856v7slWQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wToG+n6x9HmjLFgXppME0mzKgIo5PJXZScLsfrcWbobZYHLaNiMU4/uy4rvyt8SgH9/M1Bc5xXrTy8H/kvOsNbNvSNLYQ5zlwKAgx4e5sxUlVIkljVubPMyQ3ShqSsO7elliruKPDBMaQgc2HU6fPDSPoieKzg6/wPEcIlsdXOvn+oAM5Dw4p5pEJu8/8eHzvSJT7Ljmanv3tDb+LfJqPI8Qe9rrj2BY3Jd+tghtLfPqjk/qMhYR6HA/f68pVQwRDKJucWTn8xtL2SamH1HbZQY2p+sIlOHTUK0FbxUPLGF0ueZRuK+9nO1lWLbIXK1iXSVU3jVugHoH2g8h9h39Mg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Grygorii Strashko <grygorii_strashko@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Denis Mukhin <dmukhin@xxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>, Julien Grall <jgrall@xxxxxxxxxx>
  • Delivery-date: Thu, 07 Aug 2025 10:03:31 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcB4KDC2FxELT99UexPqqnlkcdng==
  • Thread-topic: [PATCH v3] xen/dom0less: arm: fix hwdom 1:1 low memory allocation

From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>

Call stack for dom0less hwdom case (1:1) memory:
create_domUs
|-construct_domU
  |-construct_hwdom()
    |-allocate_memory_11()

And allocate_memory_11() uses "dom0_mem" as:
min_low_order =
  get_order_from_bytes(min_t(paddr_t, dom0_mem, MB(128)));

In case of dom0less boot the "dom0_mem" is not used and defaulted to 0,
which causes min_low_order to get high value > order and so no allocations
happens from low memory.

Fix it, by using kinfo->unassigned_mem instead of "dom0_mem" which has
correct memory size in both cases: regular dom0 boot and dom0less boot.

Fixes: 52cb53f1816a ("xen/arm: dom0less hwdom construction")
Signed-off-by: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
Reviewed-by: Denis Mukhin <dmukhin@xxxxxxxx>
Reviewed-by: Jason Andryuk <jason.andryuk@xxxxxxx>
Acked-by: Julien Grall <jgrall@xxxxxxxxxx>
---
Changes in v3:
- updated "dom0_mem" doc in xen-command-line.pandoc
- add tag from Julien Grall

Changes in v2:
- changed 'fixes' tag
- fixed comment for allocate_memory_11()
- added reviewer's tags

 docs/misc/xen-command-line.pandoc | 3 ++-
 xen/arch/arm/domain_build.c       | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/docs/misc/xen-command-line.pandoc 
b/docs/misc/xen-command-line.pandoc
index 6865a61220ca..1f33b7a11eba 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -1035,7 +1035,8 @@ For example, with `dom0_max_vcpus=4-8`:
 > `= <size>`
 
 Set the amount of memory for the initial domain (dom0). It must be
-greater than zero. This parameter is required.
+greater than zero. This parameter is required (and only used) when the initial
+domain is not described in the Device-Tree.
 
 ### dom0_mem (x86)
 > `= List of ( min:<sz> | max:<sz> | <sz> )`
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 463ae4474d30..a9e4153e3cf9 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -249,7 +249,7 @@ fail:
  *
  * We first allocate the largest allocation we can as low as we
  * can. This then becomes the first bank. This bank must be at least
- * 128MB (or dom0_mem if that is smaller).
+ * 128MB (or memory size requested for domain if that is smaller).
  *
  * Then we start allocating more memory, trying to allocate the
  * largest possible size and trying smaller sizes until we
@@ -278,7 +278,7 @@ static void __init allocate_memory_11(struct domain *d,
                                       struct kernel_info *kinfo)
 {
     const unsigned int min_low_order =
-        get_order_from_bytes(min_t(paddr_t, dom0_mem, MB(128)));
+        get_order_from_bytes(min_t(paddr_t, kinfo->unassigned_mem, MB(128)));
     const unsigned int min_order = get_order_from_bytes(MB(4));
     struct membanks *mem = kernel_info_get_mem(kinfo);
     struct page_info *pg;
-- 
2.34.1



 


Rackspace

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