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

[PATCH v2 1/6] xen/arm: do not free reserved memory into heap


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Mon, 18 Apr 2022 20:22:46 +0800
  • 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TVQetJuWhfla6PNj0JS8SWxjHJNlo5AFHEjQX+4a0Lw=; b=UNIRTC2XwI+u7M9pj22U/BWjCPgq4tLdCIf3lPSFagSLsyBHOvGx8jbOXBoqLupIYWwZvX5q79kr1XAJhtGg/vV5fvaVQa9qa7+Ml9Q4xH29ZVxJwefqQ71lESrjAogxD7+ZjZd0of1FdG++OcKhp6kTDlElyjd1kcdMwZQj21AJjIKIX54zo34YVAGSheKw0YQkOyBXFLQEGwh+7+TDRqDiek9dwRfo78HFFCnQr5SkPUgPMGUNqjeCs99sUakaSrrq9xIUcv8bcpiDRV/Cpb6AqY1fhqMo4xflTK0SrgDnmP60ri94o1Zb7Ug1SMD36geKtzQdgq5ddEpPv5bpuw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kpa8zWvqRKZa7pQ4AECf3K18vcoNb5ntfSm+zpqbZL5hRDwuV+iZJzoXJm5Gnjocek/CiyyUDTRKoRlfJlfXV9dg8MHcVLpV1040D7jYR3rWvmJ2qdpiMOuDOdLIrMjMIZ2ZFOxCDQ8HAuxg3MWKdSWlOiRF6UOAuhVzAc5D9OK78R+eR7XYLLq4Ed+uHVP6XRKXwfvBx42h/NkhtlpMlPsCBUaHyVmMmvFjnyiwlaoodhs8h2nIS9DKnBVBLR8jHpW0SFpsWNaBri0BqhcxNytA7GO8lBsADu+c5KPMeyetZ+b7wRCX+ogjdBfBya0lXH+YChyyiqrsHeIo+/TVFw==
  • Cc: <wei.chen@xxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, "Stefano Stabellini" <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Penny Zheng <penny.zheng@xxxxxxx>
  • Delivery-date: Mon, 18 Apr 2022 12:23:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true

Pages as guest RAM for static domain, shall be reserved to this domain only.
So in case reserved pages being used for other purpose, users
shall not free them back to heap, even when last ref gets dropped.

free_staticmem_pages will be called by free_domheap_pages in runtime
for static domain freeing memory resource, so let's drop the __init
flag.

Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx>
---
v2 changes:
- new commit
---
 xen/common/page_alloc.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index 319029140f..9a3e9c1328 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -2488,7 +2488,13 @@ void free_domheap_pages(struct page_info *pg, unsigned 
int order)
             scrub = 1;
         }
 
-        free_heap_pages(pg, order, scrub);
+#ifdef CONFIG_STATIC_MEMORY
+        if ( pg->count_info & PGC_reserved )
+            /* Reserved page shall not go back to the heap. */
+            free_staticmem_pages(pg, 1 << order, scrub);
+        else
+#endif
+            free_heap_pages(pg, order, scrub);
     }
 
     if ( drop_dom_ref )
@@ -2636,7 +2642,7 @@ struct domain *get_pg_owner(domid_t domid)
 
 #ifdef CONFIG_STATIC_MEMORY
 /* Equivalent of free_heap_pages to free nr_mfns pages of static memory. */
-void __init free_staticmem_pages(struct page_info *pg, unsigned long nr_mfns,
+void free_staticmem_pages(struct page_info *pg, unsigned long nr_mfns,
                                  bool need_scrub)
 {
     mfn_t mfn = page_to_mfn(pg);
-- 
2.25.1




 


Rackspace

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