From patchwork Wed Jun 6 02:18: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: 137796 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp255708lji; Tue, 5 Jun 2018 19:20:51 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJjKdPzGiUl/JV2nxpwebbsKcxTezcEpj+yadGPGIfhXukSjjsJN3MbiKHnFApmndpDWPV6 X-Received: by 2002:a62:9945:: with SMTP id d66-v6mr517576pfe.192.1528251651187; Tue, 05 Jun 2018 19:20:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528251651; cv=none; d=google.com; s=arc-20160816; b=DgZDoB/wZ6o5eWsgAsTKXeu9XNGBZ38pRUF98e2tXUPjaD/ZTNKRUy8d2GVth1btVh U3DLgXyxysgeKUw0RXSwqA15xAk8gOO68VHltPCpDXHG7HGivWnGtN5SKLTtXd16YoHi 9/tXfAlRqvULHl/FlELua//A1lI321GJieaVZVbhV+ibk/UG5eoAOiiff2zQsdFxW4he RKAtzuV2huXZPAUkQbRKd8OQVjkq25aGLsMYZc4u+ofUzVEt2IXF/2Nhu5khPnJZoQxw KwCpT5GYDe92mEdpCrSOOvGiipfn6Zsd+5yevUcmCIjN8mJeBeegAmIWAwlWDgVQ04Sd 4r1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=1PZeytOcFaKnwy8ctkTb2JoXAWZC/oy12fQ+bA3bY+M=; b=fkEjHDC5+nfcYifeKyb5a8HQa70p9IADpwqEh+V+uWtKG9t9MlIGBtmrSyMvd5y+P6 lkKdfJkVWAyQ5TueWTwFBGV+J/tGYbhGgJrwzJSw+rtpUpjMlaZqE4wmoAyQVUDBwY8e pfSDTHnMGkWu09ifaj7O6v+HtiraMlLhwHepdTbJnzwYuxlCjaELiJbplobQ53TQRAD/ DXfY9aYRj7ENubCkq9FP65Pz2JMEYO+TodBsxKt6iT7hkGKMdoseNFAJRFnmWAYVqIuW 0uHzzjsgiQv8tpNgrFhrYTKKHzG/+okE3/QMdQlZQ3/pT0Dx2VnwysriNQLkJqLHA5ge uIRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 x1-v6si28697612pgp.422.2018.06.05.19.20.50; Tue, 05 Jun 2018 19:20:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752843AbeFFCUs (ORCPT + 30 others); Tue, 5 Jun 2018 22:20:48 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:43754 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752424AbeFFCUr (ORCPT ); Tue, 5 Jun 2018 22:20:47 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 0FF31BCB0E561; Wed, 6 Jun 2018 10:20:44 +0800 (CST) Received: from localhost (10.177.23.164) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.382.0; Wed, 6 Jun 2018 10:20:35 +0800 From: Zhen Lei To: Joerg Roedel , iommu , linux-kernel CC: Zhen Lei , Robin Murphy Subject: [PATCH 1/1] iommu/amd: make sure TLB to be flushed before IOVA freed Date: Wed, 6 Jun 2018 10:18:46 +0800 Message-ID: <1528251526-11408-1-git-send-email-thunder.leizhen@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.0 MIME-Version: 1.0 X-Originating-IP: [10.177.23.164] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 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);