From patchwork Thu Oct 19 15:24:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 10017543 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 B46C9600CC for ; Thu, 19 Oct 2017 15:27:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0156287C0 for ; Thu, 19 Oct 2017 15:27:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 919E42881A; Thu, 19 Oct 2017 15:27: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 19703286E7 for ; Thu, 19 Oct 2017 15:27: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 1e5ChW-0005hW-NG; Thu, 19 Oct 2017 15:25:38 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e5ChV-0005hH-QV for xen-devel@lists.xenproject.org; Thu, 19 Oct 2017 15:25:37 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id FB/88-14867-1F3C8E95; Thu, 19 Oct 2017 15:25:37 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDLMWRWlGSWpSXmKPExsXitHSDve6Hwy8 iDTZv1bT4vmUykwOjx+EPV1gCGKNYM/OS8isSWDPmH7nMWHBUsOL+vzXMDYz3+boYOTgkBPwl tq9k62Lk5GAT0JGY+vQSK0hYRCBcYuLXSpAws4CWRMPEJUwgtrCAq8Sn/XNYQGwWAVWJr/O3s YOU8wrYSDQt1AEJSwjIS+xqu8gKYgsJqEisnzoLbDqvgKDEyZlPWCBGSkgcfPGCeQIj9ywkqV lIUgsYmVYxahSnFpWlFukaG+klFWWmZ5TkJmbm6BoamOnlphYXJ6an5iQmFesl5+duYgSGAQM Q7GA8vS7wEKMkB5OSKO/bgy8ihfiS8lMqMxKLM+KLSnNSiw8xynBwKEnw5h4CygkWpaanVqRl 5gADEiYtwcGjJMJrCZLmLS5IzC3OTIdInWI05ji26fIfJo6Om3f/MAmx5OXnpUqJ83aBlAqAl GaU5sENgkXKJUZZKWFeRqDThHgKUotyM0tQ5V8xinMwKgnzeoJM4cnMK4Hb9wroFCagU9jtwU 4pSURISTUw6i6e8ctMOyOyeW2moG7sGZcflWc2m5y4kFCmsYN1fXL5oZy8YI99IdNibXMuKzw KPpUyX1C27KmBMsfjqaXzvHXLbY9P4Zg2YcunaW4Hnt/Qcz6jsar1zS1z2YSvd2YFas7tWzYl 7XKBw+xFTQvYg+0Xm4U8nZN16MzExCml+/4sELsptuNUhBJLcUaioRZzUXEiACFu7JePAgAA X-Env-Sender: prvs=458424478=Paul.Durrant@citrix.com X-Msg-Ref: server-16.tower-27.messagelabs.com!1508426734!112123675!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 65118 invoked from network); 19 Oct 2017 15:25:36 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-16.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 19 Oct 2017 15:25:36 -0000 X-IronPort-AV: E=Sophos;i="5.43,402,1503360000"; d="scan'208";a="455039919" From: Paul Durrant To: , , Date: Thu, 19 Oct 2017 16:24:20 +0100 Message-ID: <20171019152420.38389-1-paul.durrant@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Cc: Paul Durrant Subject: [Xen-devel] [PATCH] x86/xen: support priv-mapping in an HVM tools domain 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 If the domain has XENFEAT_auto_translated_physmap then use of the PV- specific HYPERVISOR_mmu_update hypercall is clearly incorrect. This patch adds checks in xen_remap_domain_gfn_array() and xen_unmap_domain_gfn_array() which call through to the approprate xlate_mmu function if the feature is present. A check is also added to xen_remap_domain_gfn_range() to fail with -EOPNOTSUPP since this should not be used in an HVM tools domain. Signed-off-by: Paul Durrant --- Boris Ostrovsky Juergen Gross Thomas Gleixner Ingo Molnar "H. Peter Anvin" --- arch/x86/xen/mmu.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index 3e15345abfe7..d33e7dbe3129 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c @@ -172,6 +172,9 @@ int xen_remap_domain_gfn_range(struct vm_area_struct *vma, pgprot_t prot, unsigned domid, struct page **pages) { + if (xen_feature(XENFEAT_auto_translated_physmap)) + return -EOPNOTSUPP; + return do_remap_gfn(vma, addr, &gfn, nr, NULL, prot, domid, pages); } EXPORT_SYMBOL_GPL(xen_remap_domain_gfn_range); @@ -182,6 +185,10 @@ int xen_remap_domain_gfn_array(struct vm_area_struct *vma, int *err_ptr, pgprot_t prot, unsigned domid, struct page **pages) { + if (xen_feature(XENFEAT_auto_translated_physmap)) + return xen_xlate_remap_gfn_array(vma, addr, gfn, nr, err_ptr, + prot, domid, pages); + /* We BUG_ON because it's a programmer error to pass a NULL err_ptr, * and the consequences later is quite hard to detect what the actual * cause of "wrong memory was mapped in". @@ -193,9 +200,12 @@ EXPORT_SYMBOL_GPL(xen_remap_domain_gfn_array); /* Returns: 0 success */ int xen_unmap_domain_gfn_range(struct vm_area_struct *vma, - int numpgs, struct page **pages) + int nr, struct page **pages) { - if (!pages || !xen_feature(XENFEAT_auto_translated_physmap)) + if (xen_feature(XENFEAT_auto_translated_physmap)) + return xen_xlate_unmap_gfn_range(vma, nr, pages); + + if (!pages) return 0; return -EINVAL;