lkml.org 
[lkml]   [2024]   [Apr]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
SubjectRe: [PATCH 08/12] iommu/vt-d: Use cache_tag_flush_range() in cache_invalidate_user
From
On 3/28/24 3:54 PM, Tian, Kevin wrote:
>> From: Lu Baolu <baolu.lu@linux.intel.com>
>> Sent: Monday, March 25, 2024 10:17 AM
>>
>> @@ -166,9 +122,9 @@ static int intel_nested_cache_invalidate_user(struct
>> iommu_domain *domain,
>> break;
>> }
>>
>> - intel_nested_flush_cache(dmar_domain, inv_entry.addr,
>> - inv_entry.npages,
>> - inv_entry.flags &
>> IOMMU_VTD_INV_FLAGS_LEAF);
>> + cache_tag_flush_range(dmar_domain, inv_entry.addr,
>> + inv_entry.npages,
>> + inv_entry.flags &
>> IOMMU_VTD_INV_FLAGS_LEAF);
>
> the helper requires an 'end' address but 'npages' is incorrectly used here.

Oh yes! Thanks for pointing this out. I will fix it like below.

diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h
index c139524274b9..cef997c07158 100644
--- a/drivers/iommu/intel/iommu.h
+++ b/drivers/iommu/intel/iommu.h
@@ -1050,6 +1050,12 @@ static inline unsigned long
aligned_nrpages(unsigned long host_addr, size_t size
return PAGE_ALIGN(host_addr + size) >> VTD_PAGE_SHIFT;
}

+/* Return a size from number of VTD pages. */
+static inline unsigned long nrpages_to_size(unsigned long npages)
+{
+ return npages << VTD_PAGE_SHIFT;
+}
+
/* Convert value to context PASID directory size field coding. */
#define context_pdts(pds) (((pds) & 0x7) << 9)

diff --git a/drivers/iommu/intel/nested.c b/drivers/iommu/intel/nested.c
index e251507cfcc0..ffbd8d98a3b8 100644
--- a/drivers/iommu/intel/nested.c
+++ b/drivers/iommu/intel/nested.c
@@ -123,7 +123,7 @@ static int intel_nested_cache_invalidate_user(struct
iommu_domain *domain,
}

cache_tag_flush_range(dmar_domain, inv_entry.addr,
- inv_entry.npages,
+ inv_entry.addr +
nrpages_to_size(inv_entry.npages) - 1,
inv_entry.flags &
IOMMU_VTD_INV_FLAGS_LEAF);
processed++;
}
Best regards,
baolu

\
 
 \ /
  Last update: 2024-05-27 16:27    [W:0.063 / U:0.776 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site