From patchwork Mon Apr 22 16:49:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 162599 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2801128jan; Mon, 22 Apr 2019 09:51:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqxF0Igtp1s08qBr8AFKwKyeU0Gzr4sHM3LqHiNsrZDEWj9nnwM4ysCucnFML6Y5dkRF8Xk3 X-Received: by 2002:a25:7344:: with SMTP id o65mr17091820ybc.324.1555951864610; Mon, 22 Apr 2019 09:51:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555951864; cv=none; d=google.com; s=arc-20160816; b=q5Tpotl1CRt9QO/V5BDkzKRaOpweEJJO2hbJe6TupoTWk/BTdrIi0IdT7uslk7J32R bnUhAA0nYstjWKrqHoI2UgElMYu4rnLCGl6/QQ8gTxNbbph+jelv/TfuN/rRvc16cgBZ /+vbRKm+cT7WXuSrXu+MHXDAkFPE5GJ7w4o9qoYcKcaaXsTjxecDEibV9Qat/dsufnv6 GST6aQ95FvEAIvUGHJ5xZ0QMvCwBYeJxmd/neOdn2AjjLOV5JAFkrzkDQj0fTa2jP0R4 EjhfLrjz+GgWV262IK7vh2lDDgPera4w3rXQA8sS2m+G75BMl16zgzzT9x4kSTDUnBY7 InSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from; bh=vkbWm5L4hkPeh6lhhbiKjUlgqmRpXhzR5r7St2GVTNQ=; b=nNDOk+fgLRZE+HoZOt7G1aMfwXsXIylt6ce5SfIY7lgeEjNQx/2PGR6M+5GuXBYW9V dIc/nx9FB7eWSXL2WDLHwwj3Z9cUBjgxuVAPJvgjyHd2acv7Zowx6lYZApqtKhgxvk36 1MQVODILPrTSc4+3uqO6g5rCNtXT2OxtP0dk+5oSz0lzxhlmCFukL0Y4BjR5Sva8YmVh Qe/buoC+KlVjMCBmDQHvaEq8FzJipbEgwz/N6DgREa4yrOWo9qqp6tPaHnBUdrERajn6 Di/Lvtp0OzByawtS4qBprkzW98s2I6l8FBqVjevF2mVu7Y91NA9DOiYEQYYB3U7HaGDY 2w2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id k8si9121262ywb.11.2019.04.22.09.51.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Apr 2019 09:51:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hIc91-0005Kr-0n; Mon, 22 Apr 2019 16:50:15 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hIc8z-0005Ie-Sj for xen-devel@lists.xenproject.org; Mon, 22 Apr 2019 16:50:13 +0000 X-Inumbo-ID: b24e7016-651e-11e9-8ecb-6bad741746e0 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id b24e7016-651e-11e9-8ecb-6bad741746e0; Mon, 22 Apr 2019 16:50:12 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7B674374; Mon, 22 Apr 2019 09:50:12 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6BCE13F557; Mon, 22 Apr 2019 09:50:11 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Apr 2019 17:49:33 +0100 Message-Id: <20190422164937.21350-17-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190422164937.21350-1-julien.grall@arm.com> References: <20190422164937.21350-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 16/20] xen/arm: mm: Protect Xen page-table update with a spinlock X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Oleksandr_Tyshchenko@epam.com, Julien Grall , sstabellini@kernel.org, Andrii_Anisov@epam.com MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The function create_xen_entries may be concurrently called. So we need to protect with a spinlock to avoid corruption the page-tables. Signed-off-by: Julien Grall Reviewed-by: Andrii Anisov --- xen/arch/arm/mm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index fa0f41bd07..ecde4e34df 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -969,6 +969,8 @@ enum xenmap_operation { RESERVE }; +static DEFINE_SPINLOCK(xen_pt_lock); + static int create_xen_entries(enum xenmap_operation op, unsigned long virt, mfn_t mfn, @@ -980,6 +982,8 @@ static int create_xen_entries(enum xenmap_operation op, lpae_t pte, *entry; lpae_t *third = NULL; + spin_lock(&xen_pt_lock); + for(; addr < addr_end; addr += PAGE_SIZE, mfn = mfn_add(mfn, 1)) { entry = &xen_second[second_linear_offset(addr)]; @@ -1054,6 +1058,8 @@ out: */ flush_xen_tlb_range_va(virt, PAGE_SIZE * nr_mfns); + spin_unlock(&xen_pt_lock); + return rc; }