From patchwork Thu Aug 31 09:35:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 9931649 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 E8476603B5 for ; Thu, 31 Aug 2017 09:38:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB7CC28884 for ; Thu, 31 Aug 2017 09:38:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE4C4288D9; Thu, 31 Aug 2017 09:38:40 +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 EA6AD288E2 for ; Thu, 31 Aug 2017 09:38:39 +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 1dnLtY-00066t-Pc; Thu, 31 Aug 2017 09:36:16 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dnLtX-00066Y-Tx for xen-devel@lists.xenproject.org; Thu, 31 Aug 2017 09:36:16 +0000 Received: from [85.158.139.211] by server-10.bemta-5.messagelabs.com id FC/70-01778-F88D7A95; Thu, 31 Aug 2017 09:36:15 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkkeJIrShJLcpLzFFi42JxWrrBXrfvxvJ Ig5ZpKhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bGLa8YC3YLVDRc6mVsYDzL08XIwSEh4C/x /WRSFyMnB5uAjsTUp5dYQcIiAioSt/cagJjMAuUSHRNqQUxhgQCJzwcCQIpZBFQl5l88zwxi8 wpYS/x8Op8dxJYQkJfY1XaRFcTmFLCRWLKogRHEFgKqObRyGTOErSKxfuosNoheQYmTM5+wgN jMAhISB1+8YJ7AyDsLSWoWktQCRqZVjBrFqUVlqUW6RsZ6SUWZ6RkluYmZObqGBqZ6uanFxYn pqTmJScV6yfm5mxiBQVPPwMC4g3FHu98hRkkOJiVR3rALyyOF+JLyUyozEosz4otKc1KLDzHK cHAoSfAKXAfKCRalpqdWpGXmAMMXJi3BwaMkwpsLkuYtLkjMLc5Mh0idYlSUEuc9fw0oIQCSy CjNg2uDxcwlRlkpYV5GBgYGIZ6C1KLczBJU+VeM4hyMSsK81SDjeTLzSuCmvwJazAS0ONZrKc jikkSElFQDo/rpgyWz6if/6XliPf+YsOjUhjPP/yoXRRjovt5tMnHW2dLgtt0B3/UX/7zxQfq C5L7ZbcGL5981uB9440/G4lqv/xPD/b42y3GeX/TrzskZ8l2Bwh9igpdMq5F+6HFqeega1ilb v0zar//r1V/hwsote1bM6a1daTrprc7r77NqmJc6ZR2ZfsNfiaU4I9FQi7moOBEAvcXK15QCA AA= X-Env-Sender: prvs=4091fd0e1=Paul.Durrant@citrix.com X-Msg-Ref: server-9.tower-206.messagelabs.com!1504172172!109811052!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 39529 invoked from network); 31 Aug 2017 09:36:14 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-9.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 31 Aug 2017 09:36:14 -0000 X-IronPort-AV: E=Sophos;i="5.41,451,1498521600"; d="scan'208";a="446032829" From: Paul Durrant To: Date: Thu, 31 Aug 2017 10:35:54 +0100 Message-ID: <20170831093605.2757-2-paul.durrant@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170831093605.2757-1-paul.durrant@citrix.com> References: <20170831093605.2757-1-paul.durrant@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Paul Durrant , Jan Beulich Subject: [Xen-devel] [PATCH v3 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 e339987c01..6ffbea794b 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -1002,12 +1002,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,