From: Alex Deucher <alexander.deucher@xxxxxxx> 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: d8e408a82704 ("drm/amdkfd: Expose HDP registers to user space") Reviewed-by: Felix Kuehling <felix.kuehling@xxxxxxx> Signed-off-by: Alex Deucher <alexander.deucher@xxxxxxx> Cc: stable@xxxxxxxxxxxxxxx Signed-off-by: Felix Kuehling <felix.kuehling@xxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -1290,7 +1290,7 @@ static int kfd_ioctl_alloc_memory_of_gpu goto err_unlock; } offset = amdgpu_amdkfd_get_mmio_remap_phys_addr(dev->kgd); - if (!offset) { + if (!offset || (PAGE_SIZE > 4096)) { err = -ENOMEM; goto err_unlock; } @@ -2029,6 +2029,9 @@ static int kfd_mmio_mmap(struct kfd_dev if (vma->vm_end - vma->vm_start != PAGE_SIZE) return -EINVAL; + if (PAGE_SIZE > 4096) + return -EINVAL; + address = amdgpu_amdkfd_get_mmio_remap_phys_addr(dev->kgd); vma->vm_flags |= VM_IO | VM_DONTCOPY | VM_DONTEXPAND | VM_NORESERVE | Patches currently in stable-queue which might be from alexander.deucher@xxxxxxx are queue-5.15/drm-amdgpu-using-uninitialized-value-size-when-calling-amdgpu_vce_cs_reloc.patch queue-5.15/drm-amd-display-validate-hw_points_num-before-using-.patch queue-5.15/drm-amdgpu-jpeg2-properly-set-atomics-vmid-field.patch queue-5.15/revert-drm-amd-display-validate-hw_points_num-before-using-it.patch queue-5.15/drm-amdgpu-actually-check-flags-for-all-context-ops.patch queue-5.15/drm-amdkfd-don-t-allow-mapping-the-mmio-hdp-page-with-large-pages.patch