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

[PATCH 2/2] xen/arm: Account for domU dtb bootmodule size separately


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Tue, 11 Jul 2023 10:29:31 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org 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
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=RFJtVBokWQOgsGyRuqtzu1MVYHpDtHoyB0Kjiu13Ozg=; b=H2aC1leHpsENWD3DMzmY2gldE0D8fCymfO/jnrpDaCGfszgUpwwzzgmuzEHQO0o7dRYuRjA9zti09zrJHLHe4EJSZkXaba4PTRwyBu9iFY8912BnRWJbhTnRpSVtBi95GXKgNMgtYLmDseeUpyBceCVeeE8p7F7xADyDr/yz+eK/zy3EbBisbm1IBQysemkCobWL9xNFBIhC0pmB8HnwjpSnP9kibM9ZpPnxKf1IUgh13HCPFokEw+X3kB4fKIDgsYVHL3YJ8yslQT6G/dBimdgcxrMQ9vZPzRI/fCJHLSJ/Vlx1dY7hRS0B0UX+Hv6bxeqtVztXYcWPP6Crj1JfOg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m7ZQwkn5k2R8LG32eKvVujZx/LGb923XsnbaztCxw8t7AwbkprxLwx6YfGtJXTBv4dcflHq/iVmYHD82EdExKZp6QFqgYRlPBElfnuzmKHldRWFWtXhrjUo4u+U7s066Ai3v8c0eyRD0Dmhat+uBBD2EWDkloChOV9y7GX4TQBsft/vOOkCqjYvhno2aMQTRtlSk1sYXDi3KIaFFs5KRNIHQFizfRI5xu9R17nOqw5H48IhE+S0uFqtVzsf+GjWGjdUVzCnmrjj9lp1Pm25dUXD/mJoH2r8WFbrIqMMVrQdRYRvFcBfBhdM93G/lW0Ja34aEcHWYDNvScAvfKVx4Fw==
  • Cc: Michal Orzel <michal.orzel@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 11 Jul 2023 08:29:59 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

At the moment, we limit the allocation size when creating a domU dtb to
4KB, which is not enough when using a passthrough dtb with several nodes.
Improve the handling by accounting for a dtb bootmodule (if present)
size separately, while keeping 4KB for the Xen generated nodes (still
plenty of space for new nodes). Also, cap the allocation size to 2MB,
which is the max dtb size allowed.

Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
---
Note for the future:
As discussed with Julien, really the best way would be to generate dtb directly
in the guest memory, where no allocation would be necessary. This of course
requires some rework. The solution in this patch is good enough for now and
can be treated as an intermediated step to support dtb creation of various
sizes.
---
 xen/arch/arm/domain_build.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index f2134f24b971..1dc0eca37bd6 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -3257,14 +3257,15 @@ static int __init domain_handle_dtb_bootmodule(struct 
domain *d,
 }
 
 /*
- * The max size for DT is 2MB. However, the generated DT is small, 4KB
- * are enough for now, but we might have to increase it in the future.
+ * The max size for DT is 2MB. However, the generated DT is small (not 
including
+ * domU passthrough DT nodes whose size we account separately), 4KB are enough
+ * for now, but we might have to increase it in the future.
  */
 #define DOMU_DTB_SIZE 4096
 static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo)
 {
     int addrcells, sizecells;
-    int ret;
+    int ret, fdt_size = DOMU_DTB_SIZE;
 
     kinfo->phandle_gic = GUEST_PHANDLE_GIC;
     kinfo->gnttab_start = GUEST_GNTTAB_BASE;
@@ -3273,11 +3274,18 @@ static int __init prepare_dtb_domU(struct domain *d, 
struct kernel_info *kinfo)
     addrcells = GUEST_ROOT_ADDRESS_CELLS;
     sizecells = GUEST_ROOT_SIZE_CELLS;
 
-    kinfo->fdt = xmalloc_bytes(DOMU_DTB_SIZE);
+    /* Account for domU passthrough DT size */
+    if ( kinfo->dtb_bootmodule )
+        fdt_size += kinfo->dtb_bootmodule->size;
+
+    /* Cap to max DT size if needed */
+    fdt_size = min(fdt_size, SZ_2M);
+
+    kinfo->fdt = xmalloc_bytes(fdt_size);
     if ( kinfo->fdt == NULL )
         return -ENOMEM;
 
-    ret = fdt_create(kinfo->fdt, DOMU_DTB_SIZE);
+    ret = fdt_create(kinfo->fdt, fdt_size);
     if ( ret < 0 )
         goto err;
 
-- 
2.25.1




 


Rackspace

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