lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 16 Jul 2022 17:32:26 +0800
From:   David Gow <davidgow@...gle.com>
To:     José Expósito <jose.exposito89@...il.com>
Cc:     Javier Martinez Canillas <javierm@...hat.com>,
        Daniel Latypov <dlatypov@...gle.com>,
        Thomas Zimmermann <tzimmermann@...e.de>,
        Maxime Ripard <mripard@...nel.org>,
        Daniel Vetter <daniel@...ll.ch>,
        David Airlie <airlied@...ux.ie>,
        maarten.lankhorst@...ux.intel.com,
        Jani Nikula <jani.nikula@...ux.intel.com>,
        Maíra Canal <maira.canal@....br>,
        Isabella Basso <isabbasso@...eup.net>, magalilemes00@...il.com,
        tales.aparecida@...il.com, dri-devel@...ts.freedesktop.org,
        KUnit Development <kunit-dev@...glegroups.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 1/4] drm/format-helper: Fix test on big endian architectures

On Sat, Jul 9, 2022 at 7:58 PM José Expósito <jose.exposito89@...il.com> wrote:
>
> The tests fail on big endian architectures, like PowerPC:
>
>  $ ./tools/testing/kunit/kunit.py run \
>    --kunitconfig=drivers/gpu/drm/tests \
>    --arch=powerpc --cross_compile=powerpc64-linux-gnu-
>
> Transform the XRGB8888 buffer from little endian to the CPU endian
> before calling the conversion function to avoid this error.
>
> Fixes: 8f456104915f ("drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_rgb332()")
> Reported-by: David Gow <davidgow@...gle.com>
> Signed-off-by: José Expósito <jose.exposito89@...il.com>
> ---

Thanks: I can confirm this now works on big-endian setups.

It might be worth using the __le32 type so that tools like 'sparse'
can verify the expected endianness. At the moment, sparse does
complain about this:

../drivers/gpu/drm/tests/drm_format_helper_test.c:181:26: warning:
cast to restricted __le32

Basically, this would involve replacing the u32 types with __le32 for
things you know to be little-endian. You can then run sparse over the
code with:

./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/tests \
 --arch=powerpc --cross_compile=powerpc64-linux-gnu- \
--make_options C=2 --make_options CF=-D__CHECK_ENDIAN__

Otherwise, this looks good to me, thanks!

Reviewed-by: David Gow <davidgow@...gle.com>

Cheers,
-- David


>  .../gpu/drm/tests/drm_format_helper_test.c    | 23 +++++++++++++++++--
>  1 file changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
> index 98583bf56044..4d074c2e48bf 100644
> --- a/drivers/gpu/drm/tests/drm_format_helper_test.c
> +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
> @@ -111,6 +111,21 @@ static size_t conversion_buf_size(u32 dst_format, unsigned int dst_pitch,
>         return dst_pitch * drm_rect_height(clip);
>  }
>
> +static u32 *le32buf_to_cpu(struct kunit *test, const u32 *buf, size_t buf_size)
> +{
> +       u32 *dst = NULL;
> +       int n;
> +
> +       dst = kunit_kzalloc(test, buf_size, GFP_KERNEL);
> +       if (!dst)
> +               return NULL;
> +
> +       for (n = 0; n < buf_size; n++)
> +               dst[n] = le32_to_cpu(buf[n]);
> +
> +       return dst;
> +}
> +
>  static void xrgb8888_to_rgb332_case_desc(struct xrgb8888_to_rgb332_case *t,
>                                          char *desc)
>  {
> @@ -125,6 +140,7 @@ static void xrgb8888_to_rgb332_test(struct kunit *test)
>         const struct xrgb8888_to_rgb332_case *params = test->param_value;
>         size_t dst_size;
>         __u8 *dst = NULL;
> +       __u32 *src = NULL;
>
>         struct drm_framebuffer fb = {
>                 .format = drm_format_info(DRM_FORMAT_XRGB8888),
> @@ -138,8 +154,11 @@ static void xrgb8888_to_rgb332_test(struct kunit *test)
>         dst = kunit_kzalloc(test, dst_size, GFP_KERNEL);
>         KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dst);
>
> -       drm_fb_xrgb8888_to_rgb332(dst, params->dst_pitch, params->xrgb8888,
> -                                 &fb, &params->clip);
> +       src = le32buf_to_cpu(test, params->xrgb8888, TEST_BUF_SIZE);
> +       KUNIT_ASSERT_NOT_ERR_OR_NULL(test, src);
> +
> +       drm_fb_xrgb8888_to_rgb332(dst, params->dst_pitch, src, &fb,
> +                                 &params->clip);
>         KUNIT_EXPECT_EQ(test, memcmp(dst, params->expected, dst_size), 0);
>  }
>
> --
> 2.25.1
>

Download attachment "smime.p7s" of type "application/pkcs7-signature" (4003 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ