From 8b27d2333a80a081caf5deb7c17f67f6d2efd3c3 Mon Sep 17 00:00:00 2001 From: "Isaac J. Manjarres" Date: Fri, 22 Jan 2021 15:35:34 -0800 Subject: [PATCH] iommu/arm-smmu: Fix SMR mask extraction for bootloader programmed SMRs When extracting the mask for an SMR that was programmed by the bootloader, the SMR.valid field is also extracted and is treated as part of the mask. This causes issues when removing an SMMU master, as removing the master involves constructing an SMR entry with the mask and SID without the valid bit set and writing that value to the SMR. However, since the valid bit was part of the mask, the SMR will still be valid. Instead, remove the valid bit from the raw SMR value that is used for extracting the SMR mask. Change-Id: Iccada2c474b196200ae1b56eb9faa9cb026f5ef1 Signed-off-by: Isaac J. Manjarres --- drivers/iommu/arm-smmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index fc6aa7448c3d..69a61fe4dfd4 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -4387,7 +4387,7 @@ static int arm_smmu_handoff_cbs(struct arm_smmu_device *smmu) if (!(raw_smr & SMR_VALID)) continue; - smr.mask = FIELD_GET(SMR_MASK, raw_smr); + smr.mask = FIELD_GET(SMR_MASK, raw_smr & ~SMR_VALID); smr.id = FIELD_GET(SMR_ID, raw_smr); smr.valid = true;