From patchwork Mon Jun 13 15:17:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Xu X-Patchwork-Id: 9173433 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 9124D60573 for ; Mon, 13 Jun 2016 15:24:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8256A20410 for ; Mon, 13 Jun 2016 15:24:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77480262AE; Mon, 13 Jun 2016 15:24:20 +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 E9D1020410 for ; Mon, 13 Jun 2016 15:24:19 +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 1bCTgv-000491-7L; Mon, 13 Jun 2016 15:22:17 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bCTgt-000474-Og for xen-devel@lists.xen.org; Mon, 13 Jun 2016 15:22:15 +0000 Received: from [193.109.254.147] by server-7.bemta-14.messagelabs.com id 68/3E-07668-7AFCE575; Mon, 13 Jun 2016 15:22:15 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNLMWRWlGSWpSXmKPExsVywNwkQnfZ+bh wg/Pf1SyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oyJ960KLipWfLm3iKmBcZ9UFyMHh5BAhcSn Y4pdjJwcEgK8EkeWzWCFsP0lNmy9CmYLCdRIdF/dwwRiswmoSMxofscOYosISEtc+3yZsYuRi 4NZ4CqjRNvxHrCEsEC1xIUV+9hAbBYBVYm2b32MIDavgKPElNdTmCAWKEgs+7KWGcTmFHCS2D y1kQlimaPEgtMT2Ccw8i5gZFjFqF6cWlSWWqRropdUlJmeUZKbmJmja2hoopebWlycmJ6ak5h UrJecn7uJERgIDECwg3HFQudDjJIcTEqivKcOx4UL8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuA1 PQeUEyxKTU+tSMvMAYYkTFqCg0dJhHfyWaA0b3FBYm5xZjpE6hSjopQ4rzBInwBIIqM0D64NF geXGGWlhHkZgQ4R4ilILcrNLEGVf8UozsGoJMzLBTKFJzOvBG76K6DFTECLOfZFgywuSURIST UwtgVOWcq2aRtz19LeQ6F678NylilnXzfoOp5k8bn6fG96w7wV2gXPlC8pcJbwtXOH+jGZabn WBy6odn4hfcRWPvdAPeeU4EitgoW5/clpP2ceLUqLu3F1va32HsaO9z2XLIPMnab59Jis+7tO YsuHJXHTYx7nF+gdy6vPdw+dsPn0EeeKZhclluKMREMt5qLiRAA1AGTifgIAAA== X-Env-Sender: quan.xu@intel.com X-Msg-Ref: server-16.tower-27.messagelabs.com!1465831333!47407344!1 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 57268 invoked from network); 13 Jun 2016 15:22:14 -0000 Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by server-16.tower-27.messagelabs.com with SMTP; 13 Jun 2016 15:22:14 -0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 13 Jun 2016 08:22:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,466,1459839600"; d="scan'208";a="996644984" Received: from xen-commits.sh.intel.com ([10.239.82.178]) by orsmga002.jf.intel.com with ESMTP; 13 Jun 2016 08:22:03 -0700 From: "Xu, Quan" To: xen-devel@lists.xen.org Date: Mon, 13 Jun 2016 23:17:12 +0800 Message-Id: <1465831038-43005-6-git-send-email-quan.xu@intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1465831038-43005-1-git-send-email-quan.xu@intel.com> References: <1465831038-43005-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 v8 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 Acked-by: Julien Grall Reviewed-by: Kevin Tian Reviewed-by: Jan Beulich CC: Stefano Stabellini CC: Julien Grall CC: Jan Beulich CC: Kevin Tian --- 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 6a19c57..65d8f1a 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 ec85352..3a73fab 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -311,24 +311,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 2b86710..57c9fbc 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