This is a note to let you know that I've just added the patch titled drm/amdkfd: don't allow mapping the MMIO HDP page with large pages to the 6.8-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: drm-amdkfd-don-t-allow-mapping-the-mmio-hdp-page-with-large-pages.patch and it can be found in the queue-6.8 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From be4a2a81b6b90d1a47eaeaace4cc8e2cb57b96c7 Mon Sep 17 00:00:00 2001 From: Alex Deucher <alexander.deucher@xxxxxxx> Date: Sun, 14 Apr 2024 13:06:39 -0400 Subject: drm/amdkfd: don't allow mapping the MMIO HDP page with large pages 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: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -1138,7 +1138,7 @@ static int kfd_ioctl_alloc_memory_of_gpu goto err_unlock; } offset = dev->adev->rmmio_remap.bus_addr; - if (!offset) { + if (!offset || (PAGE_SIZE > 4096)) { err = -ENOMEM; goto err_unlock; } @@ -2306,7 +2306,7 @@ static int criu_restore_memory_of_gpu(st 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; } @@ -3347,6 +3347,9 @@ static int kfd_mmio_mmap(struct kfd_node 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 | Patches currently in stable-queue which might be from alexander.deucher@xxxxxxx are queue-6.8/drm-amdgpu-fix-comparison-in-amdgpu_res_cpu_visible.patch queue-6.8/drm-amdkfd-check-cgroup-when-returning-dmabuf-info.patch queue-6.8/drm-amdgpu-fix-doorbell-regression.patch queue-6.8/drm-amd-display-handle-y-carry-over-in-vcp-x.y-calculation.patch queue-6.8/drm-amdgpu-once-more-fix-the-call-oder-in-amdgpu_ttm_move-v2.patch queue-6.8/drm-amd-display-fix-incorrect-dsc-instance-for-mst.patch queue-6.8/drm-amd-display-skip-on-writeback-when-it-s-not-appl.patch queue-6.8/drm-amdgpu-refine-ib-schedule-error-logging.patch queue-6.8/dm-amd-pm-fix-problems-with-reboot-shutdown-for-some.patch queue-6.8/drm-amdkfd-range-check-cp-bad-op-exception-interrupt.patch queue-6.8/drm-amdgpu-add-smu-14.0.1-discovery-support.patch queue-6.8/amd-amdkfd-sync-all-devices-to-wait-all-processes-be.patch queue-6.8/drm-amdgpu-implement-irq_state_enable-for-sdma-v4.4..patch queue-6.8/drm-amd-display-add-dcn-351-version-for-microcode-lo.patch queue-6.8/drm-amdgpu-fix-vcn-allocation-in-cpx-partition.patch queue-6.8/drm-radeon-silence-ubsan-warning-v3.patch queue-6.8/drm-amd-display-fix-idle-optimization-checks-for-multi-display-and-dual-edp.patch queue-6.8/drm-amd-display-atom-integrated-system-info-v2_2-for.patch queue-6.8/drm-amdkfd-don-t-allow-mapping-the-mmio-hdp-page-with-large-pages.patch queue-6.8/drm-amd-pm-fix-the-high-voltage-issue-after-unload.patch