Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] drm/amdgpu: out-of-bounds gang context address in mes_set_gang() --
commit faefcb7998343e4f4e1ec3ab6ccf3f3feccc05e7 Author: Alex Deucher <[email protected]> drm/amdgpu/userq/mes: implement set gang submit This commit adds the mes_set_gang() callback to userq_mes_funcs to configure MES gang submission between a primary and secondary usermode queue. > diff --git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c > b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c > index 7abb9d95ef59a..e186ebd08b8d2 100644 > --- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c > +++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c > @@ -649,6 +649,31 @@ static int mes_userq_restore(struct > amdgpu_usermode_queue *queue) > return r; > } > > +static int mes_set_gang(struct amdgpu_usermode_queue *primary_queue, > + struct amdgpu_usermode_queue *secondary_queue) > +{ > + struct amdgpu_userq_obj *primary_ctx = &primary_queue->fw_obj; > + struct amdgpu_userq_obj *secondary_ctx = &secondary_queue->fw_obj; > + struct amdgpu_userq_mgr *uq_mgr = primary_queue->userq_mgr; > + struct amdgpu_device *adev = uq_mgr->adev; > + struct mes_set_gang_submit_input input; > + int r; > + > + memset(&input, 0x0, sizeof(struct mes_set_gang_submit_input)); > + > + input.primary_gang_context_addr = > + primary_ctx->gpu_addr + AMDGPU_USERQ_PROC_CTX_SZ; > + input.secondary_gang_context_addr = > + secondary_ctx->gpu_addr + AMDGPU_USERQ_PROC_CTX_SZ; [Severity: High] Should primary_gang_context_addr and secondary_gang_context_addr be set to primary_ctx->gpu_addr and secondary_ctx->gpu_addr without adding AMDGPU_USERQ_PROC_CTX_SZ? Since 97bcaf15ad25 ("drm/amdgpu: implement per-process MES context"), the process context is allocated separately in uq_mgr->proc_ctx_obj, and mes_userq_create_ctx_space() allocates queue->fw_obj with size AMDGPU_USERQ_GANG_CTX_SZ (one page) for the gang context alone: drivers/gpu/drm/amd/amdgpu/mes_userqueue.c:mes_userq_create_ctx_space() { ... /* The FW expects at least one page space allocated for gang ctx. */ size = AMDGPU_USERQ_GANG_CTX_SZ; r = amdgpu_bo_create_kernel(uq_mgr->adev, size, 0, AMDGPU_GEM_DOMAIN_GTT, &ctx->obj, &ctx->gpu_addr, &ctx->cpu_ptr); ... } Adding AMDGPU_USERQ_PROC_CTX_SZ points one page past the end of each queue's fw_obj BO and does not match the gang_context_addr (ctx->gpu_addr) passed to MES in mes_userq_map(). -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=6
