Like context table entries (addressed in the previous patches), root
table entries may also be set up at runtime, when DMA translation is
already enabled (e.g. due to a device hotplug). So to stay on the safe
side, use WRITE_ONCE when setting a root table entry, to prevent the
compiler from doing store tearing which could result in setting the
present bit earlier than the context table address bits.
Signed-off-by: Dmytro Maluka <dmaluka@chromium.org>
---
drivers/iommu/intel/iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 134302fbcd92..fe4d0d210a5f 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -374,7 +374,7 @@ struct context_entry *iommu_context_addr(struct intel_iommu *iommu, u8 bus,
__iommu_flush_cache(iommu, (void *)context, CONTEXT_SIZE);
phy_addr = virt_to_phys((void *)context);
- *entry = phy_addr | 1;
+ WRITE_ONCE(*entry, phy_addr | 1);
__iommu_flush_cache(iommu, entry, sizeof(*entry));
}
return &context[devfn];
--
2.47.3