summaryrefslogtreecommitdiff
path: root/drivers/gpu
diff options
context:
space:
mode:
authorJesse.Zhang <Jesse.Zhang@amd.com>2026-01-28 11:35:57 +0800
committerAlex Deucher <alexander.deucher@amd.com>2026-01-29 12:26:15 -0500
commit8079b87c02e531cc91601f72ea8336dd2262fdf1 (patch)
tree3039a56907bcb728b001f57218b7fe53bb8574a4 /drivers/gpu
parentba205ac3d6e83f56c4f824f23f1b4522cb844ff3 (diff)
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>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
index b0ebf19db10b..b700c2b91465 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
@@ -932,6 +932,17 @@ static int amdgpu_userq_input_args_validate(struct drm_device *dev,
drm_file_err(filp, "invalidate userq queue va or size\n");
return -EINVAL;
}
+
+ if (!is_power_of_2(args->in.queue_size)) {
+ drm_file_err(filp, "Queue size must be a power of 2\n");
+ return -EINVAL;
+ }
+
+ if (args->in.queue_size < AMDGPU_GPU_PAGE_SIZE) {
+ drm_file_err(filp, "Queue size smaller than AMDGPU_GPU_PAGE_SIZE\n");
+ return -EINVAL;
+ }
+
if (!args->in.wptr_va || !args->in.rptr_va) {
drm_file_err(filp, "invalidate userq queue rptr or wptr\n");
return -EINVAL;