From patchwork Thu May 31 07:42:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen \(ThunderTown\)" X-Patchwork-Id: 137333 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp6278009lji; Thu, 31 May 2018 00:43:52 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLhwVMG5p+Te4a30uXcTWToe6YdkA3JaK/NvsoIOizZRm97crnANSynxgoVZwliyXgeYxjo X-Received: by 2002:a17:902:164:: with SMTP id 91-v6mr6000348plb.134.1527752632060; Thu, 31 May 2018 00:43:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527752632; cv=none; d=google.com; s=arc-20160816; b=rmP/JoV4L8S41Ekt/xGKoVWxxddXEhWAeRx+gm8bwRtycoAMn0zwZQpVQEcmpjQi3J tEKZ6+5XRzpOdCprHckg4+UtJjRrb1sVIfWsaIVIafk1Qt9U0+UiPuVFUMWKAvOtcwFi fayYbFSzePTjUdN5Rfq+J/ukHzps9dSeGM5Ba+ykJUZzEGQ0iA3Nra+ChrDz9H0Ulv2P J4Y35YBhEvsT40/9Yw5l0ltkCoZHeTSQbZX2cwsENZGeXKE5nJVf9gExwV9kWXPDp+Q+ JhD5MHN/UmEnwmz0jn4Mlsu1OtBUg+zOrRGALy8cMYo7SzCUHCr3RrvD1bL/krU51VQa 2nqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=67IVJR3cKs7hAmAaPCS7nFVGmZneMVWp98Zcr0enSeg=; b=HWegdhvNwVP+GqTWPPupi7yQbR0esXk1N+VlSikmHbFYLZ5jZB1D/kg9NlC489m9/D JNoeOfuvOqYNqAxjMqaoDgGa/huWN63uIyp8NsL7wawsl3d8GuEX69DzrPW/urhDvsGl bbODyuTIIHxSnjJO9S6Q9Tq0O7FdgEkmZntAMvERA2u7meq4ow0Yym11JBA6XaR/agD6 e94dw0EoVoqyZ1AmOa8b5n1xRNJGJx/8ufcAVKaOinPsXd5v0SqWRbDchqK91iOnSKao UAZiGag0ppaAQ0kdYP/n0In6uUyHpIfbN+mOWlGa87Uc8iFfI3g5uDng4bSPZhOJzSLw Mv2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bf1-v6si20566115plb.484.2018.05.31.00.43.51; Thu, 31 May 2018 00:43:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754037AbeEaHnt (ORCPT + 13 others); Thu, 31 May 2018 03:43:49 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:49010 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754076AbeEaHnq (ORCPT ); Thu, 31 May 2018 03:43:46 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id D0D58D03BD0C; Thu, 31 May 2018 15:43:42 +0800 (CST) Received: from localhost (10.177.23.164) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.382.0; Thu, 31 May 2018 15:43:34 +0800 From: Zhen Lei To: Robin Murphy , Will Deacon , Matthias Brugger , Rob Clark , Joerg Roedel , linux-mediatek , linux-arm-msm , linux-arm-kernel , iommu , linux-kernel CC: Zhen Lei , Hanjun Guo , Libin , Guozhu Li , "Xinwei Hu" Subject: [PATCH 4/7] iommu/amd: make sure TLB to be flushed before IOVA freed Date: Thu, 31 May 2018 15:42:46 +0800 Message-ID: <1527752569-18020-5-git-send-email-thunder.leizhen@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.0 In-Reply-To: <1527752569-18020-1-git-send-email-thunder.leizhen@huawei.com> References: <1527752569-18020-1-git-send-email-thunder.leizhen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.23.164] X-CFilter-Loop: Reflected Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Although the mapping has already been removed in the page table, it maybe still exist in TLB. Suppose the freed IOVAs is reused by others before the flush operation completed, the new user can not correctly access to its meomory. Signed-off-by: Zhen Lei --- drivers/iommu/amd_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 1.8.3 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 8fb8c73..93aa389 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -2402,9 +2402,9 @@ static void __unmap_single(struct dma_ops_domain *dma_dom, } if (amd_iommu_unmap_flush) { - dma_ops_free_iova(dma_dom, dma_addr, pages); domain_flush_tlb(&dma_dom->domain); domain_flush_complete(&dma_dom->domain); + dma_ops_free_iova(dma_dom, dma_addr, pages); } else { pages = __roundup_pow_of_two(pages); queue_iova(&dma_dom->iovad, dma_addr >> PAGE_SHIFT, pages, 0);