Skip to contentSkip to conversation

drm/msm: Limit command submission when no IOMMU

PATCH In review Rob Clark 3 participants 4 messages May 2, 2022 – May 4, 2022

Subsystems (3)
lore
Share & tools
lore

Rob Clark

author
#0 lore raw

PATCH 1/1 drm/msm: Limit command submission when no IOMMU

From: Rob Clark <[email protected]>

Running the GPU without an IOMMU is not really a supported (or sane) configuration. Yet it can be useful during SoC bringup (ie. if the iommu driver doesn't work yet).

Lets limit it to users who already have /dev/mem access, to avoid the chance that a user accidentially configures kernel without IOMMU support.

---
 drivers/gpu/drm/msm/msm_gem_submit.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/msm/msm_gem_submit.c +5 -0
index 23b68bc945f6..9cd8c8708990 100644
@@ -734,6 +734,11 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
 	if (args->pad)
 		return -EINVAL;
 
+	if (unlikely(!ctx->aspace) && !capable(CAP_SYS_RAWIO)) {
+		DRM_ERROR_RATELIMITED("IOMMU support or CAP_SYS_RAWIO required!\n");
+		return -EPERM;
+	}
+
 	/* for now, we just have 3d pipe.. eventually this would need to
 	 * be more clever to dispatch to appropriate gpu module:
 	 */
Signature · 1 line
2.35.1
#1 lore raw

Am Montag, dem 02.05.2022 um 10:29 -0700 schrieb Rob Clark:

Quoted 9 lines

From: Rob Clark <[email protected]>

Running the GPU without an IOMMU is not really a supported (or sane) configuration. Yet it can be useful during SoC bringup (ie. if the iommu driver doesn't work yet).

Lets limit it to users who already have /dev/mem access, to avoid the chance that a user accidentially configures kernel without IOMMU support.

I haven't followed MSM too closely, so ctx->aspace may also include the GPU MMU, but if this really only includes the IOMMU (as the commit message implies) then this breaks Freedreno on i.MX5.

Regards,
Lucas

Quoted 22 lines
---
 drivers/gpu/drm/msm/msm_gem_submit.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/msm/msm_gem_submit.c +5 -0
index 23b68bc945f6..9cd8c8708990 100644
@@ -734,6 +734,11 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
 	if (args->pad)
 		return -EINVAL;
 
+	if (unlikely(!ctx->aspace) && !capable(CAP_SYS_RAWIO)) {
+		DRM_ERROR_RATELIMITED("IOMMU support or CAP_SYS_RAWIO required!\n");
+		return -EPERM;
+	}
+
 	/* for now, we just have 3d pipe.. eventually this would need to
 	 * be more clever to dispatch to appropriate gpu module:
 	 */
author
#2 lore raw
Quoted 8 lines · Lucas Stach

Am Montag, dem 02.05.2022 um 10:29 -0700 schrieb Rob Clark:

Quoted 6 lines

From: Rob Clark <[email protected]>

Running the GPU without an IOMMU is not really a supported (or sane) configuration. Yet it can be useful during SoC bringup (ie. if the iommu driver doesn't work yet).

Quoted 7 lines
Quoted 3 lines

Lets limit it to users who already have /dev/mem access, to avoid the chance that a user accidentially configures kernel without IOMMU support.

I haven't followed MSM too closely, so ctx->aspace may also include the GPU MMU, but if this really only includes the IOMMU (as the commit message implies) then this breaks Freedreno on i.MX5.

it includes the gpu mmu, so a2xx should be fine.

BR,
-R

Quoted 27 lines

Regards,
Lucas

Quoted 22 lines
---
 drivers/gpu/drm/msm/msm_gem_submit.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/msm/msm_gem_submit.c +5 -0
index 23b68bc945f6..9cd8c8708990 100644
@@ -734,6 +734,11 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
      if (args->pad)
              return -EINVAL;
 
+     if (unlikely(!ctx->aspace) && !capable(CAP_SYS_RAWIO)) {
+             DRM_ERROR_RATELIMITED("IOMMU support or CAP_SYS_RAWIO required!\n");
+             return -EPERM;
+     }
+
      /* for now, we just have 3d pipe.. eventually this would need to
       * be more clever to dispatch to appropriate gpu module:
       */
Reviewed-by on v1 1/1
#3 lore raw
In reply to Rob Clark
Quoted 11 lines · Rob Clark

From: Rob Clark <[email protected]>

Running the GPU without an IOMMU is not really a supported (or sane) configuration. Yet it can be useful during SoC bringup (ie. if the iommu driver doesn't work yet).

Lets limit it to users who already have /dev/mem access, to avoid the chance that a user accidentially configures kernel without IOMMU support.

Quoted 20 lines
---
  drivers/gpu/drm/msm/msm_gem_submit.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/gpu/drm/msm/msm_gem_submit.c +5 -0
index 23b68bc945f6..9cd8c8708990 100644
@@ -734,6 +734,11 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
  	if (args->pad)
  		return -EINVAL;
 
+	if (unlikely(!ctx->aspace) && !capable(CAP_SYS_RAWIO)) {
+		DRM_ERROR_RATELIMITED("IOMMU support or CAP_SYS_RAWIO required!\n");
+		return -EPERM;
+	}
+
  	/* for now, we just have 3d pipe.. eventually this would need to
  	 * be more clever to dispatch to appropriate gpu module:
  	 */
Signature · 2 lines
With best wishes
Dmitry