aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/1472-drm-ttm-Quick-test-mmap-offset-in-ttm_bo_mmap.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/1472-drm-ttm-Quick-test-mmap-offset-in-ttm_bo_mmap.patch')
-rw-r--r--meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/1472-drm-ttm-Quick-test-mmap-offset-in-ttm_bo_mmap.patch73
1 files changed, 73 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/1472-drm-ttm-Quick-test-mmap-offset-in-ttm_bo_mmap.patch b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/1472-drm-ttm-Quick-test-mmap-offset-in-ttm_bo_mmap.patch
new file mode 100644
index 00000000..75fa7f77
--- /dev/null
+++ b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/1472-drm-ttm-Quick-test-mmap-offset-in-ttm_bo_mmap.patch
@@ -0,0 +1,73 @@
+From 45d9b50db67601ef7e4e1185590d3831c9c57298 Mon Sep 17 00:00:00 2001
+From: Thomas Zimmermann <tzimmermann@suse.de>
+Date: Thu, 7 Feb 2019 09:59:30 +0100
+Subject: [PATCH 1472/2940] drm/ttm: Quick-test mmap offset in ttm_bo_mmap()
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+A BO's address has to be at least the minimum offset. Sharing this
+test in ttm_bo_mmap() removes code from drivers. A full buffer-address
+validation is still done within drm_vma_offset_lockup_locked().
+
+Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
+Reviewed-by: Christian König <christian.koenig@amd.com>
+Acked-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: kalyan Alle <kalyan.alle@amd.com>
+---
+ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 9 ++-------
+ drivers/gpu/drm/ttm/ttm_bo_vm.c | 3 +++
+ include/drm/ttm/ttm_bo_driver.h | 2 ++
+ 3 files changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+index ac54a750fe3b..822add55c77d 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+@@ -2141,14 +2141,9 @@ void amdgpu_ttm_set_buffer_funcs_status(struct amdgpu_device *adev, bool enable)
+
+ int amdgpu_mmap(struct file *filp, struct vm_area_struct *vma)
+ {
+- struct drm_file *file_priv;
+- struct amdgpu_device *adev;
+-
+- if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET))
+- return -EINVAL;
++ struct drm_file *file_priv = filp->private_data;
++ struct amdgpu_device *adev = file_priv->minor->dev->dev_private;
+
+- file_priv = filp->private_data;
+- adev = file_priv->minor->dev->dev_private;
+ if (adev == NULL)
+ return -EINVAL;
+
+diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
+index 6fe91c1b692d..f1114a6e6b1e 100644
+--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
++++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
+@@ -428,6 +428,9 @@ int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma,
+ struct ttm_buffer_object *bo;
+ int ret;
+
++ if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET))
++ return -EINVAL;
++
+ bo = ttm_bo_vm_lookup(bdev, vma->vm_pgoff, vma_pages(vma));
+ if (unlikely(!bo))
+ return -EINVAL;
+diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
+index 17e20781ca7a..662b823339f5 100644
+--- a/include/drm/ttm/ttm_bo_driver.h
++++ b/include/drm/ttm/ttm_bo_driver.h
+@@ -50,6 +50,8 @@
+ #define TTM_MEMTYPE_FLAG_MAPPABLE (1 << 1) /* Memory mappable */
+ #define TTM_MEMTYPE_FLAG_CMA (1 << 3) /* Can't map aperture */
+
++#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
++
+ struct ttm_mem_type_manager;
+
+ struct ttm_mem_type_manager_func {
+--
+2.17.1
+