drm/amdkfd: fix 32-bit overflow in CWSR total size calculation
authorYongqiang Sun <Yongqiang.Sun@amd.com>
Mon, 6 Jul 2026 19:15:07 +0000 (15:15 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 14 Jul 2026 23:12:36 +0000 (19:12 -0400)
commit319f7e13423ae3f486b9aea82f9ad2d6af0ee608
tree7d9673268b73b764bfbb301fc4df9bfe9638119f
parenta30c4e979bba8da348a29edd77f103b89f0d717b
drm/amdkfd: fix 32-bit overflow in CWSR total size calculation

total_cwsr_size was computed in 32-bit before being used as a BO/SVM
allocation size.
With large ctx_save_restore_area_size and debug_memory_size
multiplied by the XCC count, the product can wrap,
yielding an undersized CWSR save area that firmware later overruns.

Promote total_cwsr_size to u64 and use check_add_overflow()/
check_mul_overflow() in both kfd_queue_acquire_buffers() and
kfd_queue_release_buffers().

Signed-off-by: Yongqiang Sun <Yongqiang.Sun@amd.com>
Reviewed-by: Philip Yang <philip.yang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_queue.c