android: ion: confirm to unmap invalid secure iova
authorhyesoo.yu <hyesoo.yu@samsung.com>
Fri, 20 Apr 2018 08:19:55 +0000 (17:19 +0900)
committerSangwook Ju <sw.ju@samsung.com>
Mon, 14 May 2018 10:45:26 +0000 (19:45 +0900)
Change-Id: Ifc926d9f85bed09c7c953fd4126f8a22e9c16e76
Signed-off-by: hyesoo.yu <hyesoo.yu@samsung.com>
drivers/staging/android/ion/ion_exynos.c

index 21d4b2e74040d55ed9bae3e59bf03d4f27fd2518..5b3c07a872808b764a0d46a95c733016f760c114 100644 (file)
@@ -133,6 +133,17 @@ void ion_iovmm_unmap(struct dma_buf_attachment *attachment, dma_addr_t iova)
        struct ion_iovm_map *iovm_map;
        struct iommu_domain *domain;
 
+       if (IS_ENABLED(CONFIG_EXYNOS_CONTENT_PATH_PROTECTION) &&
+           (buffer->flags & ION_FLAG_PROTECTED)) {
+               struct ion_buffer_prot_info *prot = buffer->priv_virt;
+
+               if (prot->dma_addr != iova)
+                       WARN(1, "unmap invalid secure iova %pad for %#x\n",
+                            &iova, (int)prot->dma_addr);
+
+               return;
+       }
+
        domain = get_domain_from_dev(attachment->dev);
        if (!domain) {
                dev_err(attachment->dev, "%s: no iommu domain\n", __func__);
@@ -148,7 +159,8 @@ void ion_iovmm_unmap(struct dma_buf_attachment *attachment, dma_addr_t iova)
                }
        }
 
-       WARN(1, "iova %pad found for %s\n", &iova, dev_name(attachment->dev));
+       WARN(1, "iova %pad not found for %s\n",
+            &iova, dev_name(attachment->dev));
 }
 
 /*