Commit 3c34da03 authored by Kunkun Jiang's avatar Kunkun Jiang Committed by Jia Qingtong
Browse files

iommu/arm-smmu-v3: Realize sync_dirty_log iommu ops

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


CVE: NA

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

This realizes sync_dirty_log iommu ops based on sync_dirty_log
io-pgtable ops.

Signed-off-by: default avatarKeqian Zhu <zhukeqian1@huawei.com>
Signed-off-by: default avatarKunkun Jiang <jiangkunkun@huawei.com>
Signed-off-by: default avatarjiaqingtong <jiaqingtong@huawei.com>
parent eba349fa
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -2985,6 +2985,35 @@ static int arm_smmu_switch_dirty_log(struct iommu_domain *domain, bool enable,
	return 0;
}

static int arm_smmu_sync_dirty_log(struct iommu_domain *domain,
				   unsigned long iova, size_t size,
				   unsigned long *bitmap,
				   unsigned long base_iova,
				   unsigned long bitmap_pgshift)
{
	struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
	struct io_pgtable_ops *ops = smmu_domain->pgtbl_ops;
	struct arm_smmu_device *smmu = smmu_domain->smmu;

	if (!(smmu->features & ARM_SMMU_FEAT_HD))
		return -ENODEV;
	if (smmu_domain->stage != ARM_SMMU_DOMAIN_S1)
		return -EINVAL;

	if (!ops || !ops->sync_dirty_log) {
		pr_err("io-pgtable don't realize sync dirty log\n");
		return -ENODEV;
	}

	/*
	 * Flush iotlb to ensure all inflight transactions are completed.
	 * See doc IHI0070Da 3.13.4 "HTTU behavior summary".
	 */
	arm_smmu_flush_iotlb_all(domain);
	return ops->sync_dirty_log(ops, iova, size, bitmap, base_iova,
				   bitmap_pgshift);
}

static int arm_smmu_of_xlate(struct device *dev, struct of_phandle_args *args)
{
	return iommu_fwspec_add_ids(dev, args->args, 1);
@@ -3121,6 +3150,7 @@ static struct iommu_ops arm_smmu_ops = {
		.iova_to_phys		= arm_smmu_iova_to_phys,
		.enable_nesting		= arm_smmu_enable_nesting,
		.switch_dirty_log	= arm_smmu_switch_dirty_log,
		.sync_dirty_log		= arm_smmu_sync_dirty_log,
		.free			= arm_smmu_domain_free,
	}
};