drm/msm: Add modparam to allow vram carveout
authorIskren Chernev <iskren.chernev@gmail.com>
Wed, 30 Dec 2020 15:29:43 +0000 (17:29 +0200)
committerRob Clark <robdclark@chromium.org>
Thu, 7 Jan 2021 17:12:53 +0000 (09:12 -0800)
Using the GPU with a VRAM Carveout is a security vulnerability.
Nevertheless it is sometimes required, especially when no IOMMU
implementation is available for a certain platform.

Signed-off-by: Iskren Chernev <iskren.chernev@gmail.com>
Signed-off-by: Rob Clark <robdclark@chromium.org>
drivers/gpu/drm/msm/adreno/a2xx_gpu.c
drivers/gpu/drm/msm/adreno/a3xx_gpu.c
drivers/gpu/drm/msm/adreno/a4xx_gpu.c
drivers/gpu/drm/msm/adreno/adreno_device.c
drivers/gpu/drm/msm/adreno/adreno_gpu.h

index 7e82c41..bdc9891 100644 (file)
@@ -534,8 +534,10 @@ struct msm_gpu *a2xx_gpu_init(struct drm_device *dev)
 
        if (!gpu->aspace) {
                dev_err(dev->dev, "No memory protection without MMU\n");
-               ret = -ENXIO;
-               goto fail;
+               if (!allow_vram_carveout) {
+                       ret = -ENXIO;
+                       goto fail;
+               }
        }
 
        return gpu;
index 93da668..4534633 100644 (file)
@@ -564,8 +564,10 @@ struct msm_gpu *a3xx_gpu_init(struct drm_device *dev)
                 * implement a cmdstream validator.
                 */
                DRM_DEV_ERROR(dev->dev, "No memory protection without IOMMU\n");
-               ret = -ENXIO;
-               goto fail;
+               if (!allow_vram_carveout) {
+                       ret = -ENXIO;
+                       goto fail;
+               }
        }
 
        icc_path = devm_of_icc_get(&pdev->dev, "gfx-mem");
index c0be3a0..82bebb4 100644 (file)
@@ -692,8 +692,10 @@ struct msm_gpu *a4xx_gpu_init(struct drm_device *dev)
                 * implement a cmdstream validator.
                 */
                DRM_DEV_ERROR(dev->dev, "No memory protection without IOMMU\n");
-               ret = -ENXIO;
-               goto fail;
+               if (!allow_vram_carveout) {
+                       ret = -ENXIO;
+                       goto fail;
+               }
        }
 
        icc_path = devm_of_icc_get(&pdev->dev, "gfx-mem");
index 87c8b03..12e75ba 100644 (file)
@@ -18,6 +18,10 @@ bool snapshot_debugbus = false;
 MODULE_PARM_DESC(snapshot_debugbus, "Include debugbus sections in GPU devcoredump (if not fused off)");
 module_param_named(snapshot_debugbus, snapshot_debugbus, bool, 0600);
 
+bool allow_vram_carveout = false;
+MODULE_PARM_DESC(allow_vram_carveout, "Allow using VRAM Carveout, in place of IOMMU");
+module_param_named(allow_vram_carveout, allow_vram_carveout, bool, 0600);
+
 static const struct adreno_info gpulist[] = {
        {
                .rev   = ADRENO_REV(2, 0, 0, 0),
index c3775f7..fe5444a 100644 (file)
@@ -18,6 +18,7 @@
 #include "adreno_pm4.xml.h"
 
 extern bool snapshot_debugbus;
+extern bool allow_vram_carveout;
 
 enum {
        ADRENO_FW_PM4 = 0,