Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/meson: unvalidated fb->offsets[0] alignment in
  meson_plane_atomic_update()
--

commit 8d8faaad8589d5470ee43df783af8a02a180150e
Author: Guillaume La Roque <[email protected]>

drm/meson: honor framebuffer offsets for the primary plane

This commit adds fb->offsets[0] to gem->dma_addr when computing
priv->viu.osd1_addr in meson_plane_atomic_update().

> diff --git a/drivers/gpu/drm/meson/meson_plane.c 
> b/drivers/gpu/drm/meson/meson_plane.c
> index 76eb8b80ad8a5..639234d2f9d42 100644
> --- a/drivers/gpu/drm/meson/meson_plane.c
> +++ b/drivers/gpu/drm/meson/meson_plane.c
> @@ -368,7 +368,7 @@ static void meson_plane_atomic_update(struct drm_plane 
> *plane,
>       /* Update Canvas with buffer address */
>       gem = drm_fb_dma_get_gem_obj(fb, 0);
>  
> -     priv->viu.osd1_addr = gem->dma_addr;
> +     priv->viu.osd1_addr = gem->dma_addr + fb->offsets[0];

[Severity: Medium]
Can an unaligned fb->offsets[0] misprogram the Canvas or AFBC scanout
address here?

Neither drm_gem_fb_create() nor meson_plane_atomic_check() checks
fb->offsets[0] alignment.  For linear scanout, meson_canvas_config() writes
((addr + 7) >> 3) to DMC_CAV_LUT_DATAL, silently rounding unaligned offsets
up by up to 7 bytes and reading past a tightly sized GEM buffer.

For GXM AFBC, meson_gxm_afbcd_setup() shifts osd1_addr >> 4 for
OSD1_AFBCD_HDR_PTR and OSD1_AFBCD_FRAME_PTR while keeping the low bits in
OSD1_AFBCD_CHROMA_PTR, truncating non-16-byte-aligned offsets.

For G12A AFBC, meson_g12a_afbcd_setup() writes osd1_addr directly to
VPU_MAFBC_HEADER_BUF_ADDR_LOW_S0 without checking 64-byte AFBC header
alignment.

Should meson_plane_atomic_check() reject framebuffers whose fb->offsets[0]
violates the Canvas (8-byte) or AFBC (16/64-byte) alignment requirements?

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

Reply via email to