* [PATCH v2] iommu/vt-d: Flush cache for PASID table before using it
@ 2025-12-21 12:35 Dmytro Maluka
2026-01-06 7:51 ` Tian, Kevin
2026-01-20 7:01 ` Baolu Lu
0 siblings, 2 replies; 3+ messages in thread
From: Dmytro Maluka @ 2025-12-21 12:35 UTC (permalink / raw)
To: David Woodhouse, Lu Baolu, iommu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, linux-kernel,
Vineeth Pillai (Google), Aashish Sharma, Grzegorz Jaszczyk,
Chuanxiao Dong, Kevin Tian, Dmytro Maluka
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.
v1 -> v2:
Add Fixes: tag.
Fixes: 194b3348bdbb ("iommu/vt-d: Fix PASID directory pointer coherency")
Signed-off-by: Dmytro Maluka <dmaluka@chromium.org>
---
drivers/iommu/intel/pasid.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c
index 3e2255057079..77b9b147ab50 100644
--- a/drivers/iommu/intel/pasid.c
+++ b/drivers/iommu/intel/pasid.c
@@ -153,6 +153,9 @@ static struct pasid_entry *intel_pasid_get_entry(struct device *dev, u32 pasid)
if (!entries)
return NULL;
+ if (!ecap_coherent(info->iommu->ecap))
+ clflush_cache_range(entries, VTD_PAGE_SIZE);
+
/*
* The pasid directory table entry won't be freed after
* allocation. No worry about the race with free and
@@ -165,10 +168,8 @@ static struct pasid_entry *intel_pasid_get_entry(struct device *dev, u32 pasid)
iommu_free_pages(entries);
goto retry;
}
- if (!ecap_coherent(info->iommu->ecap)) {
- clflush_cache_range(entries, VTD_PAGE_SIZE);
+ if (!ecap_coherent(info->iommu->ecap))
clflush_cache_range(&dir[dir_index].val, sizeof(*dir));
- }
}
return &entries[index];
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* RE: [PATCH v2] iommu/vt-d: Flush cache for PASID table before using it
2025-12-21 12:35 [PATCH v2] iommu/vt-d: Flush cache for PASID table before using it Dmytro Maluka
@ 2026-01-06 7:51 ` Tian, Kevin
2026-01-20 7:01 ` Baolu Lu
1 sibling, 0 replies; 3+ messages in thread
From: Tian, Kevin @ 2026-01-06 7:51 UTC (permalink / raw)
To: Dmytro Maluka, David Woodhouse, Lu Baolu, iommu@lists.linux.dev
Cc: Joerg Roedel, Will Deacon, Robin Murphy,
linux-kernel@vger.kernel.org, Vineeth Pillai (Google),
Aashish Sharma, Grzegorz Jaszczyk, Dong, Chuanxiao
> From: Dmytro Maluka <dmaluka@chromium.org>
> Sent: Sunday, December 21, 2025 8:35 PM
>
> 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.
>
> v1 -> v2:
> Add Fixes: tag.
>
> 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>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] iommu/vt-d: Flush cache for PASID table before using it
2025-12-21 12:35 [PATCH v2] iommu/vt-d: Flush cache for PASID table before using it Dmytro Maluka
2026-01-06 7:51 ` Tian, Kevin
@ 2026-01-20 7:01 ` Baolu Lu
1 sibling, 0 replies; 3+ messages in thread
From: Baolu Lu @ 2026-01-20 7:01 UTC (permalink / raw)
To: Dmytro Maluka, David Woodhouse, iommu
Cc: Joerg Roedel, Will Deacon, Robin Murphy, linux-kernel,
Vineeth Pillai (Google), Aashish Sharma, Grzegorz Jaszczyk,
Chuanxiao Dong, Kevin Tian
On 12/21/25 20:35, Dmytro Maluka wrote:
> 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.
>
> v1 -> v2:
> Add Fixes: tag.
>
> Fixes: 194b3348bdbb ("iommu/vt-d: Fix PASID directory pointer coherency")
> Signed-off-by: Dmytro Maluka<dmaluka@chromium.org>
> ---
> drivers/iommu/intel/pasid.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
Queued for iommu next.
Thanks,
baolu
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-20 7:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-21 12:35 [PATCH v2] iommu/vt-d: Flush cache for PASID table before using it Dmytro Maluka
2026-01-06 7:51 ` Tian, Kevin
2026-01-20 7:01 ` Baolu Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox