[1/4] drm/amdgpu: restrict userptr even more

Submitted by Christian König on Aug. 30, 2017, 3 p.m.

Details

Message ID 1504105209-1558-1-git-send-email-deathsimple@vodafone.de
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in AMD X.Org drivers

Browsing this patch as part of:
"Series without cover letter" rev 1 in AMD X.Org drivers
<< prev patch [1/4] next patch >>

Commit Message

Christian König Aug. 30, 2017, 3 p.m.
From: Christian König <christian.koenig@amd.com>

Don't allow them to be GEM imported into another process.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 6 ++++++
 1 file changed, 6 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index d028806..e32a2b5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -112,7 +112,13 @@  int amdgpu_gem_object_open(struct drm_gem_object *obj,
 	struct amdgpu_fpriv *fpriv = file_priv->driver_priv;
 	struct amdgpu_vm *vm = &fpriv->vm;
 	struct amdgpu_bo_va *bo_va;
+	struct mm_struct *mm;
 	int r;
+
+	mm = amdgpu_ttm_tt_get_usermm(abo->tbo.ttm);
+	if (mm && mm != current->mm)
+		return -EPERM;
+
 	r = amdgpu_bo_reserve(abo, false);
 	if (r)
 		return r;

Comments

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>

John and I were wondering whether this is redundant because
amdgpu_gem_prime_export already prevents exporting of userptr BOs.
However, I just realized this is not for prime buffer sharing but the
GEM_FLINK buffer sharing API. It doesn't have a driver callback in
GEM_FLINK, so the only chance to prevent sharing userptrs is in GEM_OPEN.

As I understand it, this doesn't add any new fundamental limitation,
just enforces it in a different situation.

Regards,
  Felix


On 2017-08-30 11:00 AM, Christian König wrote:
> From: Christian König <christian.koenig@amd.com>
>
> Don't allow them to be GEM imported into another process.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> index d028806..e32a2b5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> @@ -112,7 +112,13 @@ int amdgpu_gem_object_open(struct drm_gem_object *obj,
>  	struct amdgpu_fpriv *fpriv = file_priv->driver_priv;
>  	struct amdgpu_vm *vm = &fpriv->vm;
>  	struct amdgpu_bo_va *bo_va;
> +	struct mm_struct *mm;
>  	int r;
> +
> +	mm = amdgpu_ttm_tt_get_usermm(abo->tbo.ttm);
> +	if (mm && mm != current->mm)
> +		return -EPERM;
> +
>  	r = amdgpu_bo_reserve(abo, false);
>  	if (r)
>  		return r;
Acked-by: Chunming Zhou <david1.zhou@amd.com>, For the other three, we'd 
better to wait for our UMD guys tests.


On 2017年08月30日 23:00, Christian König wrote:
> From: Christian König <christian.koenig@amd.com>
>
> Don't allow them to be GEM imported into another process.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> index d028806..e32a2b5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> @@ -112,7 +112,13 @@ int amdgpu_gem_object_open(struct drm_gem_object *obj,
>   	struct amdgpu_fpriv *fpriv = file_priv->driver_priv;
>   	struct amdgpu_vm *vm = &fpriv->vm;
>   	struct amdgpu_bo_va *bo_va;
> +	struct mm_struct *mm;
>   	int r;
> +
> +	mm = amdgpu_ttm_tt_get_usermm(abo->tbo.ttm);
> +	if (mm && mm != current->mm)
> +		return -EPERM;
> +
>   	r = amdgpu_bo_reserve(abo, false);
>   	if (r)
>   		return r;