From patchwork Tue May 31 13:57:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Xu X-Patchwork-Id: 9144915 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 4D10060761 for ; Tue, 31 May 2016 14:05:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EC781FF27 for ; Tue, 31 May 2016 14:05:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3345F27B89; Tue, 31 May 2016 14:05:37 +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 9D6261FF27 for ; Tue, 31 May 2016 14:05:33 +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 1b7kGH-0000hw-HY; Tue, 31 May 2016 14:03:13 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b7kGG-0000g1-FH for xen-devel@lists.xen.org; Tue, 31 May 2016 14:03:12 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id AE/4C-25713-0A99D475; Tue, 31 May 2016 14:03:12 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNLMWRWlGSWpSXmKPExsXS1tYhoTt/pm+ 4waydJhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bxxj7mghsqFc+7PBoYP8p2MXJyCAlUSny/ NJ0ZxJYQ4JU4smwGK4TtL/Hg8ks2iJoaicYLk9hBbDYBFYkZze/AbBEBaYlrny8zdjFycTALz GeSuLu2A2yQsECexOnZj8GaWQRUJfbtPAnUwMHBK+Ag8Wh3EMR8BYllX9aClXMKOEpc6D/HBL HLQeLhl59MExh5FzAyrGJUL04tKkst0jXUSyrKTM8oyU3MzNE1NDDTy00tLk5MT81JTCrWS87 P3cQIDAQGINjBuPO50yFGSQ4mJVHeh9m+4UJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeD1nAOUE i1LTUyvSMnOAIQmTluDgURLhvQeS5i0uSMwtzkyHSJ1iVJQS500CSQiAJDJK8+DaYHFwiVFWS piXEegQIZ6C1KLczBJU+VeM4hyMSsK8fCBTeDLzSuCmvwJazAS0OD7DB2RxSSJCSqqBMe7IBY 87mXwrm+dd1tFSctrRbLvyb7rJkil7C56oTRQQ5Nt70evShOu/1dkfL9cQ7Kl5u7ZY3PjbA/u H/vKN6gW7jTLn6a09dFF9130eO49NZjeeNps4GSflfjtg0dPCWNaafPTD6q0F3FoOh/ZPu93g YFCbYuB5f2+HH3vK5J40sQqWh7ZVSizFGYmGWsxFxYkA2Sy1+X4CAAA= X-Env-Sender: quan.xu@intel.com X-Msg-Ref: server-2.tower-21.messagelabs.com!1464703385!2815320!4 X-Originating-IP: [134.134.136.24] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjQgPT4gMzkwOTcx\n X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 45391 invoked from network); 31 May 2016 14:03:11 -0000 Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by server-2.tower-21.messagelabs.com with SMTP; 31 May 2016 14:03:11 -0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP; 31 May 2016 07:01:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,395,1459839600"; d="scan'208";a="113439967" Received: from xen-commits.sh.intel.com ([10.239.82.178]) by fmsmga004.fm.intel.com with ESMTP; 31 May 2016 07:01:50 -0700 From: "Xu, Quan" To: xen-devel@lists.xen.org Date: Tue, 31 May 2016 21:57:28 +0800 Message-Id: <1464703056-4741-4-git-send-email-quan.xu@intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1464703056-4741-1-git-send-email-quan.xu@intel.com> References: <1464703056-4741-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 v6 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 Reviewed-by: Jan Beulich CC: Stefano Stabellini CC: Julien Grall CC: Kevin Tian CC: Feng Wu CC: Jan Beulich CC: Andrew Cooper --- 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 19ba976..73a7f1e 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);