From patchwork Wed Aug 10 15:00:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamas Lengyel X-Patchwork-Id: 9273159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 45F2960231 for ; Wed, 10 Aug 2016 15:03:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35D9F27E22 for ; Wed, 10 Aug 2016 15:03:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A9C82841E; Wed, 10 Aug 2016 15:03:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 166D027E22 for ; Wed, 10 Aug 2016 15:03:18 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bXUzX-0006Gb-EZ; Wed, 10 Aug 2016 15:00:23 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bXUzV-0006GO-Ia for xen-devel@lists.xenproject.org; Wed, 10 Aug 2016 15:00:21 +0000 Received: from [85.158.143.35] by server-7.bemta-6.messagelabs.com id D3/68-15404-4814BA75; Wed, 10 Aug 2016 15:00:20 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprKIsWRWlGSWpSXmKPExsVyMfSas26L4+p wg613uCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1owH96YyF+wVqjhxpZmpgbGXr4uRk0NIYAaj xLITwl2MXBwsAm9YJF69Pc4O4kgIvGORODC1nxWkSkIgRuLEqW0sEHa5xNnn3cwQ3ZoSBzecY QZpEBKYwCTRsHAFWAObgJHE1as9bCC2iICSxL1Vk5lAipgFrjBKfDt1gR0kISwQKrF28kmwqS wCqhKLHk0Em8or4CWxd/98dohtchKXpz9gm8DIt4CRYRWjRnFqUVlqka6hhV5SUWZ6RkluYma OrqGBmV5uanFxYnpqTmJSsV5yfu4mRmCwMADBDsabGwMOMUpyMCmJ8nqrrg4X4kvKT6nMSCzO iC8qzUktPsQow8GhJMFb4QCUEyxKTU+tSMvMAYYtTFqCg0dJhLcaJM1bXJCYW5yZDpE6xWjJs eX3tbVMHFsW3ACS26beW8skxJKXn5cqJc7rC9IgANKQUZoHNw4WW5cYZaWEeRmBDhTiKUgtys 0sQZV/xSjOwagkzDsPZApPZl4J3NZXQAcxAR2UpLoC5KCSRISUVAOjUHdccabNpawn2Se4f93 wEnuibdbWrcol5sfJWDM1+tN17RnFDFzf35e06oaZs++ITV1Vn7x2Fot70T2x3RHaLvXV7aYN s6YVfplaYXHKsuApx1nhe/qNIlOYmB7Wr4jrv9VffsLn4tODNlqBSi+ZLqjUzm9KU593UEmio WF5x74eu1RNZyWW4oxEQy3mouJEAD5DUZ+oAgAA X-Env-Sender: tamas.lengyel@zentific.com X-Msg-Ref: server-15.tower-21.messagelabs.com!1470841219!27895025!1 X-Originating-IP: [209.85.214.67] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 41092 invoked from network); 10 Aug 2016 15:00:20 -0000 Received: from mail-it0-f67.google.com (HELO mail-it0-f67.google.com) (209.85.214.67) by server-15.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 10 Aug 2016 15:00:20 -0000 Received: by mail-it0-f67.google.com with SMTP id j124so3190229ith.3 for ; Wed, 10 Aug 2016 08:00:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zentific-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=s3pVqd8vhfVMJdQQRyRYZAOsCJ/3c19dtFkQpipfyKo=; b=xoLwioqJWkNMdDooCeOKK86M9HNFYcuZ9ZE/e8RvBYCuwrwPenWxa87lLRmxrAjEN2 vyp+UJepN4LVCWXLZklJ3aU5ViPAdEfi2SZs+2W+I6o8GvhRByLyeEjjUncFT8UtiZIa zRMBUGfyBaCmk9ZP2GPNeOsQ6ko29wH2JmX+S/obOiim+IFybt3OyLoli8mZ19RY5/Lb BEVXapZbbIo1iJdRNOCvFYo1tCEzrvJtUu3nTvsb11j1Un13vVnbJDZLnKeeBBW14Gyj OiZpVwu81AYNqZVNll6p/saxhG6GNLRVb+QcNfpr/vLWkiaPDCL+fRumppwNJxF9W+66 qtqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=s3pVqd8vhfVMJdQQRyRYZAOsCJ/3c19dtFkQpipfyKo=; b=VpUQj5XZ7fWY0GYLB7A0SWN4P2UbTVwDr+aGDqEbj1bpEpbM1ywlk+Bc/OdbR3p/ae bETPDyNnap4MkrXlsHBD2A2hOXZZdoXI42a6eiLqgpktARBeq8NZwv5KTJByfvsNwyA9 TCGnLorxWogbk9XfDFXgG9AEivjOeoMnkLg03QLc3XCovgdPhqOGoYcLtzYtHk9X1ddJ DalB/JcZMHZ/VjBr1AYSa1waSgFfFZ5SQtcFLhGiNAEi2AdTU1Z1ngiwIdexA+KHTOWm WuRCeWC9JBBxPFlhUaVKinJBSRULtZDaBr3tprs00x6KNDgE3XVyqAqbNFVcBXgut9c7 s6AA== X-Gm-Message-State: AEkoouvlRYgWHwLrYfdE1bD3dhB7UIjgZlIo4+t3Ji0KGQTKQFQxWVyD3LJhdOUHGz6eow== X-Received: by 10.36.70.14 with SMTP id j14mr4041520itb.47.1470841218445; Wed, 10 Aug 2016 08:00:18 -0700 (PDT) Received: from l1.lan (c-73-14-35-59.hsd1.co.comcast.net. [73.14.35.59]) by smtp.gmail.com with ESMTPSA id b66sm4095916itd.0.2016.08.10.08.00.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Aug 2016 08:00:17 -0700 (PDT) From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Date: Wed, 10 Aug 2016 09:00:14 -0600 Message-Id: <1470841215-24450-1-git-send-email-tamas.lengyel@zentific.com> X-Mailer: git-send-email 2.8.1 Cc: George Dunlap , Tamas K Lengyel , Tamas K Lengyel , Jan Beulich , Andrew Cooper Subject: [Xen-devel] [PATCH v2 1/2] x86/altp2m: use __get_gfn_type_access to avoid lock conflicts 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" X-Virus-Scanned: ClamAV using ClamSMTP From: Tamas K Lengyel Use __get_gfn_type_access instead of get_gfn_type_access when checking the hostp2m entries during altp2m mem_access setting and gfn remapping to avoid a lock conflict which can make dom0 freeze. During mem_access setting the hp2m is already locked. For gfn remapping we change the flow to lock the hp2m before locking the ap2m. Signed-off-by: Tamas K Lengyel Reviewed-by: Razvan Cojocaru Reviewed-by: Jan Beulich Acked-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper v2: Lock the hp2m during gfn remapping --- xen/arch/x86/mm/p2m.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 812dbf6..1eeb934 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -1787,8 +1787,8 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m, if ( !mfn_valid(mfn) ) { - mfn = get_gfn_type_access(hp2m, gfn_l, &t, &old_a, - P2M_ALLOC | P2M_UNSHARE, &page_order); + mfn = __get_gfn_type_access(hp2m, gfn_l, &t, &old_a, + P2M_ALLOC | P2M_UNSHARE, &page_order, 0); rc = -ESRCH; if ( !mfn_valid(mfn) || t != p2m_ram_rw ) @@ -2548,6 +2548,7 @@ int p2m_change_altp2m_gfn(struct domain *d, unsigned int idx, hp2m = p2m_get_hostp2m(d); ap2m = d->arch.altp2m_p2m[idx]; + p2m_lock(hp2m); p2m_lock(ap2m); mfn = ap2m->get_entry(ap2m, gfn_x(old_gfn), &t, &a, 0, NULL, NULL); @@ -2563,8 +2564,8 @@ int p2m_change_altp2m_gfn(struct domain *d, unsigned int idx, /* Check host p2m if no valid entry in alternate */ if ( !mfn_valid(mfn) ) { - mfn = get_gfn_type_access(hp2m, gfn_x(old_gfn), &t, &a, - P2M_ALLOC | P2M_UNSHARE, &page_order); + mfn = __get_gfn_type_access(hp2m, gfn_x(old_gfn), &t, &a, + P2M_ALLOC | P2M_UNSHARE, &page_order, 0); if ( !mfn_valid(mfn) || t != p2m_ram_rw ) goto out; @@ -2606,6 +2607,7 @@ int p2m_change_altp2m_gfn(struct domain *d, unsigned int idx, out: p2m_unlock(ap2m); + p2m_unlock(hp2m); return rc; }