From patchwork Tue Sep 12 16:10:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 9949571 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 005C960360 for ; Tue, 12 Sep 2017 16:12:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E00B9283C3 for ; Tue, 12 Sep 2017 16:12:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D42F628599; Tue, 12 Sep 2017 16:12:33 +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 43A45283C3 for ; Tue, 12 Sep 2017 16:12:33 +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 1drnlc-0007SS-4h; Tue, 12 Sep 2017 16:10:28 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drnla-0007Nn-KZ for xen-devel@lists.xenproject.org; Tue, 12 Sep 2017 16:10:26 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id 8B/E9-30688-1F608B95; Tue, 12 Sep 2017 16:10:25 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjkeJIrShJLcpLzFFi42JxWrrBXvcN245 Ig54ecYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNaNh3xbWgt0CFYtmlDQwnuXpYuTkkBDwl9i/ djcTiM0moCMx9ekl1i5GDg4RARWJ23sNQExmgXKJjgm1IBXCAgES/R2bGUFsFgFVifUbJrCA2 LwCNhJ7f7WyQUyUl9jVdpEVxOYUsJW4d+ItWL0QUM2DF5uYIGwVifVTZ7FB9ApKnJz5BGwOs4 CExMEXL5gnMPLOQpKahSS1gJFpFaNGcWpRWWqRrqGxXlJRZnpGSW5iZo6uoYGpXm5qcXFiemp OYlKxXnJ+7iZGYNgwAMEOxn/bPA8xSnIwKYnyKt/fHinEl5SfUpmRWJwRX1Sak1p8iFGGg0NJ greRdUekkGBRanpqRVpmDjCAYdISHDxKIrx3WYDSvMUFibnFmekQqVOMuhwdN+/+YRJiycvPS 5US570MMkMApCijNA9uBCyaLjHKSgnzMgIdJcRTkFqUm1mCKv+KUZyDUUmYdzbIFJ7MvBK4Ta +AjmACOoLn0haQI0oSEVJSDYzc2ucnynbt8EvmXZFwLsHzx20Pvu176qRWaSUw/9//x+Bn2MN YfcXdwrO21DfoH59o+szb45a3t/jXB5wrnNhWnrkQe+EwW8H2Uxxm94/ntxe3t8y88me6sJq0 cu7RtLrtQjN2/K0PEWHfv2BhIwv7d7eJqx/wMp5fvHLafZ8X5zZMd08vqTuhxFKckWioxVxUn AgA1hGR2qECAAA= X-Env-Sender: prvs=421499f3a=Paul.Durrant@citrix.com X-Msg-Ref: server-16.tower-206.messagelabs.com!1505232618!91187079!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 41086 invoked from network); 12 Sep 2017 16:10:20 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-16.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 12 Sep 2017 16:10:20 -0000 X-IronPort-AV: E=Sophos;i="5.42,383,1500940800"; d="scan'208";a="447576635" From: Paul Durrant To: Date: Tue, 12 Sep 2017 17:10:04 +0100 Message-ID: <20170912161015.24948-2-paul.durrant@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170912161015.24948-1-paul.durrant@citrix.com> References: <20170912161015.24948-1-paul.durrant@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Paul Durrant , Jan Beulich Subject: [Xen-devel] [PATCH v6 01/12] x86/mm: allow a privileged PV domain to map guest mfns 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 In the case where a PV domain is mapping guest resources then it needs make the HYPERVISOR_mmu_update call using DOMID_SELF, rather than the guest domid, so that the passed in gmfn values are correctly treated as mfns rather than gfns present in the guest p2m. This patch removes a check which currently disallows mapping of a page when the owner of the page tables matches the domain passed to HYPERVISOR_mmu_update, but that domain is not the real owner of the page. The check was introduced by patch d3c6a215ca9 ("x86: Clean up get_page_from_l1e() to correctly distinguish between owner-of-pte and owner-of-data-page in all cases") but it's not clear why it was needed. Signed-off-by: Paul Durrant --- Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/mm.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 2e5b15e7a2..cb0189efae 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -1024,12 +1024,15 @@ get_page_from_l1e( (real_pg_owner != dom_cow) ) ) { /* - * Let privileged domains transfer the right to map their target - * domain's pages. This is used to allow stub-domain pvfb export to - * dom0, until pvfb supports granted mappings. At that time this - * minor hack can go away. + * If the real page owner is not the domain specified in the + * hypercall then establish that the specified domain has + * mapping privilege over the page owner. + * This is used to allow stub-domain pvfb export to dom0. It is + * also used to allow a privileged PV domain to map mfns using + * DOMID_SELF, which is needed for mapping guest resources such + * grant table frames. */ - if ( (real_pg_owner == NULL) || (pg_owner == l1e_owner) || + if ( (real_pg_owner == NULL) || xsm_priv_mapping(XSM_TARGET, pg_owner, real_pg_owner) ) { gdprintk(XENLOG_WARNING,