Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0675bae authored by Patrick Daly's avatar Patrick Daly
Browse files

arm64: dma-mapping: Ensure iova range within dma_mask



For devices behind an iommu, add a check to ensure the requested iova
range is supported by the device's dma mask.

Change-Id: Ic8ed9c7525ac40b905405589c29fb9384bfaccde
Signed-off-by: default avatarPatrick Daly <pdaly@codeaurora.org>
parent 4ee91b18
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1995,6 +1995,7 @@ int arm_iommu_attach_device(struct device *dev,
	int err;
	int s1_bypass = 0, is_fast = 0;
	struct iommu_group *group;
	dma_addr_t iova_end;

	group = dev->iommu_group;
	if (!group) {
@@ -2007,6 +2008,13 @@ int arm_iommu_attach_device(struct device *dev,
		return -EINVAL;
	}

	iova_end = mapping->base + (mapping->bits << PAGE_SHIFT) - 1;
	if (iova_end > dma_get_mask(dev)) {
		dev_err(dev, "dma mask %llx too small for requested iova range %pad to %pad\n",
			dma_get_mask(dev), &mapping->base, &iova_end);
		return -EINVAL;
	}

	iommu_domain_get_attr(mapping->domain, DOMAIN_ATTR_FAST, &is_fast);
	if (is_fast)
		return fast_smmu_attach_device(dev, mapping);