From patchwork Wed Feb 3 11:37:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corneliu ZUZU X-Patchwork-Id: 8201161 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8B4DEBEEE5 for ; Wed, 3 Feb 2016 11:43:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C0F74201DD for ; Wed, 3 Feb 2016 11:43:20 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E961A201B9 for ; Wed, 3 Feb 2016 11:43:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aQvnP-0001sS-12; Wed, 03 Feb 2016 11:40:27 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aQvnN-0001sN-DH for xen-devel@lists.xen.org; Wed, 03 Feb 2016 11:40:25 +0000 Received: from [85.158.139.211] by server-12.bemta-5.messagelabs.com id 2F/90-17089-827E1B65; Wed, 03 Feb 2016 11:40:24 +0000 X-Env-Sender: czuzu@bitdefender.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1454499623!20014332!1 X-Originating-IP: [91.199.104.161] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 34854 invoked from network); 3 Feb 2016 11:40:23 -0000 Received: from mx01.buh.bitdefender.com (HELO mx01.buh.bitdefender.com) (91.199.104.161) by server-12.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 3 Feb 2016 11:40:23 -0000 Comment: DomainKeys? See http://domainkeys.sourceforge.net/ DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=bitdefender.com; b=yi30Uos1qSBsI/bS+2aueOehYZxq5awdBa0UXEbAhyHu39i073KVWV0DtMy4ICWlWFyihxN4k7T6qZkQrrwoqjp0Z3Q4JKKuub92ZAy7CNxbyzb/LCiI0RVMdXcgZXhPD2WhNrNLBP686pYoO3GfYLPD4t5Xgi17TZ3L7C6SdMOxiUS+CuwxDxZt0nPPabcMNJQTN9L52hM8iKVz6VAF+I0VBLlDbN0xhsBM/PGFjSh7LaxB/vwb1/l/sZKm/Qmo4b/BxKbrC0u1Bty5TIgxetTYmqzO2VHRcFyXbZwlZfOFhyau/gBz512FZkuQ/vFjtGyoulu3byGlQBFjJLsAeg==; h=Received:Received:Received:Received:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References:X-BitDefender-Scanner:X-BitDefender-Spam:X-BitDefender-SpamStamp:X-BitDefender-CF-Stamp; DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=bitdefender.com; h=from:to :cc:subject:date:message-id:in-reply-to:references; s=default; bh=9ZpHYMPcAZEmyxvXRRu7AUAEiYQ=; b=EWIyXLGgYHK2RyVyjek66ZjgplQc p2H/RDsg4vloV6IBJ4nc5yHXjKJXdxdCYbxbJl/9gQmT91E/Y+pHO+HHjzbi7CzD bjEKn4u2JOo9MSDb0gfWoSsO5Sd1hPzB833JBjkEwL1wTdWnuxFTcZrc9Fi2SwtF FRJKqxchiPb4RXxCh8SmUB3kFTCcfPYI6YItueSTGq1S1ie7dJe3kOEgN+rKogVV xryeENS61ekB9G6eWbGELNy6H3mnHlo8XkFDa3ftJX3XV9SnmGPdho+9vxHXPXXw mA3BM3vRntJYP2PRwgwRM8Su+LVvtFWJHQ9G8KyI/4KXOjdNti8riW/vTQ== Received: (qmail 8728 invoked from network); 3 Feb 2016 13:38:00 +0200 Received: from unknown (HELO mx-sr.buh.bitdefender.com) (10.17.80.103) by mx01.buh.bitdefender.com with AES256-GCM-SHA384 encrypted SMTP; 3 Feb 2016 13:38:00 +0200 Received: from smtp02.buh.bitdefender.net (unknown [10.17.80.76]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id 5E2FE802A3 for ; Wed, 3 Feb 2016 13:38:00 +0200 (EET) Received: (qmail 12200 invoked from network); 3 Feb 2016 13:38:00 +0200 Received: from unknown (HELO czuzu-dev-vm.clj.bitdefender.biz) (czuzu@bitdefender.com@172.21.6.207) by smtp02.buh.bitdefender.net with AES128-SHA256 encrypted SMTP; 3 Feb 2016 13:38:00 +0200 From: Corneliu ZUZU To: xen-devel@lists.xen.org Date: Wed, 3 Feb 2016 13:37:44 +0200 Message-Id: <1454499464-7278-1-git-send-email-czuzu@bitdefender.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1453808778-4292-1-git-send-email-czuzu@bitdefender.com> References: <1453808778-4292-1-git-send-email-czuzu@bitdefender.com> X-BitDefender-Scanner: Clean, Agent: BitDefender qmail 3.1.4 on smtp02.buh.bitdefender.net, sigver: 7.64380 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.6.743, Dats: 413694, Stamp: 3], Multi: [Enabled, t: (0.000008, 0.002008)], BW: [Enabled, t: (0.000013,0.000001)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.002187), Flags: 2A917CE3; NN_NO_CONTENT_TYPE; NN_NO_LINK_NMD; NN_LEGIT_BITDEFENDER; NN_LEGIT_S_SQARE_BRACKETS; NN_LEGIT_MAILING_LIST_TO], SGN: [Enabled, t: (0.008742)], URL: [Enabled, t: (0.000005)], RTDA: [Enabled, t: (0.021136), Hit: No, Details: v2.3.2; Id: 2m1ghak.1aah9g7ui.hi6q], total: 0(775) X-BitDefender-CF-Stamp: none Cc: Stefano Stabellini , Ian Campbell Subject: [Xen-devel] [PATCH v2] arm: p2m.c bug-fix: hypervisor hang on __p2m_get_mem_access X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When __p2m_get_mem_access gets called, the p2m lock is already taken by either get_page_from_gva or p2m_get_mem_access. Possible code paths: 1) -> get_page_from_gva -> p2m_mem_access_check_and_get_page -> __p2m_get_mem_access 2) -> p2m_get_mem_access -> __p2m_get_mem_access In both cases if __p2m_get_mem_access subsequently gets to call p2m_lookup (happens if !radix_tree_lookup(...)), a hypervisor hang will occur, since p2m_lookup also spin-locks on the p2m lock. This bug-fix simply replaces the p2m_lookup call from __p2m_get_mem_access with a call to __p2m_lookup and also adds an ASSERT to ensure that the p2m lock is already taken upon __p2m_get_mem_access entry. Signed-off-by: Corneliu ZUZU --- Changed since v1: * added p2m-lock ASSERT --- xen/arch/arm/p2m.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 2190908..e8e6db4 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -468,6 +468,8 @@ static int __p2m_get_mem_access(struct domain *d, gfn_t gfn, #undef ACCESS }; + ASSERT(spin_is_locked(&p2m->lock)); + /* If no setting was ever set, just return rwx. */ if ( !p2m->mem_access_enabled ) { @@ -490,7 +492,7 @@ static int __p2m_get_mem_access(struct domain *d, gfn_t gfn, * No setting was found in the Radix tree. Check if the * entry exists in the page-tables. */ - paddr_t maddr = p2m_lookup(d, gfn_x(gfn) << PAGE_SHIFT, NULL); + paddr_t maddr = __p2m_lookup(d, gfn_x(gfn) << PAGE_SHIFT, NULL); if ( INVALID_PADDR == maddr ) return -ESRCH;