drm/msm: Disallow foreign mapping of _NO_SHARE
Rob Clark
maintainerPATCH 1/2 drm/msm: Disallow foreign mapping of _NO_SHARE
This restriction applies to mapping of _NO_SHARE objs in the kms vm as well as importing/exporting BOs. Since the DPU has it's own VM, scanout counts as "exporting" a BO from outside of it's host VM.
---
v2: Fix issue with MAP_NULL
drivers/gpu/drm/msm/msm_gem_vma.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/msm/msm_gem_vma.c +6 -0
@@ -373,6 +373,12 @@ msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj,struct msm_gem_vma *vma;int ret; +/* _NO_SHARE objs cannot be mapped outside of their "host" vm: */ +if (obj && (to_msm_bo (obj)->flags &MSM_BO_NO_SHARE ) && +GEM_WARN_ON (obj->resv !=drm_gpuvm_resv (gpuvm))) { +return ERR_PTR (-EINVAL ); + } +drm_gpuvm_resv_assert_held (&vm->base); vma =kzalloc (sizeof (*vma),GFP_KERNEL );
Signature · 1 line
2.53.0
Rob Clark
maintainerPATCH 2/2 drm/msm: Fix VM_BIND UNMAP locking
Wrong argument meant that the objs involved in UNMAP ops were not always getting locked.
Since _NO_SHARE objs share a common resv with the VM (which is always locked) this would only show up with non-_NO_SHARE BOs.
---
v2: Add tags
drivers/gpu/drm/msm/msm_gem_vma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_gem_vma.c +1 -1
@@ -1251,7 +1251,7 @@ vm_bind_job_lock_objects(struct msm_vm_bind_job *job, struct drm_exec *exec)case MSM_VM_BIND_OP_UNMAP : ret =drm_gpuvm_sm_unmap_exec_lock (job->vm, exec, op->iova, - op->obj_offset); + op->range);break ;case MSM_VM_BIND_OP_MAP :case MSM_VM_BIND_OP_MAP_NULL : {
Signature · 1 line
2.53.0
Quoted 16 lines · Rob Clark
This restriction applies to mapping of
_NO_SHAREobjs in the kms vm as well as importing/exporting BOs. Since the DPU has it's own VM, scanout counts as "exporting" a BO from outside of it's host VM.Signed-off-by Rob Clark <[email protected]>---
v2: Fix issue withMAP_NULLdrivers/gpu/drm/msm/msm_gem_vma.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/msm/msm_gem_vma.c +0
-0
drivers/gpu/drm/msm/msm_gem_vma.c msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj, · line 378
Quoted 6 lines
drivers/gpu/drm/msm/msm_gem_vma.c +3
-0@@ -373,6 +373,12 @@ msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj,struct msm_gem_vma *vma;int ret; +/* _NO_SHARE objs cannot be mapped outside of their "host" vm: */ +if (obj && (to_msm_bo (obj)->flags &MSM_BO_NO_SHARE ) && +GEM_WARN_ON (obj->resv !=drm_gpuvm_resv (gpuvm))) {
Can this be used to spam the logs?
Quoted 9 lines
drivers/gpu/drm/msm/msm_gem_vma.c +3
-0+return ERR_PTR (-EINVAL ); + } +drm_gpuvm_resv_assert_held (&vm->base); vma =kzalloc (sizeof (*vma),GFP_KERNEL );Signature · 1 line
2.53.0
Signature · 2 lines
With best wishes Dmitry
Quoted 21 lines · Dmitry Baryshkov
Quoted 19 lines · Rob Clark
This restriction applies to mapping of
_NO_SHAREobjs in the kms vm as well as importing/exporting BOs. Since the DPU has it's own VM, scanout counts as "exporting" a BO from outside of it's host VM.Signed-off-by Rob Clark <[email protected]>---
v2: Fix issue withMAP_NULLdrivers/gpu/drm/msm/msm_gem_vma.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/msm/msm_gem_vma.c +0
-0@@ -373,6 +373,12 @@ msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj,struct msm_gem_vma *vma;int ret;
Quoted 5 lines
drivers/gpu/drm/msm/msm_gem_vma.c msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj, · line 378
Quoted 3 lines
drivers/gpu/drm/msm/msm_gem_vma.c +3
-0+/* _NO_SHARE objs cannot be mapped outside of their "host" vm: */ +if (obj && (to_msm_bo (obj)->flags &MSM_BO_NO_SHARE ) && +GEM_WARN_ON (obj->resv !=drm_gpuvm_resv (gpuvm))) {Can this be used to spam the logs?
yeah, perhaps it should use UERR() instead
Quoted 14 lines
Quoted 10 lines
drivers/gpu/drm/msm/msm_gem_vma.c +3
-1+return ERR_PTR (-EINVAL ); + } +drm_gpuvm_resv_assert_held (&vm->base); vma =kzalloc (sizeof (*vma),GFP_KERNEL ); --2.53.0
--
With best wishes
Dmitry
Quoted 24 lines · Rob Clark
Quoted 21 lines · Dmitry Baryshkov
Quoted 19 lines · Rob Clark
This restriction applies to mapping of
_NO_SHAREobjs in the kms vm as well as importing/exporting BOs. Since the DPU has it's own VM, scanout counts as "exporting" a BO from outside of it's host VM.Signed-off-by Rob Clark <[email protected]>---
v2: Fix issue withMAP_NULLdrivers/gpu/drm/msm/msm_gem_vma.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/msm/msm_gem_vma.c +0
-0@@ -373,6 +373,12 @@ msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj,struct msm_gem_vma *vma;int ret;
Quoted 7 lines
Quoted 5 lines
drivers/gpu/drm/msm/msm_gem_vma.c msm_gem_vma_new(struct drm_gpuvm *gpuvm, struct drm_gem_object *obj, · line 378
Quoted 3 lines
drivers/gpu/drm/msm/msm_gem_vma.c +3
-0+/* _NO_SHARE objs cannot be mapped outside of their "host" vm: */ +if (obj && (to_msm_bo (obj)->flags &MSM_BO_NO_SHARE ) && +GEM_WARN_ON (obj->resv !=drm_gpuvm_resv (gpuvm))) {Can this be used to spam the logs?
yeah, perhaps it should use
UERR()instead
So, for the case that I was concerned about, we should actually just reject creating a drm fb from _NO_SHARE BO(s) (and report error w/ UERR()). I'll send a patch for that. With that, I think it is safe to keep this WARN_ON(), since the only path to hit it should be a driver bug.
BR,
-R
Quoted 14 lines
Quoted 14 lines
Quoted 10 lines
drivers/gpu/drm/msm/msm_gem_vma.c +3
-1+return ERR_PTR (-EINVAL ); + } +drm_gpuvm_resv_assert_held (&vm->base); vma =kzalloc (sizeof (*vma),GFP_KERNEL ); --2.53.0
--
With best wishes
Dmitry