From patchwork Wed Jun 8 08:58:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Xu X-Patchwork-Id: 9163733 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 D2F376088F for ; Wed, 8 Jun 2016 09:05:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2D7228345 for ; Wed, 8 Jun 2016 09:05:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B79A72838F; Wed, 8 Jun 2016 09:05:38 +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 AAC5128345 for ; Wed, 8 Jun 2016 09:05:37 +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 1bAZOg-00044s-60; Wed, 08 Jun 2016 09:03:34 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAZOe-000445-IO for xen-devel@lists.xen.org; Wed, 08 Jun 2016 09:03:32 +0000 Received: from [193.109.254.147] by server-4.bemta-14.messagelabs.com id 26/98-09542-36FD7575; Wed, 08 Jun 2016 09:03:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRWlGSWpSXmKPExsVywNwkQjfpfni 4wcYWKYslHxezODB6HN39mymAMYo1My8pvyKBNaPrxVamgsOqFbtm/WNtYDwq18XIySEkUCmx 9NdCJhBbQoBX4siyGawQtr/ExR/fWCBqaiROXH0MZrMJqEjMaH7HDmKLCEhLXPt8mbGLkYuDW WA+k8TdtR3MIAlhgTyJdVu3sYHYLAKqEovO7AGL8wo4Srz+3cAGsUBBYtmXtUBxDg5OASeJrc dKIXY5Smzb/YRlAiPvAkaGVYzqxalFZalFumZ6SUWZ6RkluYmZObqGhiZ6uanFxYnpqTmJScV 6yfm5mxiBocAABDsY/05wPsQoycGkJMqr6B4eLsSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mCt/Ye UE6wKDU9tSItMwcYlDBpCQ4eJRFeKZA0b3FBYm5xZjpE6hSjopQ4ryhIQgAkkVGaB9cGi4RLj LJSwryMQIcI8RSkFuVmlqDKv2IU52BUEuYNA5nCk5lXAjf9FdBiJqDFy4+ALS5JREhJNTBWbD yyt+VWlGe/ns3srR4Hn7/PUDkYaCy4Lfzy8pMHja7+VzJofbijSNA4gVn0kynbbwW15gK+JM+ ulgtrX6uWr8o6feSflKGCylpF3v+hTiZnZr0qd+iN/qGmv4EzqLK4QuByen9KvdnnXN8WwXM7 P6/t+xa1cO/pDV82SOQwnLtm876+wU+JpTgj0VCLuag4EQAwB0QZfwIAAA== X-Env-Sender: quan.xu@intel.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1465376607!46437496!2 X-Originating-IP: [192.55.52.88] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTkyLjU1LjUyLjg4ID0+IDM3NDcyNQ==\n X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27634 invoked from network); 8 Jun 2016 09:03:29 -0000 Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by server-9.tower-27.messagelabs.com with SMTP; 8 Jun 2016 09:03:29 -0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 08 Jun 2016 02:03:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,438,1459839600"; d="scan'208";a="983223896" Received: from xen-commits.sh.intel.com ([10.239.82.178]) by fmsmga001.fm.intel.com with ESMTP; 08 Jun 2016 02:03:27 -0700 From: "Xu, Quan" To: xen-devel@lists.xen.org Date: Wed, 8 Jun 2016 16:58:56 +0800 Message-Id: <1465376344-28290-4-git-send-email-quan.xu@intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1465376344-28290-1-git-send-email-quan.xu@intel.com> References: <1465376344-28290-1-git-send-email-quan.xu@intel.com> Cc: Kevin Tian , Stefano Stabellini , Feng Wu , Jan Beulich , Andrew Cooper , dario.faggioli@citrix.com, Julien Grall , Quan Xu Subject: [Xen-devel] [PATCH v7 03/11] IOMMU: propagate IOMMU Device-TLB flush error up to IOMMU unmapping (top level ones) 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Quan Xu Signed-off-by: Quan Xu Acked-by: Kevin Tian CC: Stefano Stabellini CC: Julien Grall CC: Kevin Tian CC: Feng Wu CC: Jan Beulich CC: Andrew Cooper v7: just drop 'Reviewed-by: Jan Beulich ', as I haven't added __must_check annotation to iommu_unmap_page() in previous v6. Reviewed-by: Jan Beulich Acked-by: Julien Grall Acked-by: Suravee Suthikulpanit --- xen/drivers/passthrough/arm/smmu.c | 2 +- xen/drivers/passthrough/vtd/iommu.c | 15 ++++++++------- xen/include/asm-x86/hvm/svm/amd-iommu-proto.h | 2 +- xen/include/xen/iommu.h | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c index 54a03a6..1ce4ddf 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -2774,7 +2774,7 @@ static int arm_smmu_map_page(struct domain *d, unsigned long gfn, return guest_physmap_add_entry(d, gfn, mfn, 0, t); } -static int arm_smmu_unmap_page(struct domain *d, unsigned long gfn) +static int __must_check arm_smmu_unmap_page(struct domain *d, unsigned long gfn) { /* * This function should only be used by gnttab code when the domain diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index db83949..4844193 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -609,7 +609,7 @@ static void intel_iommu_iotlb_flush_all(struct domain *d) } /* clear one page's page table */ -static void dma_pte_clear_one(struct domain *domain, u64 addr) +static int __must_check dma_pte_clear_one(struct domain *domain, u64 addr) { struct domain_iommu *hd = dom_iommu(domain); struct dma_pte *page = NULL, *pte = NULL; @@ -621,7 +621,7 @@ static void dma_pte_clear_one(struct domain *domain, u64 addr) if ( pg_maddr == 0 ) { spin_unlock(&hd->arch.mapping_lock); - return; + return 0; } page = (struct dma_pte *)map_vtd_domain_page(pg_maddr); @@ -631,7 +631,7 @@ static void dma_pte_clear_one(struct domain *domain, u64 addr) { spin_unlock(&hd->arch.mapping_lock); unmap_vtd_domain_page(page); - return; + return 0; } dma_clear_pte(*pte); @@ -642,6 +642,8 @@ static void dma_pte_clear_one(struct domain *domain, u64 addr) __intel_iommu_iotlb_flush(domain, addr >> PAGE_SHIFT_4K, 1, 1); unmap_vtd_domain_page(page); + + return 0; } static void iommu_free_pagetable(u64 pt_maddr, int level) @@ -1739,15 +1741,14 @@ static int intel_iommu_map_page( return 0; } -static int intel_iommu_unmap_page(struct domain *d, unsigned long gfn) +static int __must_check intel_iommu_unmap_page(struct domain *d, + unsigned long gfn) { /* Do nothing if hardware domain and iommu supports pass thru. */ if ( iommu_passthrough && is_hardware_domain(d) ) return 0; - dma_pte_clear_one(d, (paddr_t)gfn << PAGE_SHIFT_4K); - - return 0; + return dma_pte_clear_one(d, (paddr_t)gfn << PAGE_SHIFT_4K); } void iommu_pte_flush(struct domain *d, u64 gfn, u64 *pte, diff --git a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h index 9c51172..57b6cc1 100644 --- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h +++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h @@ -53,7 +53,7 @@ int amd_iommu_update_ivrs_mapping_acpi(void); /* mapping functions */ int amd_iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn, unsigned int flags); -int amd_iommu_unmap_page(struct domain *d, unsigned long gfn); +int __must_check amd_iommu_unmap_page(struct domain *d, unsigned long gfn); u64 amd_iommu_get_next_table_from_pte(u32 *entry); int amd_iommu_reserve_domain_unity_map(struct domain *domain, u64 phys_addr, unsigned long size, diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index eaa2c77..f45fa5a 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -168,7 +168,7 @@ struct iommu_ops { void (*teardown)(struct domain *d); int (*map_page)(struct domain *d, unsigned long gfn, unsigned long mfn, unsigned int flags); - int (*unmap_page)(struct domain *d, unsigned long gfn); + int __must_check (*unmap_page)(struct domain *d, unsigned long gfn); void (*free_page_table)(struct page_info *); #ifdef CONFIG_X86 void (*update_ire_from_apic)(unsigned int apic, unsigned int reg, unsigned int value);