iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] iommu/amd: make sure TLB to be flushed before IOVA freed
@ 2018-06-06  2:18 Zhen Lei
       [not found] ` <1528251526-11408-1-git-send-email-thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
  2018-07-06 11:21 ` Joerg Roedel
  0 siblings, 2 replies; 3+ messages in thread
From: Zhen Lei @ 2018-06-06  2:18 UTC (permalink / raw)
  To: Joerg Roedel, iommu, linux-kernel; +Cc: Zhen Lei, Robin Murphy

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>
---
 drivers/iommu/amd_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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);
--
1.8.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] iommu/amd: make sure TLB to be flushed before IOVA freed
       [not found] ` <1528251526-11408-1-git-send-email-thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
@ 2018-06-21  6:08   ` Leizhen (ThunderTown)
  0 siblings, 0 replies; 3+ messages in thread
From: Leizhen (ThunderTown) @ 2018-06-21  6:08 UTC (permalink / raw)
  To: Joerg Roedel, iommu, linux-kernel

Hi Joerg:
  Can you take a look at it?


On 2018/6/6 10:18, Zhen Lei wrote:
> 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-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> ---
>  drivers/iommu/amd_iommu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 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);
> --
> 1.8.3
> 
> 
> 
> .
> 

-- 
Thanks!
BestRegards

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] iommu/amd: make sure TLB to be flushed before IOVA freed
  2018-06-06  2:18 [PATCH 1/1] iommu/amd: make sure TLB to be flushed before IOVA freed Zhen Lei
       [not found] ` <1528251526-11408-1-git-send-email-thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
@ 2018-07-06 11:21 ` Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2018-07-06 11:21 UTC (permalink / raw)
  To: Zhen Lei; +Cc: iommu, linux-kernel, Robin Murphy

On Wed, Jun 06, 2018 at 10:18:46AM +0800, Zhen Lei wrote:
> 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>
> ---
>  drivers/iommu/amd_iommu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-06 11:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-06  2:18 [PATCH 1/1] iommu/amd: make sure TLB to be flushed before IOVA freed Zhen Lei
     [not found] ` <1528251526-11408-1-git-send-email-thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2018-06-21  6:08   ` Leizhen (ThunderTown)
2018-07-06 11:21 ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).