From: Christian König Date: Wed, 13 May 2015 12:30:53 +0000 (+0200) Subject: drm/amdgpu: enforce AMDGPU_GEM_CREATE_NO_CPU_ACCESS X-Git-Tag: v5.15~15474^2~25^2~31 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=271c81256612b162a9ae0f8c0f0a055a7523cea5;p=mirror_ubuntu-kernels.git drm/amdgpu: enforce AMDGPU_GEM_CREATE_NO_CPU_ACCESS Deny user and kernel mapping if we said we never want to do so. Signed-off-by: Christian König Reviewed-by: Jammy Zhou Reviewed-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index 5fd0bc73b302..8dd843da799f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -316,7 +316,8 @@ int amdgpu_mode_dumb_mmap(struct drm_file *filp, return -ENOENT; } robj = gem_to_amdgpu_bo(gobj); - if (amdgpu_ttm_tt_has_userptr(robj->tbo.ttm)) { + if (amdgpu_ttm_tt_has_userptr(robj->tbo.ttm) || + (robj->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)) { drm_gem_object_unreference_unlocked(gobj); return -EPERM; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 992b7f5843bc..a721f5044557 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -263,6 +263,9 @@ int amdgpu_bo_kmap(struct amdgpu_bo *bo, void **ptr) bool is_iomem; int r; + if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) + return -EPERM; + if (bo->kptr) { if (ptr) { *ptr = bo->kptr;