Skip to contentSkip to conversation

iommu/arm-smmu-v3: Ensure we sync STE when only changing config field

PATCH New Will Deacon 3 participants 3 messages Oct 5, 2017 – Oct 6, 2017 IOMMU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/arm-smmu-v3: Ensure we sync STE when only changing config field

The SMMUv3 architecture permits caching of data structures deemed to be "reachable" by the SMU, which includes STEs marked as invalid. When transitioning an STE to a bypass/fault configuration at init or detach time, we mistakenly elide the CMDQ_OP_CFGI_STE operation in some cases, therefore potentially leaving the old STE state cached in the SMMU.

This patch fixes the problem by ensuring that we perform the CMDQ_OP_CFGI_STE operation irrespective of the validity of the previous STE.

---
 drivers/iommu/arm-smmu-v3.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iommu/arm-smmu-v3.c +5 -2
index 47f52b1ab838..91fdabdb4de6 100644
@@ -1085,8 +1085,11 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_device *smmu, u32 sid,
 		dst[1] = cpu_to_le64(STRTAB_STE_1_SHCFG_INCOMING
 			 << STRTAB_STE_1_SHCFG_SHIFT);
 		dst[2] = 0; /* Nuke the VMID */
-		if (ste_live)
-			arm_smmu_sync_ste_for_sid(smmu, sid);
+		/*
+		 * The SMMU can perform negative caching, so we must sync
+		 * the STE regardless of whether the old value was live.
+		 */
+		arm_smmu_sync_ste_for_sid(smmu, sid);
 		return;
 	}
 
Signature · 1 line
2.1.4
reviewer
#1 lore raw

PATCH 1/1 iommu/arm-smmu-v3: Ensure we sync STE when only changing config field

Quoted 9 lines · Will Deacon

The SMMUv3 architecture permits caching of data structures deemed to be "reachable" by the SMU, which includes STEs marked as invalid. When transitioning an STE to a bypass/fault configuration at init or detach time, we mistakenly elide the CMDQ_OP_CFGI_STE operation in some cases, therefore potentially leaving the old STE state cached in the SMMU.

This patch fixes the problem by ensuring that we perform the CMDQ_OP_CFGI_STE operation irrespective of the validity of the previous STE.

Quoted 26 lines
---
 drivers/iommu/arm-smmu-v3.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iommu/arm-smmu-v3.c +5 -2
index 47f52b1ab838..91fdabdb4de6 100644
@@ -1085,8 +1085,11 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_device *smmu, u32 sid,
 		dst[1] = cpu_to_le64(STRTAB_STE_1_SHCFG_INCOMING
 			 << STRTAB_STE_1_SHCFG_SHIFT);
 		dst[2] = 0; /* Nuke the VMID */
-		if (ste_live)
-			arm_smmu_sync_ste_for_sid(smmu, sid);
+		/*
+		 * The SMMU can perform negative caching, so we must sync
+		 * the STE regardless of whether the old value was live.
+		 */
+		arm_smmu_sync_ste_for_sid(smmu, sid);
 		return;
 	}
 
#2 lore raw

PATCH 1/1 iommu/arm-smmu-v3: Ensure we sync STE when only changing config field

Hi Will,

Quoted 7 lines · Robin Murphy
Quoted 6 lines · Will Deacon

The SMMUv3 architecture permits caching of data structures deemed to be "reachable" by the SMU, which includes STEs marked as invalid. When transitioning an STE to a bypass/fault configuration at init or detach time, we mistakenly elide the CMDQ_OP_CFGI_STE operation in some cases, therefore potentially leaving the old STE state cached in the SMMU.

Quoted 5 lines
Quoted 3 lines

This patch fixes the problem by ensuring that we perform the CMDQ_OP_CFGI_STE operation irrespective of the validity of the previous STE.

Thanks

Eric

Quoted 34 lines
Quoted 17 lines
---
 drivers/iommu/arm-smmu-v3.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iommu/arm-smmu-v3.c +0 -0
index 47f52b1ab838..91fdabdb4de6 100644
@@ -1085,8 +1085,11 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_device *smmu, u32 sid,
 		dst[1] = cpu_to_le64(STRTAB_STE_1_SHCFG_INCOMING
 			 << STRTAB_STE_1_SHCFG_SHIFT);
 		dst[2] = 0; /* Nuke the VMID */

drivers/iommu/arm-smmu-v3.c static void arm_smmu_write_strtab_ent(struct arm_smmu_device *smmu, u32 sid, · line 1095

Quoted 10 lines
drivers/iommu/arm-smmu-v3.c +5 -2
-		if (ste_live)
-			arm_smmu_sync_ste_for_sid(smmu, sid);
+		/*
+		 * The SMMU can perform negative caching, so we must sync
+		 * the STE regardless of whether the old value was live.
+		 */
+		arm_smmu_sync_ste_for_sid(smmu, sid);
 		return;
 	}
 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel