]> Git Repo - J-linux.git/commitdiff
drm/amdkfd: don't allow mapping the MMIO HDP page with large pages
authorAlex Deucher <[email protected]>
Sun, 14 Apr 2024 17:06:39 +0000 (13:06 -0400)
committerAlex Deucher <[email protected]>
Fri, 10 May 2024 17:05:13 +0000 (13:05 -0400)
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: d8e408a82704 ("drm/amdkfd: Expose HDP registers to user space")
Reviewed-by: Felix Kuehling <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
Cc: [email protected]
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c

index 55aa74cbc5325e23451aa255dd5ce016e0aa4df8..1e6cc0bfc4328d5447922bef89e5d396e91b66b0 100644 (file)
@@ -1139,7 +1139,7 @@ static int kfd_ioctl_alloc_memory_of_gpu(struct file *filep,
                        goto err_unlock;
                }
                offset = dev->adev->rmmio_remap.bus_addr;
-               if (!offset) {
+               if (!offset || (PAGE_SIZE > 4096)) {
                        err = -ENOMEM;
                        goto err_unlock;
                }
@@ -2307,7 +2307,7 @@ static int criu_restore_memory_of_gpu(struct kfd_process_device *pdd,
                        return -EINVAL;
                }
                offset = pdd->dev->adev->rmmio_remap.bus_addr;
-               if (!offset) {
+               if (!offset || (PAGE_SIZE > 4096)) {
                        pr_err("amdgpu_amdkfd_get_mmio_remap_phys_addr failed\n");
                        return -ENOMEM;
                }
@@ -3349,6 +3349,9 @@ static int kfd_mmio_mmap(struct kfd_node *dev, struct kfd_process *process,
        if (vma->vm_end - vma->vm_start != PAGE_SIZE)
                return -EINVAL;
 
+       if (PAGE_SIZE > 4096)
+               return -EINVAL;
+
        address = dev->adev->rmmio_remap.bus_addr;
 
        vm_flags_set(vma, VM_IO | VM_DONTCOPY | VM_DONTEXPAND | VM_NORESERVE |
This page took 0.058024 seconds and 4 git commands to generate.