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

[PATCH] xen/arm: Fix booting hwdom/1:1 domU with CONFIG_GRANT_TABLE=n


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Wed, 25 Jun 2025 12:12:30 +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 (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=Y3hiNFzxIQZ9mKBcULLnKYBwTI1NMIdUdy4GH33M5uc=; b=rZu6aj4dAu7FpSIeh9mqytc1hE716IZVQTxh1jYNTGtr5ATDjGmh60siMlCEGim0jm9dNz4t7mEWRNfHRn0PuH9pBXZFapq1Uts0Y5w/0MUz+coxhoPVmmG4A3k1hCDvNFvi6M1OFqgF753ABwCuSPB6BFR0f10as84Bia1Zeuc+0Ud2JOdPlxU3r6bpDkx6n3wM37y4SkuiVzdFq/38wmz5TyZ1g6/nUZDbSuqlNuIzH7/LSTU94WXhnwzxSUliCKP5gZMnZ7AfsJxqpWMIxzSLAxcWIDz9kQ5MCDp9+auYaFV/07REKL6XwMOreCFhtgVDQCz0C5MZryIS2nUzCg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lr4hVe9KP3Q3AQtUxiu33Qo/mLRXFZ+a0nVOImWoTKn+VotUeGO20h+g29qXW+lTG9BhP8lP0xx/e/w2BTLRV7Wih+snmY93ZSXSDTbuWydZQdbdo8tZvUe/mGhXlqaFSiVxB0RQutapUABiwKtUESWRuVYXVT4vSY2ssM7vBSXsWwGD8te/4RDK6p4VDlAvTpox7+1NqrONzzqsLeF0iiGUAIa0op6ihaycxIa1myENtZIiJQR2dSw5rG5HeMYeTJH0oWExPVkLF6NFl0rQ4+ihqmfqhx9tTyL8w8KICimQtbchTGQ97oggy+EUubTItsWdeq56HN0ijR9VC+cyug==
  • 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: Wed, 25 Jun 2025 10:12:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

At the moment, we unconditionally allocate space for grant table region
membank and add it in the membanks array to find_unallocated_memory() to
find unused memory. In case of CONFIG_GRANT_TABLE=n, the size of the
region is empty and assertion in rangeset_remove_range() fails when
booting hwdom or 1:1 domU without IOMMU. Example:

(XEN) Assertion 's <= e' failed at common/rangeset.c:189
...
(XEN) Xen call trace:
(XEN)    [<00000a0000218b5c>] rangeset_remove_range+0xbc/0x2d4 (PC)
(XEN)    [<00000a00002b8370>] find_unallocated_memory+0x140/0x208 (LR)
(XEN)    [<00000a00002cc28c>] make_hypervisor_node+0x310/0x7e0
...

Same issue would occur when booting hwdom with LLC coloring enabled.
Fix it by performing conditional allocation and configuration.

Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
---
 xen/arch/arm/domain_build.c           | 19 ++++++++++++-------
 xen/common/device-tree/domain-build.c |  7 ++++++-
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 3f5c7c2e5aa8..04d3dca38a42 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1011,7 +1011,10 @@ static int __init find_host_extended_regions(const 
struct kernel_info *kinfo,
                                              struct membanks *ext_regions)
 {
     int res;
-    struct membanks *gnttab = membanks_xzalloc(1, MEMORY);
+    struct membanks *gnttab =
+        IS_ENABLED(CONFIG_GRANT_TABLE)
+        ? membanks_xzalloc(1, MEMORY)
+        : NULL;
     struct membanks *xen_reg =
         kinfo->xen_reg_assigned
         ? membanks_xzalloc(count_ranges(kinfo->xen_reg_assigned), MEMORY)
@@ -1037,12 +1040,6 @@ static int __init find_host_extended_regions(const 
struct kernel_info *kinfo,
 
     dt_dprintk("Find unallocated memory for extended regions\n");
 
-    if ( !gnttab )
-    {
-        res = -ENOMEM;
-        goto out;
-    }
-
     if ( kinfo->xen_reg_assigned )
     {
         if ( !xen_reg )
@@ -1056,9 +1053,17 @@ static int __init find_host_extended_regions(const 
struct kernel_info *kinfo,
                                rangeset_to_membank, xen_reg);
     }
 
+#ifdef CONFIG_GRANT_TABLE
+    if ( !gnttab )
+    {
+        res = -ENOMEM;
+        goto out;
+    }
+
     gnttab->nr_banks = 1;
     gnttab->bank[0].start = kinfo->gnttab_start;
     gnttab->bank[0].size = kinfo->gnttab_size;
+#endif
 
     res = find_unallocated_memory(kinfo, mem_banks, ARRAY_SIZE(mem_banks),
                                   ext_regions, add_ext_regions);
diff --git a/xen/common/device-tree/domain-build.c 
b/xen/common/device-tree/domain-build.c
index cd01a8b4bc9f..e6d7b8961e89 100644
--- a/xen/common/device-tree/domain-build.c
+++ b/xen/common/device-tree/domain-build.c
@@ -250,7 +250,10 @@ void __init allocate_memory(struct domain *d, struct 
kernel_info *kinfo)
      */
     if ( is_hardware_domain(d) )
     {
-        struct membanks *gnttab = membanks_xzalloc(1, MEMORY);
+        struct membanks *gnttab =
+            IS_ENABLED(CONFIG_GRANT_TABLE)
+            ? membanks_xzalloc(1, MEMORY)
+            : NULL;
         /*
          * Exclude the following regions:
          * 1) Remove reserved memory
@@ -261,12 +264,14 @@ void __init allocate_memory(struct domain *d, struct 
kernel_info *kinfo)
             gnttab,
         };
 
+#ifdef CONFIG_GRANT_TABLE
         if ( !gnttab )
             goto fail;
 
         gnttab->nr_banks = 1;
         gnttab->bank[0].start = kinfo->gnttab_start;
         gnttab->bank[0].size = kinfo->gnttab_size;
+#endif
 
         hwdom_free_mem = membanks_xzalloc(NR_MEM_BANKS, MEMORY);
         if ( !hwdom_free_mem )
-- 
2.25.1




 


Rackspace

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