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

Re: [PATCH] xen/device-tree: Allow exact match for overlapping regions


  • To: Luca Fancellu <luca.fancellu@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Wed, 6 Nov 2024 16:07:28 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=arm.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=UmGfr9YAT/jMo+NtkL6AVLsUurS+IfL8hP3NwFSI/H4=; b=p1TreqSBMMvGioVGRwm1vnfBAIsySiBfYcJMnVUgFVhK1887ZfiUI4oaVUhQ+A3k8A1AI4w8mMmc6VJkflca2SFrAssELkz/R3KQUilKXa0+WMe9X/bBUqXEBocNN8Mw6/DRs/FQvxGhz/nM4ELxYaoMmIsEqdDgLyzAPvTXOqWzfmbk0cUWm/J0wAI82xoBcCuXW7ZXbQory6YehXllwH1AXc85BMdNdUXMs5leTGoRKXIUJ6vX9eMKlTkT030D4Gc9Uk+URhmn6RtOEAzME8cFDE8kfyiHKnjFHNyzVN9zzXqxbhCKF9zPkFZrhb4AYCt4SsFyaksFuDnhioNI8A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IKHbHh92XKmN+JqlE+y6Th03b2uuG4Rl7JDk/eSKbm4jlMPAnmOM9edjMNd9bhHrNsgxxISNXf5Hs3xYZQr1y+qam4XeFMazVTJFyuAFuDu4FIPSf78g/nLDr2ujGLN2912RF4XMBZjXOaBv9OgsFEGbJxNeVQgA07t0a0lBr8nox9OgmD0LrfqQPzFTHDkz2+BYfyX8rQmnJRdXpQYvoRWsMS+er0uPH3oQoOQ5VkihQOwRN3myTGPCBKFbP9LVB5LCpr+yZ7AHIEGoJaMYXm+CweLC6Qat7TH6Yr1oaSbSpYqqMMaPcNeTCwkm7psuunIGwbR7mmYmeORUStznvA==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>, Shawn Anastasio <sanastasio@xxxxxxxxxxxxxxxxxxxxx>, Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Delivery-date: Wed, 06 Nov 2024 15:07:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 06/11/2024 14:41, Luca Fancellu wrote:
> 
> 
> There are some cases where the device tree exposes a memory range
> in both /memreserve/ and reserved-memory node, in this case the
> current code will stop Xen to boot since it will find that the
> latter range is clashing with the already recorded /memreserve/
> ranges.
> 
> Furthermore, u-boot lists boot modules ranges, such as ramdisk,
> in the /memreserve/ part and even in this case this will prevent
> Xen to boot since it will see that the module memory range that
> it is going to add in 'add_boot_module' clashes with a /memreserve/
> range.
> 
> When Xen populate the data structure that tracks the memory ranges,
> it also adds a memory type described in 'enum membank_type', so
> in order to fix this behavior, allow the 'check_reserved_regions_overlap'
> function to check for exact memory range match given a specific memory
> type; allowing reserved-memory node ranges and boot modules to have an
> exact match with ranges from /memreserve/.
> 
> While there, set a type for the memory recorded during ACPI boot.
> 
> Fixes: 53dc37829c31 ("xen/arm: Add DT reserve map regions to 
> bootinfo.reserved_mem")
> Reported-by: Shawn Anastasio <sanastasio@xxxxxxxxxxxxxxxxxxxxx>
> Reported-by: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
> Signed-off-by: Luca Fancellu <luca.fancellu@xxxxxxx>
> ---
> I tested this patch adding the same range in a /memreserve/ entry and
> /reserved-memory node, and by letting u-boot pass a ramdisk.
> I've also tested that a configuration running static shared memory still works
> fine.
> ---
So we have 2 separate issues. I don't particularly like the concept of 
introducing MEMBANK_NONE
and the changes below look a bit too much for me, given that for boot modules 
we can only have
/memreserve/ matching initrd.

Shawn patch fixes the first issue. AFAICT the second issue can be fixed by 
below simple patch:
diff --git a/xen/common/device-tree/bootfdt.c b/xen/common/device-tree/bootfdt.c
index 927f59c64b0d..d8bd8c44bd35 100644
--- a/xen/common/device-tree/bootfdt.c
+++ b/xen/common/device-tree/bootfdt.c
@@ -586,6 +586,10 @@ size_t __init boot_fdt_info(const void *fdt, paddr_t paddr)

     add_boot_module(BOOTMOD_FDT, paddr, fdt_totalsize(fdt), false);

+    ret = device_tree_for_each_node(fdt, 0, early_scan_node, NULL);
+    if ( ret )
+        panic("Early FDT parsing failed (%d)\n", ret);
+
     nr_rsvd = fdt_num_mem_rsv(fdt);
     if ( nr_rsvd < 0 )
         panic("Parsing FDT memory reserve map failed (%d)\n", nr_rsvd);
@@ -594,10 +598,14 @@ size_t __init boot_fdt_info(const void *fdt, paddr_t 
paddr)
     {
         struct membank *bank;
         paddr_t s, sz;
+        const struct bootmodule *mod = 
boot_module_find_by_kind(BOOTMOD_RAMDISK);

         if ( fdt_get_mem_rsv_paddr(device_tree_flattened, i, &s, &sz) < 0 )
             continue;

+        if ( mod && (mod->start == s) && (mod->size == sz) )
+            continue;
+
         if ( reserved_mem->nr_banks < reserved_mem->max_banks )
         {
             bank = &reserved_mem->bank[reserved_mem->nr_banks];
@@ -610,10 +618,6 @@ size_t __init boot_fdt_info(const void *fdt, paddr_t paddr)
             panic("Cannot allocate reserved memory bank\n");
     }

-    ret = device_tree_for_each_node(fdt, 0, early_scan_node, NULL);
-    if ( ret )
-        panic("Early FDT parsing failed (%d)\n", ret);
-
     /*
      * On Arm64 setup_directmap_mappings() expects to be called with the lowest
      * bank in memory first. There is no requirement that the DT will provide

I'll let other DT maintainers voice their opinion.

~Michal



 


Rackspace

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