All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] iommu/vt-d: Ensure memory ordering in context & root entry updates
@ 2025-12-21  1:43 Dmytro Maluka
  2025-12-21  1:43 ` [PATCH 1/2] iommu/vt-d: Ensure memory ordering in context " Dmytro Maluka
  2025-12-21  1:43 ` [PATCH 2/2] iommu/vt-d: Use WRITE_ONCE for setting root table entries Dmytro Maluka
  0 siblings, 2 replies; 7+ messages in thread
From: Dmytro Maluka @ 2025-12-21  1:43 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

As discussed in [1], we don't currently prevent the compiler from
reordering memory writes when updating context entries, which is
potentially dangerous, as it may cause setting the present bit (i.e.
enabling DMA translation for the given device) before finishing setting
up other bits in the context entry (and thus creating a time window when
a DMA from the device may result in an unpredicted behavior).

Fix this in the same way as how this is already addressed for PASID
entries, i.e. by using READ_ONCE/WRITE_ONCE in the helpers used for
setting individual bits in context entries, so that memory writes done
by those helpers are ordered in relation to each other (plus, prevent
load/store tearing and so on).

While at it, similarly paranoidally fix updating root entries as well:
use WRITE_ONCE to make sure that the present bit is set atomically
together with the context table address bits, not before them.

[1] https://lore.kernel.org/all/aTG7gc7I5wExai3S@google.com/

Dmytro Maluka (2):
  iommu/vt-d: Ensure memory ordering in context entry updates
  iommu/vt-d: Use WRITE_ONCE for setting root table entries

 drivers/iommu/intel/iommu.c |  2 +-
 drivers/iommu/intel/iommu.h | 37 +++++++++++++++++++++----------------
 drivers/iommu/intel/pasid.c |  3 ++-
 3 files changed, 24 insertions(+), 18 deletions(-)

-- 
2.47.3


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

end of thread, other threads:[~2025-12-27 18:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-21  1:43 [PATCH 0/2] iommu/vt-d: Ensure memory ordering in context & root entry updates Dmytro Maluka
2025-12-21  1:43 ` [PATCH 1/2] iommu/vt-d: Ensure memory ordering in context " Dmytro Maluka
2025-12-21  9:04   ` Baolu Lu
2025-12-21 13:11     ` Dmytro Maluka
2025-12-23  6:10       ` Baolu Lu
2025-12-27 18:06         ` Dmytro Maluka
2025-12-21  1:43 ` [PATCH 2/2] iommu/vt-d: Use WRITE_ONCE for setting root table entries Dmytro Maluka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.