From patchwork Tue Jul 18 10:34:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Dyasli X-Patchwork-Id: 9847693 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 0F2E2602C8 for ; Tue, 18 Jul 2017 10:36:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C4B128549 for ; Tue, 18 Jul 2017 10:36:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0125C2854A; Tue, 18 Jul 2017 10:36:48 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 969EF28550 for ; Tue, 18 Jul 2017 10:36:48 +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 1dXPpv-00066c-Up; Tue, 18 Jul 2017 10:34:39 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXPpu-00063O-Ie for xen-devel@lists.xen.org; Tue, 18 Jul 2017 10:34:38 +0000 Received: from [85.158.143.35] by server-4.bemta-6.messagelabs.com id 09/F3-02962-D34ED695; Tue, 18 Jul 2017 10:34:37 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAIsWRWlGSWpSXmKPExsXitHRDpK7tk9x Ig6Y7KhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8a2o+9ZC1bxV1y8MIW9gXETTxcjB4eEgL/E 3S6nLkZODjYBPYmNs18xgdgiArISq7vmsIPYzAKfmCQajjmC2MICzhJtp5cygtgsAqoSV+9PZ QGxeQVsJaa9Ww1WLyEgL7Gr7SIriM0pYCcx73knWI0QUM3qC7tYIWxVidcvdkH1CkqcnPmEBW KXhMTBFy+YJzDyzkKSmoUktYCRaRWjRnFqUVlqka6hpV5SUWZ6RkluYmaOrqGBmV5uanFxYnp qTmJSsV5yfu4mRmDoMADBDsYfywIOMUpyMCmJ8q4+kBspxJeUn1KZkVicEV9UmpNafIhRhoND SYL36COgnGBRanpqRVpmDjCIYdISHDxKIrxBj4HSvMUFibnFmekQqVOMuhyvJvz/xiTEkpefl yolzlsDMkMApCijNA9uBCyiLjHKSgnzMgIdJcRTkFqUm1mCKv+KUZyDUUmYdwvIFJ7MvBK4Ta +AjmACOkLYNwfkiJJEhJRUAyPLog1x3C3HN3Toq0mZb9FYXi76VlhQ+qvlyXWbje6cFFJTkdq 4c+26X+vqbOIvNe6Z78zI+K+g8LX1oo0iYu63wixfs4R/+uq9ag3TJtntnA6SMxpZN69Ne6i5 UoNz9iXXlWbppgeVZ+XWf5K9cuCf6PSkm+tZ1Rdp5nV/iOl09LSrctIrllNiKc5INNRiLipOB AC9tCzKowIAAA== X-Env-Sender: prvs=365bef495=sergey.dyasli@citrix.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1500374074!70287400!3 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17856 invoked from network); 18 Jul 2017 10:34:37 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-3.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 18 Jul 2017 10:34:37 -0000 X-IronPort-AV: E=Sophos;i="5.40,377,1496102400"; d="scan'208";a="431880763" From: Sergey Dyasli To: Date: Tue, 18 Jul 2017 11:34:25 +0100 Message-ID: <20170718103429.25020-9-sergey.dyasli@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170718103429.25020-1-sergey.dyasli@citrix.com> References: <20170718103429.25020-1-sergey.dyasli@citrix.com> MIME-Version: 1.0 Cc: Sergey Dyasli , Kevin Tian , Jun Nakajima , George Dunlap , Andrew Cooper , Tim Deegan , Jan Beulich , Boris Ostrovsky , Suravee Suthikulpanit Subject: [Xen-devel] [PATCH RFC 08/12] x86/np2m: add p2m_get_nestedp2m_locked() 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The new function returns still write-locked np2m. Signed-off-by: Sergey Dyasli --- xen/arch/x86/mm/p2m.c | 12 +++++++++--- xen/include/asm-x86/p2m.h | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 4b83d4a4f1..364fdd8c13 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -1824,7 +1824,7 @@ static void nvcpu_flush(struct vcpu *v) } struct p2m_domain * -p2m_get_nestedp2m(struct vcpu *v) +p2m_get_nestedp2m_locked(struct vcpu *v) { struct nestedvcpu *nv = &vcpu_nestedhvm(v); struct domain *d = v->domain; @@ -1849,7 +1849,6 @@ p2m_get_nestedp2m(struct vcpu *v) nvcpu_flush(v); p2m->np2m_base = np2m_base; assign_np2m(v, p2m); - p2m_unlock(p2m); nestedp2m_unlock(d); return p2m; @@ -1865,12 +1864,19 @@ p2m_get_nestedp2m(struct vcpu *v) p2m->np2m_base = np2m_base; nvcpu_flush(v); assign_np2m(v, p2m); - p2m_unlock(p2m); nestedp2m_unlock(d); return p2m; } +struct p2m_domain *p2m_get_nestedp2m(struct vcpu *v) +{ + struct p2m_domain *p2m = p2m_get_nestedp2m_locked(v); + p2m_unlock(p2m); + + return p2m; +} + struct p2m_domain * p2m_get_p2m(struct vcpu *v) { diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 801a11a960..936d1142c8 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -364,6 +364,8 @@ struct p2m_domain { * Updates vCPU's n2pm to match its EPTP in VMCS12 and returns that np2m. */ struct p2m_domain *p2m_get_nestedp2m(struct vcpu *v); +/* Similar to the above except that returned p2m is still write-locked */ +struct p2m_domain *p2m_get_nestedp2m_locked(struct vcpu *v); /* If vcpu is in host mode then behaviour matches p2m_get_hostp2m(). * If vcpu is in guest mode then behaviour matches p2m_get_nestedp2m().