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

[PATCH v6 2/8] xen/arm: Keep memory nodes in device tree when Xen boots from EFI


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Wei Chen <wei.chen@xxxxxxx>
  • Date: Fri, 10 Jun 2022 13:53:10 +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=fe/7SCgP8Par+1oz7XY3pgQuiN9XdtDg0NAdMEO3/oI=; b=OlC9r1/ueG6jm8gcw95bdK8Z7Zd2N7RdOjjsuu+vs69MqQhcGfJSQG93zqv2oAcco5DquPDRVtOW73i+YD7F5Uv7DhbFR5XtspbG4mZ0lsfY/VkwYzBJ4pnmra1+CTCEhD6NfKTLMmguuAAuBf+TkT9DVHSY/9afynxohCgRIxuyoJWHmOa7V7DDRxebJ2FmsSDWyyaO3YzGiWIbxMkJCK/gdAYxlv3eDuCt+G8AmtNW4VI196GKWj7ph2mq+OVRQahfxVY9ywE8O9ifxs5hnz2cm1be2vePFaYbb7bQndPSIen30BpKNpiAprqNMWG9MOzWQHBCdCbliCh/DNaUhQ==
  • 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=fe/7SCgP8Par+1oz7XY3pgQuiN9XdtDg0NAdMEO3/oI=; b=ne7FhMXp4O3E3hp7VmY8xSKeyWXP310ReNPJ1i4bflH7pbDw5sAxO8omrbvxrDFse1OkiRYovzW44cNlXKU1weIY2oa8ad0XR55R9EEL4yzHOsgVD8QsRRBDvO36RU20dtvHPj1VQdeswUbMtjDCeWyvhSAoEGrRWLoXOCazA/T0vTdUV5TxPCf2NzzZpjlrqvkQfieJGYFUJH+nBgao03lq4LLkgMOJF27JdecFuNba4ElSwoVuCIQG54YATvzj3OAeHOYksDERzw+QfsMfErkoSyhrFZ71Qie68B/xhX7Ih0P4K7rucKowWQFNGXD1JsZeGIVh3PbK57+tRIAXdg==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=fG43HVGRzqgv268RgH4ZlslKXSyLWt+AjAAzjwzu/88XreU0HjoZ1HiIQY43wgnEOaZOG2jG+d1l+2u8+MN9ts6LohKPgslEfYhhOa0ofVKx5OrM9CMXgbkvqeImRr8PzAMyvX+Ric4wid8e/Joq9LlSPr2dzHe0K3Q1QiuM6sxOGZdJCc4oFjcFSrg61nb+KSzJibK1WIZ1QHXXSWJsOvT6oUZ6UpZqXNBRykB05MK7uEdahhv0hsZAoZRQJcPA9CEl+nSGfqrYPhX7jHr70Oigh8OLQKLMG64QN6OareLiicHheuPoe8fuHhWPWR98mz7aVzXsaxWakR0jzNiBYg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ddq0wSrEF0nEyvtRkGTdBTBFasFvFEJ/2RpAiQy4FzzM4Diz8aixV+ow9uRVMqPqg5O7TqkPmF0dgN7++UToo+qhuJ2oqpZU7W3Nmdj16+ACDzKtUoS7k6zU14kjFSXkBDD54RR8yn1y309NG28C8sGsiWhVYNxAwwr/LZxH0yl3025yXHGneY1vsnFGamesDIaNkKFLHSxnSLk15+67MOCFeZj1YUj6/X9W3jNAfSm2MSeW6HhEJO30Yj+K+5SuOuuMgpKjBZEo/Cvcji3E+eRKEgTqHprI7pNd+P+S0TKku44DVReQq2FLdZk5D4O0lFZGTKm11ctH7mCJg8xryg==
  • 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: Fri, 10 Jun 2022 05:53:59 +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>
---
v3 -> v4:
1. No change.
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®.