From patchwork Fri Apr 29 09:25:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Xu X-Patchwork-Id: 8979041 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 A61129F372 for ; Fri, 29 Apr 2016 09:30:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B232120259 for ; Fri, 29 Apr 2016 09:30:42 +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 BA9AD20251 for ; Fri, 29 Apr 2016 09:30:41 +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 1aw4jG-0000B2-Fy; Fri, 29 Apr 2016 09:28:54 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aw4jE-00009G-Q4 for xen-devel@lists.xen.org; Fri, 29 Apr 2016 09:28:52 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id D5/44-18833-45923275; Fri, 29 Apr 2016 09:28:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNLMWRWlGSWpSXmKPExsVywNwkQjdYUzn c4M8bFYslHxezODB6HN39mymAMYo1My8pvyKBNWPbgpKCS0IVX95OZ2xgbOXvYuTgEBKokFg/ NbmLkZNDQoBX4siyGawQtr/E+qXz2UBsIYEaiSntt8FsNgFFiQ0XlzOB2CIC0hLXPl9m7GLk4 mAWmM8o8bTlOiNIQlggVqK/8RoziM0ioCrxeM8HsAZeAUeJ7Vvms0MsUJBY9mUtWA2ngJPE9e vvoZY5Snzo/sE6gZF3ASPDKkb14tSistQiXSO9pKLM9IyS3MTMHF1DAzO93NTi4sT01JzEpGK 95PzcTYzAQGAAgh2My/46HWKU5GBSEuUN4VQOF+JLyk+pzEgszogvKs1JLT7EKMPBoSTBG6cB lBMsSk1PrUjLzAGGJExagoNHSYTXCCTNW1yQmFucmQ6ROsWoKCXOqwWSEABJZJTmwbXB4uASo 6yUMC8j0CFCPAWpRbmZJajyrxjFORiVhHk7QKbwZOaVwE1/BbSYCWixwCZFkMUliQgpqQZG63 XR69Q6JhlO8PqnP+XftimBhjN0KhOy2dkzvDVFb0bt0v4f9+qC8veF3UYnHX80rtt8QaWhsbK V+6bppWl+rznq9M2ZDaVyFH4fNfy4/IfptNXvPy8XNmiy/Pf57SH9FSev6nx6yVoecun4/k3T RNpvfJ5rcKFhydVzT65rb2wTttERFXrBpcRSnJFoqMVcVJwIAJWCHKp+AgAA X-Env-Sender: quan.xu@intel.com X-Msg-Ref: server-2.tower-21.messagelabs.com!1461922125!2123467!5 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.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 45087 invoked from network); 29 Apr 2016 09:28:51 -0000 Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by server-2.tower-21.messagelabs.com with SMTP; 29 Apr 2016 09:28:51 -0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 29 Apr 2016 02:28:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,551,1455004800"; d="scan'208";a="965266430" Received: from xen-commits.sh.intel.com ([10.239.82.178]) by orsmga002.jf.intel.com with ESMTP; 29 Apr 2016 02:28:49 -0700 From: Quan Xu To: xen-devel@lists.xen.org Date: Fri, 29 Apr 2016 17:25:11 +0800 Message-Id: <1461921917-48394-5-git-send-email-quan.xu@intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1461921917-48394-1-git-send-email-quan.xu@intel.com> References: <1461921917-48394-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 v3 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 --- 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 6e2e43a..e908046 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -618,11 +618,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 hvm_iommu *hd = domain_hvm_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 */ @@ -630,7 +631,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); @@ -640,7 +641,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); @@ -648,9 +649,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) @@ -1771,9 +1774,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,