From: CMY Date: Fri, 22 May 2015 09:26:42 +0000 (+0800) Subject: rk: iommu: support iommu region guard X-Git-Tag: firefly_0821_release~4098 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=47b2346ab1caaa80188a6ecb73dbe4fc249858d4;p=firefly-linux-kernel-4.4.55.git rk: iommu: support iommu region guard Add an guard area after each iommu region, it is used to detect cross-border access Signed-off-by: CMY Signed-off-by: XXM --- diff --git a/drivers/iommu/rockchip-iovmm.c b/drivers/iommu/rockchip-iovmm.c index 595b75c23d04..29f885fc0275 100644 --- a/drivers/iommu/rockchip-iovmm.c +++ b/drivers/iommu/rockchip-iovmm.c @@ -19,6 +19,8 @@ #include "rockchip-iommu.h" +#define IOMMU_REGION_GUARD (2<vmm_pool, size); + start = (dma_addr_t)gen_pool_alloc(vmm->vmm_pool, + size+IOMMU_REGION_GUARD); if (!start) { ret = -ENOMEM; goto err_map_noiomem; @@ -197,7 +200,8 @@ void rockchip_iovmm_unmap(struct device *dev, dma_addr_t iova) /* rockchip_iommu_tlb_invalidate(dev); */ - gen_pool_free(vmm->vmm_pool, region->start, region->size); + gen_pool_free(vmm->vmm_pool, region->start, + region->size+IOMMU_REGION_GUARD); WARN_ON(unmapped_size != region->size);