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

[PATCH 7/9] xen/arm: take care of concurrency on static memory allocation


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <sstabellini@xxxxxxxxxx>, <julien@xxxxxxx>, <jbeulich@xxxxxxxx>
  • From: Penny Zheng <penny.zheng@xxxxxxx>
  • Date: Mon, 7 Jun 2021 02:43:16 +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=/JHF5WaQ0fbVKChrSZ5i9VP+rOLKRk36xXg7oyU+VXY=; b=ZXMvDk8VmcyqAKBFBaQJv46ex32NcwSViXlCMPjde3qlQrtUcAEvGSdpIyf+sFx15J45fZIVxL7zwriEjanDyxuh3OlZP61T+5AQ3DT5PKd4k629pqMeuR7DqIcfDjI/QQZ6e3y0ztHGF2KGZ1jv8FhJ0BWCLgoDWyIdweCtOehwTbDRpumusyPCd2EoewQlTCuBA9qD0QIyTgSyX77uCux8l3v/W3Vb0csY25Fg2fSWHc3oAx/x8BbPgzoKwUgi1VZAnLZhZ0rmXbXC58cBLtOLButEvUNcG6sT+WfD13NnmuLQX+SLu/FRo0RsrSFWFvAYGfCmPr52A/VH6uwcHg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T/D7veZtl/BSsuiNy6+mof86zzVKMNR35v03tl9zbDZmUwSDkRRIVLroKYVqMGBlwN/UpfxUvcGmo4PENcOZhpUxjamaR0mGpQX9n0S0o/K6PnKMbA0VJjw8FZrcPeq7GPAC7BgR2k5tPZN4dO604kWCIvvkUWFIgcv6rMq9HOYqtV/bb9WxgLJIt4Z7lhuYItKsvaLF7zIbI+1NFeKo7j3mfrd9ipg1vYkSFsxy9g+sL58gTaD0FkmLVrxTXmUGl+0lWXDEemJXcuH26TbVSRYohYSSNpILb3RQpTwnReisT8kpB/GI8zVPYJIM64zLJCxEAr0KJI7RktDkxs5HGA==
  • Cc: <Bertrand.Marquis@xxxxxxx>, <Penny.Zheng@xxxxxxx>, <Wei.Chen@xxxxxxx>
  • Delivery-date: Mon, 07 Jun 2021 02:44:24 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true

In the future, user may want to allocate static memory at runtime,
and it is quite important to get the code protected from concurrent
access.

Re-use heap_lock to protect concurrent access in alloc_staticmem_pages.

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

diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index a0eea5f1a4..c6ccfc3216 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -1087,6 +1087,9 @@ static struct page_info *alloc_staticmem_pages(unsigned 
long nr_mfns,
                nr_mfns, mfn_x(smfn));
         return NULL;
     }
+
+    spin_lock(&heap_lock);
+
     pg = mfn_to_page(smfn);
 
     for ( i = 0; i < nr_mfns; i++ )
@@ -1127,6 +1130,8 @@ static struct page_info *alloc_staticmem_pages(unsigned 
long nr_mfns,
                             !(memflags & MEMF_no_icache_flush));
     }
 
+    spin_unlock(&heap_lock);
+
     if ( need_tlbflush )
         filtered_flush_tlb_mask(tlbflush_timestamp);
 
-- 
2.25.1




 


Rackspace

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