Commit f7cdf692 authored by Kunkun Jiang's avatar Kunkun Jiang Committed by Zheng Zengkai
Browse files

iommu/arm-smmu-v3: Standardize granule size when support RIL

virt inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I401IF


CVE: NA

------------------------------

In __arm_smmu_tlb_inv_range(), the field 'ttl' of TLB invalidation
command is caculated based on granule size when the SMMU supports
RIL. There are some scenarious we need to avoid, which are pointed
out in the SMMUv3 spec(page 143-144, Version D.a). Adding a check
to ensure that the granule size is supported by the SMMU before set
the 'ttl' value.

Reported-by: default avatarNianyao Tang <tangnianyao@huawei.com>
Signed-off-by: default avatarKunkun Jiang <jiangkunkun@huawei.com>
Reviewed-by: default avatarKeqian Zhu <zhukeqian1@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 8f1d8ede
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2088,6 +2088,11 @@ static void __arm_smmu_tlb_inv_range(struct arm_smmu_cmdq_ent *cmd,
		cmd->tlbi.tg = (tg - 10) / 2;

		/* Determine what level the granule is at */
		if (!(granule & smmu_domain->domain.pgsize_bitmap) ||
		    (granule & (granule - 1))) {
			granule = leaf_pgsize;
			iova = ALIGN_DOWN(iova, leaf_pgsize);
		}
		cmd->tlbi.ttl = 4 - ((ilog2(granule) - 3) / (tg - 3));

		/* Align size with the leaf page size upwards */