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

[PATCH] static-memory: Fix incorrect tot_size calculation


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Wed, 4 Feb 2026 13:42:35 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org 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=VWMO57uU2Fq3Clg6mGQDBBnMxZ+u25eXCEE6rCrPYcY=; b=iFRwvL40LOjGq+gvQBSf4w06OzVmSwmc+XPFEeAgG02/Pvq+xTThTvpK9EHCjEC+ALy7DYSOm4xt/x83ayeOmqcHL1EYb0Il5uJ6Glx9wLzuWAZ1/GpVn4n0En/Wk8gSelHri15JcUuwwKE+wfNx2FX57/HsIGwts3VdlKHlSLhnfJcrWVcww/VpIboaGvuFyRcLMbkxJrpluq8+XUF5FVZjBjAWj70WBH4sZ/ddnqKgLkIKS4NkYVRTZeXOg6LzrZCyjtdscoe4S0B186/tOTOqCOhoAFq1BaziXeiEP8whHL2KYCDJiLjWFxjTCKBraNsgnOlf7gkoIC1q2TuPtA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gExFv5VhnboIcUN2YJVIyb7C6H4NkjsT5wCUmKZuB5vwy9Q1nkv0rLkaa1dR5sRewiZIHR1qNfy+jpf/vyn24qdRVdObkXuyG/R1KyL9H37UIReqFuCsIsHjTFtqjGW5Il+aqSewpdzw4UF9RLKOtbCAWApgDgnQAzCcyhtNBa1WHSS5x+ENZ1jCQUiqDXOgurDhJmTB1DCVz0N76YSIxUb0pVnplSF777CO/xgJ9WOOEnbtBiu7chUzWo4aMVzaFY6wAhMDBxpzE0hopVHvc2BcxgGory2SIPoS8de2tZON5yR+2zJmvkStckZXifbuk0hxHt+fa28VZ/oCE3N8eQ==
  • Cc: Michal Orzel <michal.orzel@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>
  • Delivery-date: Wed, 04 Feb 2026 12:42:59 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

When a physical memory bank spans multiple guest RAM banks, the variable
psize is modified inside the allocation loop, but the modified value
(instead of the original bank size) is added to tot_size. This causes an
incorrect total size calculation leading to false panic. Move the
tot_size calculation right after acquire_static_memory_bank().

Fixes: 487975df53b5 ("xen/arm: introduce allocate_static_memory")
Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
---
 xen/common/device-tree/static-memory.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/common/device-tree/static-memory.c 
b/xen/common/device-tree/static-memory.c
index 0774d0680604..ffbc12aa24df 100644
--- a/xen/common/device-tree/static-memory.c
+++ b/xen/common/device-tree/static-memory.c
@@ -118,6 +118,8 @@ void __init allocate_static_memory(struct domain *d, struct 
kernel_info *kinfo,
         if ( mfn_eq(smfn, INVALID_MFN) )
             goto fail;
 
+        tot_size += psize;
+
         printk(XENLOG_INFO "%pd: STATIC BANK[%u] %#"PRIpaddr"-%#"PRIpaddr"\n",
                d, bank, pbase, pbase + psize);
 
@@ -158,8 +160,6 @@ void __init allocate_static_memory(struct domain *d, struct 
kernel_info *kinfo,
                 mem->bank[gbank].start = rambase[gbank];
             }
         }
-
-        tot_size += psize;
     }
 
     mem->nr_banks = ++gbank;
-- 
2.43.0




 


Rackspace

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