From patchwork Tue Aug 22 14:50:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 9915449 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 9386B603F9 for ; Tue, 22 Aug 2017 14:54:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68F4428898 for ; Tue, 22 Aug 2017 14:54:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C241288A2; Tue, 22 Aug 2017 14:54:17 +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 BC62C28898 for ; Tue, 22 Aug 2017 14:54:15 +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 1dkAX1-0002P3-Op; Tue, 22 Aug 2017 14:51:51 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dkAX0-0002OA-DI for xen-devel@lists.xenproject.org; Tue, 22 Aug 2017 14:51:50 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id A3/6A-03557-5054C995; Tue, 22 Aug 2017 14:51:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpikeJIrShJLcpLzFFi42JxWrohUpfVdU6 kweTtvBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8b3fb9YCnYKVPR0/mBrYDzN08XIySEh4C/x 9MMqdhCbTUBHYurTS6xdjBwcIgIqErf3GoCYzALlEh0TakEqhAXCJc4++McCYrMIqEr0N81mB bF5BawlVj5awAgxUV5iV9tFsDingI3Ew0MTWEDGCAHV3LoeCBIWAhq+fuosNohWQYmTM5+AjW QWkJA4+OIF8wRG3llIUrOQpBYwMq1i1ChOLSpLLdI1NtJLKspMzyjJTczM0TU0MNPLTS0uTkx PzUlMKtZLzs/dxAgMGwYg2MF4el3gIUZJDiYlUd7J32dHCvEl5adUZiQWZ8QXleakFh9ilOHg UJLgne88J1JIsCg1PbUiLTMHGMAwaQkOHiUR3lCQNG9xQWJucWY6ROoUo6KUOK8HSEIAJJFRm gfXBouaS4yyUsK8jECHCPEUpBblZpagyr9iFOdgVBLmLQCZwpOZVwI3/RXQYiagxYat00AWly QipKQaGDn+vYme3PxQ7W6dq8g9x4dTrj6xYL6axPM6LrClyeH1Tucnp5mW5OqfrWTxnPNh6bp H76dNyD7qtkIgWvz9E7G4PK64KgmZdwv8PkbIbHOO+M8h9JZDoVPBsqzfmPe0CVdD+eO+wm55 C7VlBwrnCR8KaH9iXTRjoq7gBVYzkaCmftm6+c9nKrEUZyQaajEXFScCAKdYEwqVAgAA X-Env-Sender: prvs=40066d99f=Paul.Durrant@citrix.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1503413507!60068124!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 12345 invoked from network); 22 Aug 2017 14:51:48 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-15.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 22 Aug 2017 14:51:48 -0000 X-IronPort-AV: E=Sophos;i="5.41,412,1498521600"; d="scan'208";a="436412957" From: Paul Durrant To: Date: Tue, 22 Aug 2017 15:50:56 +0100 Message-ID: <20170822145107.6877-3-paul.durrant@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170822145107.6877-1-paul.durrant@citrix.com> References: <20170822145107.6877-1-paul.durrant@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Paul Durrant , Jan Beulich Subject: [Xen-devel] [PATCH v2 REPOST 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 0abb1e284f..aaa9ff5197 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,