Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:

Pre-existing issues:
- [High] Integer underflow when computing MST.slotEnd for disabled outputs, 
leading to a massive slotEnd value (0xFFFFFFFF).
--

--- Patch [4]: [PATCH 4/7] nouveau/gsp: use per-version DP_CONFIG_STREAM params 
on r570 firmware ---
commit d855125b895d27bafd2aaed0c330ae6eae007aef
Author: Mohamed Ahmed <[email protected]>

nouveau/gsp: use per-version DP_CONFIG_STREAM params on r570 firmware

This commit separates the DP_CONFIG_STREAM_PARAMS structure and its related
functions into r535 and r570 variants. This handles the structure shrinking
that occurred in the 570 firmware version.

> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/disp.c 
> b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/disp.c
> index a96e31c2d80b2..61f82e15ff398 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/disp.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/disp.c
[ ... ]
> @@ -74,6 +75,67 @@ r570_disp_chan_set_pushbuf(struct nvkm_disp *disp, s32 
> oclass, int inst, struct
>       return nvkm_gsp_rm_ctrl_wr(&gsp->internal.device.subdevice, ctrl);
>  }
>  
> +static void
> +r570_dp_vcpi(struct nvkm_ior *sor, int head, u8 slot, u8 slot_nr, u16 pbn, 
> u16 aligned_pbn)
> +{
> +     struct nvkm_disp *disp = sor->disp;
> +     NV0073_CTRL_CMD_DP_CONFIG_STREAM_PARAMS *ctrl;
[ ... ]
> +     ctrl->MST.slotStart = slot;
> +     ctrl->MST.slotEnd = slot + slot_nr - 1;

[Severity: High]
This isn't a bug introduced by this patch, but this preexisting issue gets
copied into the new r570_dp_vcpi() function from the r535 code.

When an MST output is disabled, nv50_msto_prepare() (in dispnv50/disp.c)
calls nvif_outp_dp_mst_vcpi() with num_slots=0. This propagates here, setting
slot_nr to 0.

With slot_nr = 0, does the expression "slot + slot_nr - 1" evaluate to -1?
Since MST.slotEnd is an NvU32, this would underflow to 0xFFFFFFFF, passing
a maximal bound for a time slot range to the GSP firmware. 

Could this potentially cause out-of-bounds accesses or hangs in the firmware?
Should this logic be updated to handle slot_nr = 0 safely before it evaluates
to -1 and underflows?

> +     ctrl->MST.PBN = pbn;

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=4

Reply via email to