lkml.org 
[lkml]   [2021]   [Apr]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] iommu/vt-d: Force to flush iotlb before creating superpage
From
Date
Hi Longpeng,

On 4/1/21 3:18 PM, Longpeng(Mike) wrote:
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index ee09323..cbcb434 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -2342,9 +2342,20 @@ static inline int hardware_largepage_caps(struct dmar_domain *domain,
> * removed to make room for superpage(s).
> * We're adding new large pages, so make sure
> * we don't remove their parent tables.
> + *
> + * We also need to flush the iotlb before creating
> + * superpage to ensure it does not perserves any
> + * obsolete info.
> */
> - dma_pte_free_pagetable(domain, iov_pfn, end_pfn,
> - largepage_lvl + 1);
> + if (dma_pte_present(pte)) {

The dma_pte_free_pagetable() clears a batch of PTEs. So checking current
PTE is insufficient. How about removing this check and always performing
cache invalidation?

> + int i;
> +
> + dma_pte_free_pagetable(domain, iov_pfn, end_pfn,
> + largepage_lvl + 1);
> + for_each_domain_iommu(i, domain)
> + iommu_flush_iotlb_psi(g_iommus[i], domain,
> + iov_pfn, nr_pages, 0, 0);
> +

Best regards,
baolu

\
 
 \ /
  Last update: 2021-04-02 06:54    [W:0.091 / U:0.292 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site