Skip to content

Commit dead723

Browse files
Isaac J. Manjarreswilldeacon
authored andcommitted
iommu/arm-smmu-qcom: Fix mask extraction for bootloader programmed SMRs
When extracting the mask for a SMR that was programmed by the bootloader, the SMR's valid bit is also extracted and is treated as part of the mask, which is not correct. Consider the scenario where an SMMU master whose context is determined by a bootloader programmed SMR is removed (omitting parts of device/driver core): ->iommu_release_device() -> arm_smmu_release_device() -> arm_smmu_master_free_smes() -> arm_smmu_free_sme() /* Assume that the SME is now free */ -> arm_smmu_write_sme() -> arm_smmu_write_smr() /* Construct SMR value using mask and SID */ Since the valid bit was considered as part of the mask, the SMR will be programmed as valid. Fix the SMR mask extraction step for bootloader programmed SMRs by masking out the valid bit when we know that we're already working with a valid SMR. Fixes: 07a7f2c ("iommu/arm-smmu-qcom: Read back stream mappings") Signed-off-by: Isaac J. Manjarres <[email protected]> Cc: [email protected] Reviewed-by: Robin Murphy <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 9111aeb commit dead723

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ static int qcom_smmu_cfg_probe(struct arm_smmu_device *smmu)
207207
smr = arm_smmu_gr0_read(smmu, ARM_SMMU_GR0_SMR(i));
208208

209209
if (FIELD_GET(ARM_SMMU_SMR_VALID, smr)) {
210+
/* Ignore valid bit for SMR mask extraction. */
211+
smr &= ~ARM_SMMU_SMR_VALID;
210212
smmu->smrs[i].id = FIELD_GET(ARM_SMMU_SMR_ID, smr);
211213
smmu->smrs[i].mask = FIELD_GET(ARM_SMMU_SMR_MASK, smr);
212214
smmu->smrs[i].valid = true;

0 commit comments

Comments
 (0)