]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
xen/arm: Handle empty grant table region in find_unallocated_memory()
authorMichal Orzel <michal.orzel@amd.com>
Thu, 24 Aug 2023 09:06:40 +0000 (11:06 +0200)
committerJulien Grall <jgrall@amazon.com>
Tue, 12 Sep 2023 13:29:14 +0000 (14:29 +0100)
When creating dom0 with grant table support disabled in Xen and no IOMMU,
the following assert is triggered (debug build):
"Assertion 's <= e' failed at common/rangeset.c:189"

(XEN) Xen call trace:
(XEN)    [<0000020000218568>] rangeset_remove_range+0xbc/0x2cc (PC)
(XEN)    [<00000200002c76bc>] domain_build.c#make_hypervisor_node+0x294/0x7c4 (LR)
(XEN)    [<00000200002ca240>] domain_build.c#handle_node+0x7ec/0x924
(XEN)    [<00000200002ca7ac>] domain_build.c#construct_dom0+0x434/0x4d8

This is because find_unallocated_memory() (used to find memory holes
for extended regions) calls rangeset_remove_range() for an empty
grant table region. Fix it by checking if the size of region is not 0.

Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
xen/arch/arm/domain_build.c

index 29dcbb8a2ee63764bb6ca5d70525ea83dd85ecb2..6cf0450858586cf6e3a670f4bdf181bda997a8d3 100644 (file)
@@ -1633,14 +1633,18 @@ static int __init find_unallocated_memory(const struct kernel_info *kinfo,
     }
 
     /* Remove grant table region */
-    start = kinfo->gnttab_start;
-    end = kinfo->gnttab_start + kinfo->gnttab_size;
-    res = rangeset_remove_range(unalloc_mem, PFN_DOWN(start), PFN_DOWN(end - 1));
-    if ( res )
+    if ( kinfo->gnttab_size )
     {
-        printk(XENLOG_ERR "Failed to remove: %#"PRIpaddr"->%#"PRIpaddr"\n",
-               start, end);
-        goto out;
+        start = kinfo->gnttab_start;
+        end = kinfo->gnttab_start + kinfo->gnttab_size;
+        res = rangeset_remove_range(unalloc_mem, PFN_DOWN(start),
+                                    PFN_DOWN(end - 1));
+        if ( res )
+        {
+            printk(XENLOG_ERR "Failed to remove: %#"PRIpaddr"->%#"PRIpaddr"\n",
+                   start, end);
+            goto out;
+        }
     }
 
     start = 0;