Re: [PATCH 11/11] drm/amdgpu/vce4: Fix VCE 4 firmware size and offsets

Christian König
2026-04-23T11:31:13Z

On 4/23/26 03:16, Timur Kristóf wrote:
> The VCPU BO contains the actual FW at an offset, but
> it was not calculated into the VCPU BO size.
> Subtract this from the FW size to make sure there is
> no out of bounds access.
>
> This may fix VM faults when using VCE 4.
>
> Cc: John Olender <john.olender@gmail.com>
> Fixes: c1dc356a116c ("drm/amdgpu: add initial vce 4.0 support for vega10")
> Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>

Leo can you take a look at this? VCE4 doesn't use the classic VCE FW validation any more.

So I'm not sure we have nor need that here.

Regards,
Christian.

> ---
> drivers/gpu/drm/amd/amdgpu/vce_v4_0.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
> index 3309e7b8f2a2e..eaa3e05a52e59 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
> @@ -281,7 +281,7 @@ static int vce_v4_0_sriov_start(struct amdgpu_device *adev)
> mmVCE_LMI_VCPU_CACHE_64BIT_BAR2),
> (adev->vce.gpu_addr >> 40) & 0xff);
>
> - size = VCE_V4_0_FW_SIZE;
> + size = VCE_V4_0_FW_SIZE - AMDGPU_VCE_FIRMWARE_OFFSET;
> MMSCH_V1_0_INSERT_DIRECT_WT(SOC15_REG_OFFSET(VCE, 0, mmVCE_VCPU_CACHE_SIZE0), size);
>
> offset = (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) ? offset + size : 0;