Skip to content

Commit 8079b87

Browse files
Jie1zhangalexdeucher
authored andcommitted
drm/amdgpu: validate user queue size constraints
Add validation to ensure user queue sizes meet hardware requirements: - Size must be a power of two for efficient ring buffer wrapping - Size must be at least AMDGPU_GPU_PAGE_SIZE to prevent undersized allocations This prevents invalid configurations that could lead to GPU faults or unexpected behavior. Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Jesse Zhang <jesse.zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent ba205ac commit 8079b87

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,17 @@ static int amdgpu_userq_input_args_validate(struct drm_device *dev,
932932
drm_file_err(filp, "invalidate userq queue va or size\n");
933933
return -EINVAL;
934934
}
935+
936+
if (!is_power_of_2(args->in.queue_size)) {
937+
drm_file_err(filp, "Queue size must be a power of 2\n");
938+
return -EINVAL;
939+
}
940+
941+
if (args->in.queue_size < AMDGPU_GPU_PAGE_SIZE) {
942+
drm_file_err(filp, "Queue size smaller than AMDGPU_GPU_PAGE_SIZE\n");
943+
return -EINVAL;
944+
}
945+
935946
if (!args->in.wptr_va || !args->in.rptr_va) {
936947
drm_file_err(filp, "invalidate userq queue rptr or wptr\n");
937948
return -EINVAL;

0 commit comments

Comments
 (0)