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

[PATCH v3 3/9] xen/arm: Keep memory nodes in device tree when Xen boots from EFI


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Wei Chen <wei.chen@xxxxxxx>
  • Date: Wed, 11 May 2022 09:46:33 +0800
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=2; 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=x/jj6swJvwW7oaPWf61xuXLCqACdkaqKcZ14A1cc0Po=; b=gftvtevopxys/ClG/riOg7vQ6b3XCo0eE/HmoyB/M6WyqPfoNVQHO0FHk/ipNcHOZW2iscUONold1RYRG/nIwcTEXcWA7sBN5H2dC/Fd/8aVZ8nFj08YVftSr3+m4gMolLJrg8/IAl6uQDrTcl/46ThknWBEv9mEKkUBX9UyFwQG/L6dC1fR53s0thQ+6mhH6cQUZLEutk0Hai/3AhXxIwTA/rlnHRz5OGt4HJzJ2jexI6azIKLidom7DmtO7bX1tPC+RmMkXovxLkcR0pouDWEU/6lh82T1z8s3S4FPpTel0NjejJvoNQB+0lEZVChoqReJ+CdqWzjcMQ3ITqlv0Q==
  • 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=x/jj6swJvwW7oaPWf61xuXLCqACdkaqKcZ14A1cc0Po=; b=Z76qAbTvrGOEFiq0FBAdlzL2WuyJ2mh7bmClMPdXjsXnjSZBnDQ0gTNYBEdr9hJzIy+2ZaU2LOSv0l9DqrHkh+LbmnKolMl7FVa+0BeQifXDfDTixRuAdxZPO2CI2CDO8cTbwjIFuERZ/KXO2l+jW2WVSBmz70qrAuO2Qi41/5i/y/v08K59p28g6kpO51BTbZiH0VhjqxNWLxVEyvgMCw+/0M7Vrr9guboy2LyYpaD6n3mWdmOkvi464rL51svO93QRVwqlARtWM46kECUW2LPNrtgojZlSQlGvFYp3yQvguB5q3aXOIig/608n96jenpDP1KrpiHZbiXA9yuAQpw==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=Ok5CyOeuc5iCr5/Ow2NlN/JVQfNgqbQI6AwdgHqgiNcm0ozSB7SGcptm7qZiH4UKvDLQCES9l0ZVkLkoD8oTJ779M8x7HRomRwXQZgLmPGZsjcq0diEoTVbdQQhPCn5fcINaSUw05+qczmjG215os32+E16CfzjctO+xX1UnizRIJVVsH243JaHED3k3859/NKzamrqe15B0fJIuU6pjeUGIXLj1elijAtqycZJ5qu1KHigWLEk3po/mCyYEyAv8K/umr1gYehNwrbQfXbIrwioPvlBoQRvluqHXSnC1CG/BVAXj/ivLEhufavxPAiQpVLywvPRPCo0zSk0ow74FxA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cn6wZhv2NdrvO5W8IQE45hNexTnPLrBll7smfmwTI8UACcaVmUlQ7H5OCVDfeIWFLNIH5+fM+GjiT+CW0IjqVGp/y+6oRPUO1m5y1TG8T2lpgxKTC3wNBEVH/BmPnS3QVD1UMUkd8f/Ywqg5WNAgauKXp2Pjwg8A94D8H5V2DXBbTWiK/e9uWibDoBOtdxAlVaSdcz16hsTovt6pP7JRoc/xCWvQPUAVbajh9nhCQD6NyjcGgIx7Y8bSsgcBsbxdmNKRcIPjAYqtbOOPZpRxVLSCeDITlzXhYaQEurpktqDJ+Eh0/DJ5LOp7vfWda+EXdoyPI+p9Gi7L5hYBIaR1xw==
  • Cc: <nd@xxxxxxx>, Wei Chen <wei.chen@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Jiamei Xie <jiamei.xie@xxxxxxx>
  • Delivery-date: Wed, 11 May 2022 01:47:13 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true

In current code, when Xen is booting from EFI, it will delete
all memory nodes in device tree. This would work well in current
stage, because Xen can get memory map from EFI system table.
However, EFI system table cannot completely replace memory nodes
of device tree. EFI system table doesn't contain memory NUMA
information. Xen depends on ACPI SRAT or device tree memory nodes
to parse memory blocks' NUMA mapping. So in EFI + DTB boot, Xen
doesn't have any method to get numa-node-id for memory blocks any
more. This makes device tree based NUMA support become impossible
for Xen in EFI + DTB boot.

So in this patch, we will keep memory nodes in device tree for
NUMA code to parse memory numa-node-id later.

As a side effect, if we still parse boot memory information in
early_scan_node, bootmem.info will calculate memory ranges in
memory nodes twice. So we have to prevent early_scan_node to
parse memory nodes in EFI boot.

Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
Tested-by: Jiamei Xie <jiamei.xie@xxxxxxx>
Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
---
v2 -> v3:
1. Add Rb.
v1 -> v2:
1. Move this patch from later to early of this series.
2. Refine commit message.
---
 xen/arch/arm/bootfdt.c      |  8 +++++++-
 xen/arch/arm/efi/efi-boot.h | 25 -------------------------
 2 files changed, 7 insertions(+), 26 deletions(-)

diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
index 29671c8df0..ec81a45de9 100644
--- a/xen/arch/arm/bootfdt.c
+++ b/xen/arch/arm/bootfdt.c
@@ -11,6 +11,7 @@
 #include <xen/lib.h>
 #include <xen/kernel.h>
 #include <xen/init.h>
+#include <xen/efi.h>
 #include <xen/device_tree.h>
 #include <xen/libfdt/libfdt.h>
 #include <xen/sort.h>
@@ -367,7 +368,12 @@ static int __init early_scan_node(const void *fdt,
 {
     int rc = 0;
 
-    if ( device_tree_node_matches(fdt, node, "memory") )
+    /*
+     * If Xen has been booted via UEFI, the memory banks are
+     * populated. So we should skip the parsing.
+     */
+    if ( !efi_enabled(EFI_BOOT) &&
+         device_tree_node_matches(fdt, node, "memory") )
         rc = process_memory_node(fdt, node, name, depth,
                                  address_cells, size_cells, &bootinfo.mem);
     else if ( depth == 1 && !dt_node_cmp(name, "reserved-memory") )
diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h
index e452b687d8..59d93c24a1 100644
--- a/xen/arch/arm/efi/efi-boot.h
+++ b/xen/arch/arm/efi/efi-boot.h
@@ -231,33 +231,8 @@ EFI_STATUS __init fdt_add_uefi_nodes(EFI_SYSTEM_TABLE 
*sys_table,
     int status;
     u32 fdt_val32;
     u64 fdt_val64;
-    int prev;
     int num_rsv;
 
-    /*
-     * Delete any memory nodes present.  The EFI memory map is the only
-     * memory description provided to Xen.
-     */
-    prev = 0;
-    for (;;)
-    {
-        const char *type;
-        int len;
-
-        node = fdt_next_node(fdt, prev, NULL);
-        if ( node < 0 )
-            break;
-
-        type = fdt_getprop(fdt, node, "device_type", &len);
-        if ( type && strncmp(type, "memory", len) == 0 )
-        {
-            fdt_del_node(fdt, node);
-            continue;
-        }
-
-        prev = node;
-    }
-
    /*
     * Delete all memory reserve map entries. When booting via UEFI,
     * kernel will use the UEFI memory map to find reserved regions.
-- 
2.25.1




 


Rackspace

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