iommu/vt-d: Ensure atomicity in context and PASID entry updates
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest3 patches 14 repliesIn review
- v13 patches 35 repliesSuperseded
Changes in v2 from the cover letter
- Considering that these fixes should be backported deep into old versions, and the previous solution relies heavily on the x86_64 cmpxchg16b instruction, which is not friendly to backport as it might cause regressions on early hardware or configurations, we use the simple dma_wmb() approach in this version.
- Jason proposed the entry-sync framework
(https://lore.kernel.org/linux-iommu/[email protected]/)
which consolidates the details of how to update a translation table entry in common code shared by the individual drivers, so that the IOMMU driver could be designed without considering the hitless or non-hitless replace.
- To make life easier, I decided to split all the work into multiple series. The first, as it is, covers fixing the real problems in a backport-friendly way, and the next series covers entry-sync for PASID table entry updates.
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | iommu/vt-d: Clear Present bit before tearing down PASID entrydrivers/ drivers/ | +19 | 3 replies | |
| 2/3 | iommu/vt-d: Clear Present bit before tearing down context entrydrivers/ drivers/ | +23 | 7 replies | |
| 3/3 | iommu/vt-d: Fix race condition during PASID entry replacementdrivers/ drivers/ drivers/ +1 more | +16 | 2 replies |
Reviews trailers per patch
All 3 patches have a Reviewed-by or Acked-by.
| Patch | Dmytro Maluka | Samiullah Khawaja | Kevin Tian |
|---|---|---|---|
| 1/3 | R-b | R-b | R-b |
| 2/3 | R-b | R-b | R-b |
| 3/3 | R-b | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.
Cover letter [PATCH v2 0/3] iommu/vt-d: Ensure atomicity in context and PASID entry updates
This is a follow-up from recent discussions in the iommu community mailing list [1] [2] regarding potential race conditions in table entry updates.
The Intel VT-d hardware fetches translation table entries (context entries and PASID entries) in 128-bit (16-byte) chunks. Currently, the Linux driver often updates these entries using multiple 64-bit writes. This creates a race condition where the IOMMU hardware may fetch a "torn" entry — a mixture of old and new data — during a CPU update. This can lead to unpredictable hardware behavior, spurious faults, or system instability.
This addresses these atomicity issues by following the translation table entry ownership handshake protocal recommended by the VT-d specification.
[1] https://lore.kernel.org/linux-iommu/[email protected]/
[2] https://lore.kernel.org/linux-iommu/[email protected]/
Change log:
v2:
- Considering that these fixes should be backported deep into old versions, and the previous solution relies heavily on the x86_64 cmpxchg16b instruction, which is not friendly to backport as it might cause regressions on early hardware or configurations, we use the simple dma_wmb() approach in this version.
- Jason proposed the entry-sync framework
(https://lore.kernel.org/linux-iommu/[email protected]/)
which consolidates the details of how to update a translation table entry in common code shared by the individual drivers, so that the IOMMU driver could be designed without considering the hitless or non-hitless replace.
- To make life easier, I decided to split all the work into multiple series. The first, as it is, covers fixing the real problems in a backport-friendly way, and the next series covers entry-sync for PASID table entry updates.
v1: https://lore.kernel.org/linux-iommu/[email protected]/
Lu Baolu (3):
iommu/vt-d: Clear Present bit before tearing down PASID entry iommu/vt-d: Clear Present bit before tearing down context entry iommu/vt-d: Fix race condition during PASID entry replacement
drivers/iommu/intel/iommu.h | 21 +++- drivers/iommu/intel/pasid.h | 28 +++--- drivers/iommu/intel/iommu.c | 33 +++--- drivers/iommu/intel/nested.c | 9 +- drivers/iommu/intel/pasid.c | 190 +---------------------------------- 5 files changed, 58 insertions(+), 223 deletions(-)
Signature · 1 line
2.43.0