From patchwork Mon May 16 14:08:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 67900 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1559269qge; Mon, 16 May 2016 07:10:37 -0700 (PDT) X-Received: by 10.31.63.201 with SMTP id m192mr11762634vka.93.1463407837303; Mon, 16 May 2016 07:10:37 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id q65si5203916uaq.45.2016.05.16.07.10.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 May 2016 07:10:37 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b2JCx-0004hX-PK; Mon, 16 May 2016 14:09:19 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b2JCw-0004h1-Nz for xen-devel@lists.xen.org; Mon, 16 May 2016 14:09:18 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id 0E/D6-26599-E84D9375; Mon, 16 May 2016 14:09:18 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRWlGSWpSXmKPExsVysyfVTbf3imW 4QfchRYslHxezODB6HN39mymAMYo1My8pvyKBNWPfjVnMBZd4Klb1TGBqYDzH2cXIxSEksIlR Yv6+dlYI5zSQc7OVpYuRk4NNQFPizudPTCC2iIC0xLXPlxlBbGaBTIljbXPBaoQFQiU2bJwGF mcRUJWYP3UZWxcjBwevgLPE3lWsIGEJATmJk8cms4KEOQVcJL7slwAxhYAqbp71msDIvYCRYR WjRnFqUVlqka6hiV5SUWZ6RkluYmaOrqGBqV5uanFxYnpqTmJSsV5yfu4mRqBvGYBgB+PZ056 HGCU5mJREeePXWIYL8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuDdehkoJ1iUmp5akZaZAwwymLQE B4+SCO8xkDRvcUFibnFmOkTqFKOilDhvC0hCACSRUZoH1wYL7EuMslLCvIxAhwjxFKQW5WaWo Mq/YhTnYFQS5j0FMoUnM68EbvoroMVMQIsnmFmALC5JREhJNTAaTksrOf/uiLHS6Us/3r8V1V Avrt9Z+1KBL/xQ5Wsl7pf3nLesTzBpYytQXtwRH7XcKXB67/SZAv9u2Bwr+rvr056Hodohi5S /VfWlTtyfv+BC0LnfrzIbMpl5vpwr8VE+/Gn+diYVi6ildu+cpkx+/1ssTFM0ys8+IdRO7NwD ppwbrVqteo+UWIozEg21mIuKEwGv+kx/ZwIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1463407757!39856754!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 52763 invoked from network); 16 May 2016 14:09:17 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-206.messagelabs.com with SMTP; 16 May 2016 14:09:17 -0000 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 1A15E50D; Mon, 16 May 2016 07:09:33 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.215.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DC1543F21A; Mon, 16 May 2016 07:09:15 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 16 May 2016 15:08:55 +0100 Message-Id: <1463407735-7409-3-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1463407735-7409-1-git-send-email-julien.grall@arm.com> References: <1463407735-7409-1-git-send-email-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, wei.liu2@citrix.com, wei.chen@arm.com Subject: [Xen-devel] [for-4.7 2/2] xen/arm: p2m: Release the p2m lock before undoing the mappings X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Since commit 4b25423a "arch/arm: unmap partially-mapped memory regions", Xen has been undoing the P2M mappings when an error occurred during insertion or memory allocation. This is done by calling recursively apply_p2m_changes, however the second call is done with the p2m lock taken which will result in a deadlock for the current processor. Fix it by moving the recursive call after the lock has been released. Signed-off-by: Julien Grall --- I think we could unlock the p2m lock before freeing the temporary mapping. Although, I played safe as this is a bug fix for Xen 4.7 and to be backported up to Xen 4.5. --- xen/arch/arm/p2m.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 68c67b0..838d004 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1184,6 +1184,14 @@ out: while ( (pg = page_list_remove_head(&free_pages)) ) free_domheap_page(pg); + for ( level = P2M_ROOT_LEVEL; level < 4; level ++ ) + { + if ( mappings[level] ) + unmap_domain_page(mappings[level]); + } + + spin_unlock(&p2m->lock); + if ( rc < 0 && ( op == INSERT || op == ALLOCATE ) && addr != start_gpaddr ) { @@ -1196,14 +1204,6 @@ out: mattr, 0, p2m_invalid, d->arch.p2m.default_access); } - for ( level = P2M_ROOT_LEVEL; level < 4; level ++ ) - { - if ( mappings[level] ) - unmap_domain_page(mappings[level]); - } - - spin_unlock(&p2m->lock); - return rc; }