From patchwork Wed May 18 08:08:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Xu X-Patchwork-Id: 9116731 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2FB0ABF29F for ; Wed, 18 May 2016 08:14:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 32E7220303 for ; Wed, 18 May 2016 08:14:27 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id BBA88202EC for ; Wed, 18 May 2016 08:14:25 +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 1b2wam-0004j1-8g; Wed, 18 May 2016 08:12:32 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b2wal-0004g1-5M for xen-devel@lists.xen.org; Wed, 18 May 2016 08:12:31 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id C7/49-03814-EE32C375; Wed, 18 May 2016 08:12:30 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrLLMWRWlGSWpSXmKPExsVywNykQvedsk2 4wYs5khZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bZm9sZCxarV3Qv2sXSwPhJvouRk0NIoEJi 89R3jCC2hACvxJFlM1i7GDmAbH+JI83eECU1Ei86toGVsAkoSmy4uJwJxBYRkJa49vkyUJyLg 1lgPpPE3bUdzCAJYYE4iW+Ln4HZLAKqEl2/NrOB2LwCjhL3Vi9ggdilILHsy1qwGk4BJ4kVCy ewQyxzlJi/fBrzBEbeBYwMqxg1ilOLylKLdA1N9ZKKMtMzSnITM3N0DQ2M9XJTi4sT01NzEpO K9ZLzczcxAoOBAQh2MK7Z7nmIUZKDSUmUd6u8TbgQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCd6b SkA5waLU9NSKtMwcYFjCpCU4eJREeE2AoSnEW1yQmFucmQ6ROsWoKCXOexukTwAkkVGaB9cGi 4VLjLJSwryMQIcI8RSkFuVmlqDKv2IU52BUEub9BzKFJzOvBG76K6DFTECLb4mBLS5JREhJNT DeTTubdEDKJESub0bOhTcXOoLMVx0KfruxoV/Q5qr7Mvt1MYVnrmQFvFjA/+dlJHOFlL0YY9y cfKFpjPLidQos178E1XX7hV2zvKX2NXVNbi0Xv6rfovVKnpMLjmhEtDi73Uv5ueZ4zYv4htyq m6He7DsdpkR7/1yhspqr7LFoTmvuqZ7UqUosxRmJhlrMRcWJAPwfPPOAAgAA X-Env-Sender: quan.xu@intel.com X-Msg-Ref: server-13.tower-31.messagelabs.com!1463559142!40094725!5 X-Originating-IP: [192.55.52.120] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27698 invoked from network); 18 May 2016 08:12:29 -0000 Received: from mga04.intel.com (HELO mga04.intel.com) (192.55.52.120) by server-13.tower-31.messagelabs.com with SMTP; 18 May 2016 08:12:29 -0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP; 18 May 2016 01:12:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,328,1459839600"; d="scan'208";a="979407896" Received: from xen-commits.sh.intel.com ([10.239.82.178]) by orsmga002.jf.intel.com with ESMTP; 18 May 2016 01:12:27 -0700 From: Quan Xu To: xen-devel@lists.xen.org Date: Wed, 18 May 2016 16:08:25 +0800 Message-Id: <1463558911-98187-5-git-send-email-quan.xu@intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1463558911-98187-1-git-send-email-quan.xu@intel.com> References: <1463558911-98187-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 v5 04/10] IOMMU: propagate IOMMU Device-TLB flush error up to IOMMU unmapping. 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Propagate the IOMMU Device-TLB flush error up to IOMMU unmapping. 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 | 18 ++++++++++-------- xen/include/asm-x86/hvm/svm/amd-iommu-proto.h | 2 +- xen/include/xen/iommu.h | 2 +- 4 files changed, 13 insertions(+), 11 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 3ece815..29fb7fd 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -616,11 +616,12 @@ 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; u64 pg_maddr; + int rc = 0; spin_lock(&hd->arch.mapping_lock); /* get last level pte */ @@ -628,7 +629,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); @@ -638,7 +639,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); @@ -646,9 +647,11 @@ static void dma_pte_clear_one(struct domain *domain, u64 addr) iommu_flush_cache_entry(pte, sizeof(struct dma_pte)); if ( !this_cpu(iommu_dont_flush_iotlb) ) - __intel_iommu_iotlb_flush(domain, addr >> PAGE_SHIFT_4K, 1, 1); + rc = __intel_iommu_iotlb_flush(domain, addr >> PAGE_SHIFT_4K, 1, 1); unmap_vtd_domain_page(page); + + return rc; } static void iommu_free_pagetable(u64 pt_maddr, int level) @@ -1775,15 +1778,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); } int 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);