From patchwork Tue May 31 13:57:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Xu X-Patchwork-Id: 9144921 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 32293607D6 for ; Tue, 31 May 2016 14:05:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25836272D8 for ; Tue, 31 May 2016 14:05:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A3902796F; Tue, 31 May 2016 14:05: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 8305027B89 for ; Tue, 31 May 2016 14:05: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 1b7kGM-0000jL-0a; Tue, 31 May 2016 14:03:18 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b7kGK-0000ii-Nn for xen-devel@lists.xen.org; Tue, 31 May 2016 14:03:16 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 99/DC-30266-4A99D475; Tue, 31 May 2016 14:03:16 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrLLMWRWlGSWpSXmKPExsXS1tYhobtkpm+ 4wZobjBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0bjgTUsBdsUKxb9nMfSwLhEqouRk0NIoFLi 86+D7CC2hACvxJFlM1ghbH+JvuvnmCBqaiR2TX3AAmKzCahIzGh+B1YvIiAtce3zZcYuRi4OZ oGrjBJtx3vAEsIC1RL9V/czgtgsAqoS67d8YgOxeQUcJA6teckGsUBBYtmXtcwgNqeAo8SFfp hlDhIPv/xkmsDIu4CRYRWjenFqUVlqka6hXlJRZnpGSW5iZo6uoYGZXm5qcXFiempOYlKxXnJ +7iZGYDAwAMEOxp3PnQ4xSnIwKYnyPsz2DRfiS8pPqcxILM6ILyrNSS0+xCjDwaEkwes5Aygn WJSanlqRlpkDDEuYtAQHj5II7z2QNG9xQWJucWY6ROoUo6KUOG8SSEIAJJFRmgfXBouFS4yyU sK8jECHCPEUpBblZpagyr9iFOdgVBLm5QOZwpOZVwI3/RXQYiagxfEZPiCLSxIRUlINjEx/z3 dmPlN6+yybI1EvPyir+raQp3yIkYDpeuumj44+zr2nPh52Ykxcc8azSfK1ZqTs+TO7mc68TWy f8viymu3nLTsdXpz67sRRHhllfOjA4Q+yixnrODYl7EqWMWm2y27SiTxnc1N5n1tI+bWv/lev bz+nXe5/6HXgP+3PZVNVZCPYOXrtlViKMxINtZiLihMBTUH0loACAAA= X-Env-Sender: quan.xu@intel.com X-Msg-Ref: server-2.tower-21.messagelabs.com!1464703385!2815320!6 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 46561 invoked from network); 31 May 2016 14:03:15 -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:15 -0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP; 31 May 2016 07:01:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,395,1459839600"; d="scan'208";a="113440061" Received: from xen-commits.sh.intel.com ([10.239.82.178]) by fmsmga004.fm.intel.com with ESMTP; 31 May 2016 07:01:54 -0700 From: "Xu, Quan" To: xen-devel@lists.xen.org Date: Tue, 31 May 2016 21:57:30 +0800 Message-Id: <1464703056-4741-6-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 , Quan Xu , dario.faggioli@citrix.com, Julien Grall , Jan Beulich Subject: [Xen-devel] [Patch v6 05/11] IOMMU/MMU: propagate IOMMU Device-TLB flush error up to iommu_iotlb_flush{, _all} (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 Reviewed-by: Jan Beulich CC: Stefano Stabellini CC: Julien Grall CC: Jan Beulich CC: Kevin Tian v6: Remove __must_check annotation from xenmem_add_to_physmap(). --- xen/arch/arm/p2m.c | 4 +++- xen/common/memory.c | 12 ++++++++++-- xen/drivers/passthrough/iommu.c | 13 +++++++++---- xen/drivers/passthrough/x86/iommu.c | 5 +++-- xen/include/xen/iommu.h | 5 +++-- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 838d004..68679a3 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1178,7 +1178,9 @@ out: if ( flush ) { flush_tlb_domain(d); - iommu_iotlb_flush(d, sgfn, egfn - sgfn); + ret = iommu_iotlb_flush(d, sgfn, egfn - sgfn); + if ( !rc ) + rc = ret; } while ( (pg = page_list_remove_head(&free_pages)) ) diff --git a/xen/common/memory.c b/xen/common/memory.c index ccc6436..46b1d9f 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -683,9 +683,17 @@ static int xenmem_add_to_physmap(struct domain *d, #ifdef CONFIG_HAS_PASSTHROUGH if ( need_iommu(d) ) { + int ret; + this_cpu(iommu_dont_flush_iotlb) = 0; - iommu_iotlb_flush(d, xatp->idx - done, done); - iommu_iotlb_flush(d, xatp->gpfn - done, done); + + ret = iommu_iotlb_flush(d, xatp->idx - done, done); + if ( unlikely(ret) && rc >= 0 ) + rc = ret; + + ret = iommu_iotlb_flush(d, xatp->gpfn - done, done); + if ( unlikely(ret) && rc >= 0 ) + rc = ret; } #endif diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c index 25501cd..e9b2855 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -312,24 +312,29 @@ static void iommu_free_pagetables(unsigned long unused) cpumask_cycle(smp_processor_id(), &cpu_online_map)); } -void iommu_iotlb_flush(struct domain *d, unsigned long gfn, unsigned int page_count) +int iommu_iotlb_flush(struct domain *d, unsigned long gfn, + unsigned int page_count) { const struct domain_iommu *hd = dom_iommu(d); if ( !iommu_enabled || !hd->platform_ops || !hd->platform_ops->iotlb_flush ) - return; + return 0; hd->platform_ops->iotlb_flush(d, gfn, page_count); + + return 0; } -void iommu_iotlb_flush_all(struct domain *d) +int iommu_iotlb_flush_all(struct domain *d) { const struct domain_iommu *hd = dom_iommu(d); if ( !iommu_enabled || !hd->platform_ops || !hd->platform_ops->iotlb_flush_all ) - return; + return 0; hd->platform_ops->iotlb_flush_all(d); + + return 0; } int __init iommu_setup(void) diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c index b64b98f..a18a608 100644 --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -104,8 +104,9 @@ int arch_iommu_populate_page_table(struct domain *d) this_cpu(iommu_dont_flush_iotlb) = 0; if ( !rc ) - iommu_iotlb_flush_all(d); - else if ( rc != -ERESTART ) + rc = iommu_iotlb_flush_all(d); + + if ( rc && rc != -ERESTART ) iommu_teardown(d); return rc; diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 14041a1..22a2002 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -200,8 +200,9 @@ int iommu_do_pci_domctl(struct xen_domctl *, struct domain *d, int iommu_do_domctl(struct xen_domctl *, struct domain *d, XEN_GUEST_HANDLE_PARAM(xen_domctl_t)); -void iommu_iotlb_flush(struct domain *d, unsigned long gfn, unsigned int page_count); -void iommu_iotlb_flush_all(struct domain *d); +int __must_check iommu_iotlb_flush(struct domain *d, unsigned long gfn, + unsigned int page_count); +int __must_check iommu_iotlb_flush_all(struct domain *d); /* * The purpose of the iommu_dont_flush_iotlb optional cpu flag is to