Skip to content

Commit 6fabce5

Browse files
nicolincwilldeacon
authored andcommitted
iommu/arm-smmu-v3: Add a missing dma_wmb() for hitless STE update
When writing a new (previously invalid) valid IOPTE to a page table, then installing the page table into an STE hitlesslessly (e.g. in S2TTB field), there is a window before an STE invalidation, where the page-table may be accessed by SMMU but the new IOPTE is still siting in the CPU cache. This could occur when we allocate an iommu_domain and immediately install it hitlessly, while there would be no dma_wmb() for the page table memory prior to the earliest point of HW reading the STE. Fix it by adding a dma_wmb() prior to updating the STE. Fixes: 56e1a4c ("iommu/arm-smmu-v3: Add unit tests for arm_smmu_write_entry") Cc: stable@vger.kernel.org Reported-by: Will Deacon <will@kernel.org> Closes: https://lore.kernel.org/linux-iommu/aXdlnLLFUBwjT0V5@willie-the-truck/ Suggested-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Will Deacon <will@kernel.org>
1 parent f338e77 commit 6fabce5

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,13 @@ void arm_smmu_write_entry(struct arm_smmu_entry_writer *writer, __le64 *entry,
12361236
__le64 unused_update[NUM_ENTRY_QWORDS];
12371237
u8 used_qword_diff;
12381238

1239+
/*
1240+
* Many of the entry structures have pointers to other structures that
1241+
* need to have their updates be visible before any writes of the entry
1242+
* happen.
1243+
*/
1244+
dma_wmb();
1245+
12391246
used_qword_diff =
12401247
arm_smmu_entry_qword_diff(writer, entry, target, unused_update);
12411248
if (hweight8(used_qword_diff) == 1) {

0 commit comments

Comments
 (0)