]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
iommu/amd: make sure TLB to be flushed before IOVA freed
authorZhen Lei <thunder.leizhen@huawei.com>
Wed, 6 Jun 2018 02:18:46 +0000 (10:18 +0800)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:50:37 +0000 (19:50 -0600)
BugLink: https://bugs.launchpad.net/bugs/1836287
[ Upstream commit 3c120143f584360a13614787e23ae2cdcb5e5ccd ]

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 <thunder.leizhen@huawei.com>
Fixes: b1516a14657a ('iommu/amd: Implement flush queue')
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/iommu/amd_iommu.c

index 8ddc2f1c56566175533d6639a75e8677ce03d3d7..2bc174b33dabbdfa5457109091f8049bcf1e1cbc 100644 (file)
@@ -2401,9 +2401,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);