Skip to content

Commit 7b368ec

Browse files
alexdeuchersmb49
authored andcommitted
drm/amdkfd: don't allow mapping the MMIO HDP page with large pages
BugLink: https://bugs.launchpad.net/bugs/2080594 commit be4a2a81b6b90d1a47eaeaace4cc8e2cb57b96c7 upstream. We don't get the right offset in that case. The GPU has an unused 4K area of the register BAR space into which you can remap registers. We remap the HDP flush registers into this space to allow userspace (CPU or GPU) to flush the HDP when it updates VRAM. However, on systems with >4K pages, we end up exposing PAGE_SIZE of MMIO space. Fixes: d8e408a ("drm/amdkfd: Expose HDP registers to user space") Reviewed-by: Felix Kuehling <felix.kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org Signed-off-by: Felix Kuehling <felix.kuehling@amd.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Koichiro Den <koichiro.den@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 31d8219 commit 7b368ec

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,7 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep,
12901290
goto err_unlock;
12911291
}
12921292
offset = amdgpu_amdkfd_get_mmio_remap_phys_addr(dev->kgd);
1293-
if (!offset) {
1293+
if (!offset || (PAGE_SIZE > 4096)) {
12941294
err = -ENOMEM;
12951295
goto err_unlock;
12961296
}
@@ -2029,6 +2029,9 @@ static int kfd_mmio_mmap(struct kfd_dev *dev, struct kfd_process *process,
20292029
if (vma->vm_end - vma->vm_start != PAGE_SIZE)
20302030
return -EINVAL;
20312031

2032+
if (PAGE_SIZE > 4096)
2033+
return -EINVAL;
2034+
20322035
address = amdgpu_amdkfd_get_mmio_remap_phys_addr(dev->kgd);
20332036

20342037
vma->vm_flags |= VM_IO | VM_DONTCOPY | VM_DONTEXPAND | VM_NORESERVE |

0 commit comments

Comments
 (0)