Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iommu/vt-d: Flush cache for PASID table before using it

When writing the address of a freshly allocated zero-initialized PASID
table to a PASID directory entry, do that after the CPU cache flush for
this PASID table, not before it, to avoid the time window when this
PASID table may be already used by non-coherent IOMMU hardware while
its contents in RAM is still some random old data, not zero-initialized.

Fixes: 194b3348bdbb ("iommu/vt-d: Fix PASID directory pointer coherency")
Signed-off-by: Dmytro Maluka <dmaluka@chromium.org>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Link: https://lore.kernel.org/r/20251221123508.37495-1-dmaluka@chromium.org
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>

authored by

Dmytro Maluka and committed by
Joerg Roedel
22d169bd 10e60d87

+4 -3
+4 -3
drivers/iommu/intel/pasid.c
··· 153 153 if (!entries) 154 154 return NULL; 155 155 156 + if (!ecap_coherent(info->iommu->ecap)) 157 + clflush_cache_range(entries, VTD_PAGE_SIZE); 158 + 156 159 /* 157 160 * The pasid directory table entry won't be freed after 158 161 * allocation. No worry about the race with free and ··· 168 165 iommu_free_pages(entries); 169 166 goto retry; 170 167 } 171 - if (!ecap_coherent(info->iommu->ecap)) { 172 - clflush_cache_range(entries, VTD_PAGE_SIZE); 168 + if (!ecap_coherent(info->iommu->ecap)) 173 169 clflush_cache_range(&dir[dir_index].val, sizeof(*dir)); 174 - } 175 170 } 176 171 177 172 return &entries[index];