From patchwork Fri Aug 11 14:21:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 9896095 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 8D52060325 for ; Fri, 11 Aug 2017 14:24:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F90A285F5 for ; Fri, 11 Aug 2017 14:24:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7482328BE5; Fri, 11 Aug 2017 14:24:39 +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 F2A16285F5 for ; Fri, 11 Aug 2017 14:24:38 +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 1dgAph-0006h4-MI; Fri, 11 Aug 2017 14:22:37 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgApg-0006g1-3h for xen-devel@lists.xenproject.org; Fri, 11 Aug 2017 14:22:36 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id EC/5C-03044-BADBD895; Fri, 11 Aug 2017 14:22:35 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeJIrShJLcpLzFFi42JxWrohUnfV3t5 Ig0f9Zhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa0b7xC7Wgp0CFbfuvGVsYDzN08XIySEh4C/R cegUM4jNJqAjMfXpJdYuRg4OEQEVidt7DUBMZoFyiY4JtSAVwgIBEruaP7KB2CwCqhLHV20E6 +QVsJHYtnMpI8REeYldbRdZQWxOAVuJ39sbwGwhoJqXJ19B2SoS66fOYoPoFZQ4OfMJC4jNLC AhcfDFC+YJjLyzkKRmIUktYGRaxahRnFpUllqka2Shl1SUmZ5RkpuYmaNraGCml5taXJyYnpq TmFSsl5yfu4kRGDgMQLCD8fzawEOMkhxMSqK8CT69kUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQk eFv3AOUEi1LTUyvSMnOAIQyTluDgURLhXQiS5i0uSMwtzkyHSJ1i1OV4NeH/NyYhlrz8vFQpc d7pIEUCIEUZpXlwI2DxdIlRVkqYlxHoKCGegtSi3MwSVPlXjOIcjErCvNogU3gy80rgNr0COo IJ6Ig+H7AjShIRUlINjP1b/2TIyxmxCF6YZ2SoYGSxvTIie9V04RVrBO4b7/y1mDnpQ7KM51H XqnkvjqtrPg98frj19W6X9Yr7p21XefyXm/U5O1vwpR/aJc0Nd5boNryx4eWaHzPXqCvkr7Pg v70/lxzSuGcmfugnl+eXjZFhIQ887utevLPl4Vqm2A/5cpWX3H57TlJiKc5INNRiLipOBACZe K3nogIAAA== X-Env-Sender: prvs=389ee98fb=Paul.Durrant@citrix.com X-Msg-Ref: server-13.tower-27.messagelabs.com!1502461353!101879906!1 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.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31231 invoked from network); 11 Aug 2017 14:22:34 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-13.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 11 Aug 2017 14:22:34 -0000 X-IronPort-AV: E=Sophos;i="5.41,358,1498521600"; d="scan'208";a="435186801" From: Paul Durrant To: Date: Fri, 11 Aug 2017 15:21:33 +0100 Message-ID: <20170811142143.35787-3-paul.durrant@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170811142143.35787-1-paul.durrant@citrix.com> References: <20170811142143.35787-1-paul.durrant@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Paul Durrant , Jan Beulich Subject: [Xen-devel] [PATCH v2 02/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 e44b298df1..d71dc5f16a 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -989,12 +989,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,