Skip to content

Commit be4a2a8

Browse files
committed
drm/amdkfd: don't allow mapping the MMIO HDP page with large pages
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
1 parent eb2077f commit be4a2a8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep,
11391139
goto err_unlock;
11401140
}
11411141
offset = dev->adev->rmmio_remap.bus_addr;
1142-
if (!offset) {
1142+
if (!offset || (PAGE_SIZE > 4096)) {
11431143
err = -ENOMEM;
11441144
goto err_unlock;
11451145
}
@@ -2307,7 +2307,7 @@ static int criu_restore_memory_of_gpu(struct kfd_process_device *pdd,
23072307
return -EINVAL;
23082308
}
23092309
offset = pdd->dev->adev->rmmio_remap.bus_addr;
2310-
if (!offset) {
2310+
if (!offset || (PAGE_SIZE > 4096)) {
23112311
pr_err("amdgpu_amdkfd_get_mmio_remap_phys_addr failed\n");
23122312
return -ENOMEM;
23132313
}
@@ -3349,6 +3349,9 @@ static int kfd_mmio_mmap(struct kfd_node *dev, struct kfd_process *process,
33493349
if (vma->vm_end - vma->vm_start != PAGE_SIZE)
33503350
return -EINVAL;
33513351

3352+
if (PAGE_SIZE > 4096)
3353+
return -EINVAL;
3354+
33523355
address = dev->adev->rmmio_remap.bus_addr;
33533356

33543357
vm_flags_set(vma, VM_IO | VM_DONTCOPY | VM_DONTEXPAND | VM_NORESERVE |

0 commit comments

Comments
 (0)