public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] iommu/vt-d: Ensure atomicity in context and PASID entry updates
@ 2026-01-20  6:18 Lu Baolu
  2026-01-20  6:18 ` [PATCH v2 1/3] iommu/vt-d: Clear Present bit before tearing down PASID entry Lu Baolu
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Lu Baolu @ 2026-01-20  6:18 UTC (permalink / raw)
  To: Joerg Roedel, Will Deacon, Robin Murphy, Kevin Tian,
	Jason Gunthorpe
  Cc: Dmytro Maluka, Samiullah Khawaja, iommu, linux-kernel, Lu Baolu

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/20251227175728.4358-1-dmaluka@chromium.org/
[2] https://lore.kernel.org/linux-iommu/20260107201800.2486137-1-skhawaja@google.com/

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/20260113150542.GF812923@nvidia.com/)
   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/20260113030052.977366-1-baolu.lu@linux.intel.com/

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(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2026-01-21  8:12 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-20  6:18 [PATCH v2 0/3] iommu/vt-d: Ensure atomicity in context and PASID entry updates Lu Baolu
2026-01-20  6:18 ` [PATCH v2 1/3] iommu/vt-d: Clear Present bit before tearing down PASID entry Lu Baolu
2026-01-20 13:56   ` Dmytro Maluka
2026-01-20 18:14     ` Samiullah Khawaja
2026-01-21  6:16   ` Tian, Kevin
2026-01-20  6:18 ` [PATCH v2 2/3] iommu/vt-d: Clear Present bit before tearing down context entry Lu Baolu
2026-01-20 14:07   ` Dmytro Maluka
2026-01-20 18:22   ` Samiullah Khawaja
2026-01-21  6:23   ` Tian, Kevin
2026-01-21  7:28     ` Baolu Lu
2026-01-21  7:50       ` Tian, Kevin
2026-01-21  8:04         ` Baolu Lu
2026-01-21  8:12           ` Tian, Kevin
2026-01-20  6:18 ` [PATCH v2 3/3] iommu/vt-d: Fix race condition during PASID entry replacement Lu Baolu
2026-01-20 18:54   ` Samiullah Khawaja
2026-01-21  6:23   ` Tian, Kevin
2026-01-20 13:56 ` [PATCH v2 0/3] iommu/vt-d: Ensure atomicity in context and PASID entry updates Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox