Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/vkms: unclamped s32-to-u16 wraparound in apply_colorop()
  1D curve LUTs
- [Low] drm/vkms: globally export KUnit-only gamma22 LUTs via
  EXPORT_SYMBOL()
--

commit b0ad0319d06f1020df30009f35dd9bb1429d38fb
Author: Robert Mader <[email protected]>

drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA22

This commit adds non-uniform LUTs and colorop handling for the Gamma 2.2
EOTF and its inverse, along with a KUnit round-trip test.

> diff --git a/drivers/gpu/drm/vkms/vkms_composer.c 
> b/drivers/gpu/drm/vkms/vkms_composer.c
> index 7a6a7875520ca..8eaad80ad4697 100644
> --- a/drivers/gpu/drm/vkms/vkms_composer.c
> +++ b/drivers/gpu/drm/vkms/vkms_composer.c
> @@ -264,6 +264,19 @@ static void apply_colorop(struct pixel_argb_s32 *pixel, 
> struct drm_colorop *colo
>                       pixel->g = apply_lut_to_channel_value(&srgb_eotf, 
> pixel->g, LUT_GREEN);
>                       pixel->b = apply_lut_to_channel_value(&srgb_eotf, 
> pixel->b, LUT_BLUE);
>                       break;
> +             case DRM_COLOROP_1D_CURVE_GAMMA22:
> +                     pixel->r = apply_lut_to_channel_value(&gamma22_eotf, 
> pixel->r, LUT_RED);
> +                     pixel->g = apply_lut_to_channel_value(&gamma22_eotf, 
> pixel->g, LUT_GREEN);
> +                     pixel->b = apply_lut_to_channel_value(&gamma22_eotf, 
> pixel->b, LUT_BLUE);
> +                     break;
> +             case DRM_COLOROP_1D_CURVE_GAMMA22_INV:
> +                     pixel->r = 
> apply_lut_to_channel_value(&gamma22_inv_eotf, pixel->r,
> +                                                           LUT_RED);
> +                     pixel->g = 
> apply_lut_to_channel_value(&gamma22_inv_eotf, pixel->g,
> +                                                           LUT_GREEN);
> +                     pixel->b = 
> apply_lut_to_channel_value(&gamma22_inv_eotf, pixel->b,
> +                                                           LUT_BLUE);
> +                     break;

[Severity: Medium]
Can passing pixel->r, pixel->g, and pixel->b directly to
apply_lut_to_channel_value() wrap out-of-range values modulo 65536?

pre_blend_color_transform() runs the pipeline in struct pixel_argb_s32 and
only clamps channels to [0, 0xffff] after all colorops finish.  Because
vkms_initialize_color_pipeline() places a 1D curve stage after the 3x4 CTM
stages, out-of-range CTM outputs reach this lookup as unclamped s32 values.

Since apply_lut_to_channel_value() takes a u16 channel_value, implicit
narrowing turns -1 into 0xffff and 0x10000 into 0x0000, corrupting rendered
pixels and CRCs.  Clamping to [0, 0xffff] before the lookup avoids this.

[ ... ]

> diff --git a/drivers/gpu/drm/vkms/vkms_luts.c 
> b/drivers/gpu/drm/vkms/vkms_luts.c
> index 4b766ae7c1254..5778226fc290f 100644
> --- a/drivers/gpu/drm/vkms/vkms_luts.c
> +++ b/drivers/gpu/drm/vkms/vkms_luts.c

[ ... ]

> +const struct vkms_color_lut gamma22_eotf = {
> +     .x = pow22_x,
> +     .y = pow22_y,
> +     .lut_length = ARRAY_SIZE(pow22_y)
> +};
> +EXPORT_SYMBOL(gamma22_eotf);

[ ... ]

> +const struct vkms_color_lut gamma22_inv_eotf = {
> +     .x = pow22_inv_x,
> +     .y = pow22_inv_y,
> +     .lut_length = ARRAY_SIZE(pow22_inv_y)
> +};
> +EXPORT_SYMBOL(gamma22_inv_eotf);

[Severity: Low]
Should gamma22_eotf and gamma22_inv_eotf use EXPORT_SYMBOL_IF_KUNIT()
instead of EXPORT_SYMBOL()?

vkms_luts.o is linked into vkms.o with vkms_composer.o, so the only
external user is vkms_color_test.c, which already imports the
EXPORTED_FOR_KUNIT_TESTING namespace.  EXPORT_SYMBOL() exports these
unprefixed names globally even without KUnit, risking symbol collisions.

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

Reply via email to