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

[PATCH 02/10] xen/arm: handle static memory in dt_unreserved_regions


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <sstabellini@xxxxxxxxxx>, <julien@xxxxxxx>
  • From: Penny Zheng <penny.zheng@xxxxxxx>
  • Date: Tue, 18 May 2021 05:21:05 +0000
  • 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=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-SenderADCheck; bh=Y6ATApPmkJrCTf9a/bdU7n8KOS835CGS4AwJ5jf2OAQ=; b=lvDdsQKErF1AEelc10ZAdO00PEOqtgNwm9Vy05ZOLdEbdXsJQKTfgu1l8I3zXJ/uNQITuwmBpymin+TOQRmRwAQmLQH2uB6nAc7LxueFmip2NrFfhjKT4z7nsmhsS8X2sco/4juM3XDrr3ptOO1kuRBEsVgglRVzGln8+JLGRSbULlr7e/opHaXVqTDn0Cvwt7GOECQ8ytr6JcVWRTq3PKc7SpBDAyQtyffd1PKz7skVHtLzYqRzPAuGlZFef6mwPFFid6ViXhakHcFbP3abe6UnaAHYEpdQCyPk8YWuGccGAz886D1TnduWalPw+FP5cXG3gXkNox1vuRNTgmNTOA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FTHnQ07fRNS5BlvlqHDqyskc/9S0UEz6GUcdpGuapbw7glfOX5H7aGelZnGk6D4BSmAwMnFEivcUwz/YIQxATxATrZCj12JSkOflDxTLktQXWjg+GTeK4tDVX60nL7eoull+KpXL+lHF8LAwVRLgpLddxEdoMEsvYD5Uf5DSxwvnc03SZPWAZMnJfzuNB5Uksuwj7+6TsssAc4I+Csd5q6qO8RgJ6c6wg0OwdgTwxG9M96NgU8tM9dVnWASjLWSgtKym1RRvVlToNI6X4pAizb9e06o5uSgkpM1Un5m3Yfoon0+RE8t3gerc6k3zChtbxj9TmFcisDTBr32gimMkhw==
  • Cc: <Bertrand.Marquis@xxxxxxx>, <Penny.Zheng@xxxxxxx>, <Wei.Chen@xxxxxxx>, <nd@xxxxxxx>
  • Delivery-date: Tue, 18 May 2021 05:22:07 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true

static memory regions overlap with memory nodes. The
overlapping memory is reserved-memory and should be
handled accordingly:
dt_unreserved_regions should skip these regions the
same way they are already skipping mem-reserved regions.

Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx>
---
 xen/arch/arm/setup.c | 39 +++++++++++++++++++++++++++++++++------
 1 file changed, 33 insertions(+), 6 deletions(-)

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 00aad1c194..444dbbd676 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -201,7 +201,7 @@ static void __init dt_unreserved_regions(paddr_t s, paddr_t 
e,
                                          void (*cb)(paddr_t, paddr_t),
                                          int first)
 {
-    int i, nr = fdt_num_mem_rsv(device_tree_flattened);
+    int i, nr_reserved, nr_static, nr = fdt_num_mem_rsv(device_tree_flattened);
 
     for ( i = first; i < nr ; i++ )
     {
@@ -222,18 +222,45 @@ static void __init dt_unreserved_regions(paddr_t s, 
paddr_t e,
     }
 
     /*
-     * i is the current bootmodule we are evaluating across all possible
-     * kinds.
+     * i is the current reserved RAM banks we are evaluating across all
+     * possible kinds.
      *
      * When retrieving the corresponding reserved-memory addresses
      * below, we need to index the bootinfo.reserved_mem bank starting
      * from 0, and only counting the reserved-memory modules. Hence,
      * we need to use i - nr.
      */
-    for ( ; i - nr < bootinfo.reserved_mem.nr_banks; i++ )
+    i = i - nr;
+    nr_reserved = bootinfo.reserved_mem.nr_banks;
+    for ( ; i < nr_reserved; i++ )
     {
-        paddr_t r_s = bootinfo.reserved_mem.bank[i - nr].start;
-        paddr_t r_e = r_s + bootinfo.reserved_mem.bank[i - nr].size;
+        paddr_t r_s = bootinfo.reserved_mem.bank[i].start;
+        paddr_t r_e = r_s + bootinfo.reserved_mem.bank[i].size;
+
+        if ( s < r_e && r_s < e )
+        {
+            dt_unreserved_regions(r_e, e, cb, i + 1);
+            dt_unreserved_regions(s, r_s, cb, i + 1);
+            return;
+        }
+    }
+
+    /*
+     * i is the current reserved RAM banks we are evaluating across all
+     * possible kinds.
+     *
+     * When retrieving the corresponding static-memory bank address
+     * below, we need to index the bootinfo.static_mem starting
+     * from 0, and only counting the static-memory bank. Hence,
+     * we need to use i - nr_reserved.
+     */
+
+    i = i - nr_reserved;
+    nr_static = bootinfo.static_mem.nr_banks;
+    for ( ; i < nr_static; i++ )
+    {
+        paddr_t r_s = bootinfo.static_mem.bank[i].start;
+        paddr_t r_e = r_s + bootinfo.static_mem.bank[i].size;
 
         if ( s < r_e && r_s < e )
         {
-- 
2.25.1




 


Rackspace

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