From patchwork Wed May 18 08:08:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Xu X-Patchwork-Id: 9116741 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1DC789F37F 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 2B755202AE 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 ECA55202F0 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 1b2wap-0004lY-Gi; Wed, 18 May 2016 08:12:35 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b2wao-0004kY-5X for xen-devel@lists.xen.org; Wed, 18 May 2016 08:12:34 +0000 Received: from [85.158.137.68] by server-16.bemta-3.messagelabs.com id 9C/66-06460-1F32C375; Wed, 18 May 2016 08:12:33 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRWlGSWpSXmKPExsVywNykQveDsk2 4wYHr5hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aq/lXsBStVKp7sPcPcwHhfqouRk0NIoEJi 0ZOTbCC2hACvxJFlM1ghbH+JznVLGSFqaiT+ff/ODmKzCShKbLi4nAnEFhGQlrj2+TJQDRcHs 8BqJomZjy+DFQkLxEh8P7cBbBCLgKrEm5/fwGxeAUeJ/6dvQS1QkFj2ZS0ziM0p4CSxYuEEdo hljhLzl09jnsDIu4CRYRWjRnFqUVlqka6hqV5SUWZ6RkluYmaOrqGBsV5uanFxYnpqTmJSsV5 yfu4mRmA4MADBDsY12z0PMUpyMCmJ8m6VtwkX4kvKT6nMSCzOiC8qzUktPsQow8GhJMF7Uwko J1iUmp5akZaZAwxMmLQEB4+SCK8JMDiFeIsLEnOLM9MhUqcYdTm2LLixlkmIJS8/L1VKnPc2y AwBkKKM0jy4EbAoucQoKyXMywh0lBBPQWpRbmYJqvwrRnEORiVh3n8gU3gy80rgNr0COoIJ6I hbYmBHlCQipKQaGJ80r/xcUXzm1gQeifrKVb72Xh+DJfua8qx75zlIeHO84/zx0z861s9gwtl XwTG72/Rtz7059KBywf+A5JTcvaKxVz4s8bD5VMUcltn3ZuIJs/Ipmw20Dk6aYaQYMPuPWJN5 /LwjTeVmr2/te/ryn56k25xFOzYsFX/X9/w/u7damYetekhSpBJLcUaioRZzUXEiAK5Gi0yNA gAA X-Env-Sender: quan.xu@intel.com X-Msg-Ref: server-13.tower-31.messagelabs.com!1463559142!40094725!6 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 28132 invoked from network); 18 May 2016 08:12:32 -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:32 -0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP; 18 May 2016 01:12:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,328,1459839600"; d="scan'208";a="979407921" Received: from xen-commits.sh.intel.com ([10.239.82.178]) by orsmga002.jf.intel.com with ESMTP; 18 May 2016 01:12:29 -0700 From: Quan Xu To: xen-devel@lists.xen.org Date: Wed, 18 May 2016 16:08:26 +0800 Message-Id: <1463558911-98187-6-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 , Quan Xu , dario.faggioli@citrix.com, Julien Grall , Jan Beulich , Suravee Suthikulpanit Subject: [Xen-devel] [PATCH v5 05/10] IOMMU: propagate IOMMU Device-TLB flush error up to IOMMU mapping. 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 mapping. Signed-off-by: Quan Xu Acked-by: Kevin Tian CC: Suravee Suthikulpanit CC: Stefano Stabellini CC: Julien Grall CC: Kevin Tian CC: Feng Wu CC: Jan Beulich --- xen/drivers/passthrough/amd/pci_amd_iommu.c | 17 +++++++++++++++-- xen/drivers/passthrough/arm/smmu.c | 4 ++-- xen/drivers/passthrough/vtd/iommu.c | 12 +++++++----- xen/include/xen/iommu.h | 4 ++-- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c b/xen/drivers/passthrough/amd/pci_amd_iommu.c index 70b7475..86d6fb3 100644 --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c @@ -285,6 +285,8 @@ static void __hwdom_init amd_iommu_hwdom_init(struct domain *d) if ( !iommu_passthrough && !need_iommu(d) ) { + int rc = 0; + /* Set up 1:1 page table for dom0 */ for ( i = 0; i < max_pdx; i++ ) { @@ -295,12 +297,23 @@ static void __hwdom_init amd_iommu_hwdom_init(struct domain *d) * a pfn_valid() check would seem desirable here. */ if ( mfn_valid(pfn) ) - amd_iommu_map_page(d, pfn, pfn, - IOMMUF_readable|IOMMUF_writable); + { + int ret; + + ret = amd_iommu_map_page(d, pfn, pfn, + IOMMUF_readable|IOMMUF_writable); + + if ( unlikely(ret) ) + rc = ret; + } if ( !(i & 0xfffff) ) process_pending_softirqs(); } + + if ( rc ) + AMD_IOMMU_DEBUG("d%d: IOMMU mapping failed %d.", + d->domain_id, rc); } for_each_amd_iommu ( iommu ) diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c index 1ce4ddf..ee5c89d 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -2745,8 +2745,8 @@ static void arm_smmu_iommu_domain_teardown(struct domain *d) xfree(xen_domain); } -static int arm_smmu_map_page(struct domain *d, unsigned long gfn, - unsigned long mfn, unsigned int flags) +static int __must_check arm_smmu_map_page(struct domain *d, unsigned long gfn, + unsigned long mfn, unsigned int flags) { p2m_type_t t; diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index 29fb7fd..461688c 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1724,13 +1724,15 @@ static void iommu_domain_teardown(struct domain *d) spin_unlock(&hd->arch.mapping_lock); } -static int intel_iommu_map_page( - struct domain *d, unsigned long gfn, unsigned long mfn, - unsigned int flags) +static int __must_check intel_iommu_map_page(struct domain *d, + unsigned long gfn, + unsigned long mfn, + unsigned int flags) { struct domain_iommu *hd = dom_iommu(d); struct dma_pte *page = NULL, *pte = NULL, old, new = { 0 }; u64 pg_maddr; + int rc = 0; /* Do nothing if VT-d shares EPT page table */ if ( iommu_use_hap_pt(d) ) @@ -1773,9 +1775,9 @@ static int intel_iommu_map_page( unmap_vtd_domain_page(page); if ( !this_cpu(iommu_dont_flush_iotlb) ) - __intel_iommu_iotlb_flush(d, gfn, dma_pte_present(old), 1); + rc = __intel_iommu_iotlb_flush(d, gfn, dma_pte_present(old), 1); - return 0; + return rc; } static int __must_check intel_iommu_unmap_page(struct domain *d, diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 73a7f1e..14041a1 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -166,8 +166,8 @@ struct iommu_ops { #endif /* HAS_PCI */ void (*teardown)(struct domain *d); - int (*map_page)(struct domain *d, unsigned long gfn, unsigned long mfn, - unsigned int flags); + int __must_check (*map_page)(struct domain *d, unsigned long gfn, + unsigned long mfn, unsigned int flags); int __must_check (*unmap_page)(struct domain *d, unsigned long gfn); void (*free_page_table)(struct page_info *); #ifdef CONFIG_X86