From patchwork Fri May 6 08:54:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Xu X-Patchwork-Id: 9030421 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 A74C39F39D for ; Fri, 6 May 2016 09:00:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 81A5920394 for ; Fri, 6 May 2016 09:00:54 +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 19E1A20384 for ; Fri, 6 May 2016 09:00:53 +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 1aybaZ-0004O8-1N; Fri, 06 May 2016 08:58:23 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aybaY-0004MD-Op for xen-devel@lists.xen.org; Fri, 06 May 2016 08:58:22 +0000 Received: from [193.109.254.147] by server-1.bemta-14.messagelabs.com id 1D/4F-02869-EAC5C275; Fri, 06 May 2016 08:58:22 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRWlGSWpSXmKPExsXS1tYhors2Rif cYN96Q4slHxezODB6HN39mymAMYo1My8pvyKBNWNhaw9rwQmhikPHL7E0MP7m62Lk5BASqJC4 t+89K4gtIcArcWTZDCjbX2LNlSZGiJoaiRef77GD2GwCihIbLi5nArFFBKQlrn2+DFTDxcEsM J9R4mnLdSCHnUNYIFbimitICYuAqsSlb1PBRvIKOEqcfveLCWK8gsSyL2uZQWxOASeJtqnt7B CrHCV+TNvGNIGRdwEjwypGjeLUorLUIl1DI72kosz0jJLcxMwcXUNDE73c1OLixPTUnMSkYr3 k/NxNjMBQYACCHYxnpzkfYpTkYFIS5V31TztciC8pP6UyI7E4I76oNCe1+BCjDAeHkgRvTrRO uJBgUWp6akVaZg4wKGHSEhw8SiK8f0HSvMUFibnFmekQqVOMilLivAtAEgIgiYzSPLg2WCRcY pSVEuZlBDpEiKcgtSg3swRV/hWjOAejkjDvNJApPJl5JXDTXwEtZgJa/H6uJsjikkSElFQD48 wfpbE/l9SdDek53X056FzaxHXBX/af+r3CK3gLn9XhLW1HFjF/WDit+EFL/qXpv29Izwg6rzb 1wE2dFV/Vf3MmRHoY+1aceHA9WtOY6SfLzHCpQ+dTHW0LGYUO5uS6BAhd9ZvtIaXacF7rjYVx QEOOwiKNxzV1EQtt4repnY6+8H5B+MmodiWW4oxEQy3mouJEAAH37V5/AgAA X-Env-Sender: quan.xu@intel.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1462525094!39896475!5 X-Originating-IP: [134.134.136.20] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjAgPT4gMzU1MzU4\n X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 45863 invoked from network); 6 May 2016 08:58:21 -0000 Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by server-9.tower-27.messagelabs.com with SMTP; 6 May 2016 08:58:21 -0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 06 May 2016 01:58:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,586,1455004800"; d="scan'208";a="969963803" Received: from xen-commits.sh.intel.com ([10.239.82.178]) by orsmga002.jf.intel.com with ESMTP; 06 May 2016 01:58:19 -0700 From: Quan Xu To: xen-devel@lists.xen.org Date: Fri, 6 May 2016 16:54:34 +0800 Message-Id: <1462524880-67205-5-git-send-email-quan.xu@intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1462524880-67205-1-git-send-email-quan.xu@intel.com> References: <1462524880-67205-1-git-send-email-quan.xu@intel.com> Cc: dario.faggioli@citrix.com, Jan Beulich , Feng Wu , Kevin Tian , Quan Xu Subject: [Xen-devel] [PATCH v4 04/10] vt-d: 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 CC: Kevin Tian CC: Feng Wu CC: Jan Beulich Reviewed-by: Jan Beulich --- xen/drivers/passthrough/vtd/iommu.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index 64093a9..e0e1126 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -616,11 +616,12 @@ static void iommu_flush_iotlb_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) ) - iommu_flush_iotlb(domain, addr >> PAGE_SHIFT_4K, 1, 1); + rc = iommu_flush_iotlb(domain, addr >> PAGE_SHIFT_4K, 1, 1); unmap_vtd_domain_page(page); + + return rc; } static void iommu_free_pagetable(u64 pt_maddr, int level) @@ -1766,9 +1769,7 @@ static int intel_iommu_unmap_page(struct domain *d, unsigned long gfn) 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,