Subject: Re: "test_ip_fast_csum: ASSERTION FAILED at lib/checksum_kunit.c:589" at boot with CONFIG_CHECKSUM_KUNIT=y enabled on a Talos II, kernel 6.8-rc5

From: Charlie Jenkins <[email-masked]>
Date: Thu, 22 Feb 2024 22:12:47 -0800

On Fri, Feb 23, 2024 at 05:59:07AM +0000, Christophe Leroy wrote:
> Hi Erhard, hi Charlie,
> 
> Le 23/02/2024 à 02:26, Erhard Furtner a écrit :
> > Greetings!
> > 
> > Looks like my Talos II (running a BE kernel+system) fails some of the kernels internal unit tests. One of the failing tests is checksum_kunit, enabled via CONFIG_CHECKSUM_KUNIT=y:
> > 
> > [...]
> >     KTAP version 1
> >      # Subtest: checksum
> >      # module: checksum_kunit
> >      1..5
> > entry-flush: disabled on command line.
> >      ok 1 test_csum_fixed_random_inputs
> >      ok 2 test_csum_all_carry_inputs
> >      ok 3 test_csum_no_carry_inputs
> >      # test_ip_fast_csum: ASSERTION FAILED at lib/checksum_kunit.c:589
> >      Expected ( u64)expected == ( u64)csum_result, but
> >          ( u64)expected == 55939 (0xda83)
> >          ( u64)csum_result == 33754 (0x83da)
> >      not ok 4 test_ip_fast_csum
> >      # test_csum_ipv6_magic: ASSERTION FAILED at lib/checksum_kunit.c:617
> >      Expected ( u64)expected_csum_ipv6_magic[i] == ( u64)csum_ipv6_magic(saddr, daddr, len, proto, csum), but
> >          ( u64)expected_csum_ipv6_magic[i] == 6356 (0x18d4)
> >          ( u64)csum_ipv6_magic(saddr, daddr, len, proto, csum) == 43586 (0xaa42)
> >      not ok 5 test_csum_ipv6_magic
> > # checksum: pass:3 fail:2 skip:0 total:5
> > # Totals: pass:3 fail:2 skip:0 total:5
> > not ok 4 checksum
> > [...]
> > 
> > Full dmesg + kernel .config attached.
> 
> Looks like the same problem as the one I fixed with commit b38460bc463c 
> ("kunit: Fix checksum tests on big endian CPUs")
> 
> The new tests implemented through commit 6f4c45cbcb00 ("kunit: Add tests 
> for csum_ipv6_magic and ip_fast_csum") create a lot of type issues as 
> reported by sparse when built with C=2 (see below).
> 
> Once those issues are fixed, it should work.
> 
> Charlie, can you provide a fix ?
> 
> Thanks,
> Christophe

The "lib: checksum: Fix issues with checksum tests" patch should fix all of these issues [1].

[1] https://lore.kernel.org/all/[email-masked]/T/#m189783a9b2a7d12e3c34c4a412e65408658db2c9

- Charlie

> 
>    CC      lib/checksum_kunit.o
>    CHECK   lib/checksum_kunit.c
> lib/checksum_kunit.c:219:9: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:219:9:    expected restricted __sum16
> lib/checksum_kunit.c:219:9:    got int
> lib/checksum_kunit.c:219:17: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:219:17:    expected restricted __sum16
> lib/checksum_kunit.c:219:17:    got int
> lib/checksum_kunit.c:219:25: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:219:25:    expected restricted __sum16
> lib/checksum_kunit.c:219:25:    got int
> lib/checksum_kunit.c:219:33: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:219:33:    expected restricted __sum16
> lib/checksum_kunit.c:219:33:    got int
> lib/checksum_kunit.c:219:41: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:219:41:    expected restricted __sum16
> lib/checksum_kunit.c:219:41:    got int
> lib/checksum_kunit.c:219:49: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:219:49:    expected restricted __sum16
> lib/checksum_kunit.c:219:49:    got int
> lib/checksum_kunit.c:219:57: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:219:57:    expected restricted __sum16
> lib/checksum_kunit.c:219:57:    got int
> lib/checksum_kunit.c:219:65: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:219:65:    expected restricted __sum16
> lib/checksum_kunit.c:219:65:    got int
> lib/checksum_kunit.c:219:73: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:219:73:    expected restricted __sum16
> lib/checksum_kunit.c:219:73:    got int
> lib/checksum_kunit.c:220:9: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:220:9:    expected restricted __sum16
> lib/checksum_kunit.c:220:9:    got int
> lib/checksum_kunit.c:220:17: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:220:17:    expected restricted __sum16
> lib/checksum_kunit.c:220:17:    got int
> lib/checksum_kunit.c:220:25: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:220:25:    expected restricted __sum16
> lib/checksum_kunit.c:220:25:    got int
> lib/checksum_kunit.c:220:33: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:220:33:    expected restricted __sum16
> lib/checksum_kunit.c:220:33:    got int
> lib/checksum_kunit.c:220:41: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:220:41:    expected restricted __sum16
> lib/checksum_kunit.c:220:41:    got int
> lib/checksum_kunit.c:220:49: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:220:49:    expected restricted __sum16
> lib/checksum_kunit.c:220:49:    got int
> lib/checksum_kunit.c:220:57: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:220:57:    expected restricted __sum16
> lib/checksum_kunit.c:220:57:    got int
> lib/checksum_kunit.c:220:65: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:220:65:    expected restricted __sum16
> lib/checksum_kunit.c:220:65:    got int
> lib/checksum_kunit.c:220:73: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:220:73:    expected restricted __sum16
> lib/checksum_kunit.c:220:73:    got int
> lib/checksum_kunit.c:221:9: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:221:9:    expected restricted __sum16
> lib/checksum_kunit.c:221:9:    got int
> lib/checksum_kunit.c:221:17: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:221:17:    expected restricted __sum16
> lib/checksum_kunit.c:221:17:    got int
> lib/checksum_kunit.c:221:25: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:221:25:    expected restricted __sum16
> lib/checksum_kunit.c:221:25:    got int
> lib/checksum_kunit.c:221:33: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:221:33:    expected restricted __sum16
> lib/checksum_kunit.c:221:33:    got int
> lib/checksum_kunit.c:221:41: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:221:41:    expected restricted __sum16
> lib/checksum_kunit.c:221:41:    got int
> lib/checksum_kunit.c:221:49: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:221:49:    expected restricted __sum16
> lib/checksum_kunit.c:221:49:    got int
> lib/checksum_kunit.c:221:57: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:221:57:    expected restricted __sum16
> lib/checksum_kunit.c:221:57:    got int
> lib/checksum_kunit.c:221:65: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:221:65:    expected restricted __sum16
> lib/checksum_kunit.c:221:65:    got int
> lib/checksum_kunit.c:221:73: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:221:73:    expected restricted __sum16
> lib/checksum_kunit.c:221:73:    got int
> lib/checksum_kunit.c:222:9: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:222:9:    expected restricted __sum16
> lib/checksum_kunit.c:222:9:    got int
> lib/checksum_kunit.c:222:17: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:222:17:    expected restricted __sum16
> lib/checksum_kunit.c:222:17:    got int
> lib/checksum_kunit.c:222:25: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:222:25:    expected restricted __sum16
> lib/checksum_kunit.c:222:25:    got int
> lib/checksum_kunit.c:222:33: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:222:33:    expected restricted __sum16
> lib/checksum_kunit.c:222:33:    got int
> lib/checksum_kunit.c:222:41: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:222:41:    expected restricted __sum16
> lib/checksum_kunit.c:222:41:    got int
> lib/checksum_kunit.c:222:49: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:222:49:    expected restricted __sum16
> lib/checksum_kunit.c:222:49:    got int
> lib/checksum_kunit.c:222:57: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:222:57:    expected restricted __sum16
> lib/checksum_kunit.c:222:57:    got int
> lib/checksum_kunit.c:222:65: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:222:65:    expected restricted __sum16
> lib/checksum_kunit.c:222:65:    got int
> lib/checksum_kunit.c:222:73: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:222:73:    expected restricted __sum16
> lib/checksum_kunit.c:222:73:    got int
> lib/checksum_kunit.c:223:9: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:223:9:    expected restricted __sum16
> lib/checksum_kunit.c:223:9:    got int
> lib/checksum_kunit.c:223:17: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:223:17:    expected restricted __sum16
> lib/checksum_kunit.c:223:17:    got int
> lib/checksum_kunit.c:223:25: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:223:25:    expected restricted __sum16
> lib/checksum_kunit.c:223:25:    got int
> lib/checksum_kunit.c:223:33: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:223:33:    expected restricted __sum16
> lib/checksum_kunit.c:223:33:    got int
> lib/checksum_kunit.c:223:41: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:223:41:    expected restricted __sum16
> lib/checksum_kunit.c:223:41:    got int
> lib/checksum_kunit.c:223:49: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:223:49:    expected restricted __sum16
> lib/checksum_kunit.c:223:49:    got int
> lib/checksum_kunit.c:223:57: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:223:57:    expected restricted __sum16
> lib/checksum_kunit.c:223:57:    got int
> lib/checksum_kunit.c:223:65: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:223:65:    expected restricted __sum16
> lib/checksum_kunit.c:223:65:    got int
> lib/checksum_kunit.c:223:73: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:223:73:    expected restricted __sum16
> lib/checksum_kunit.c:223:73:    got int
> lib/checksum_kunit.c:224:9: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:224:9:    expected restricted __sum16
> lib/checksum_kunit.c:224:9:    got int
> lib/checksum_kunit.c:224:17: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:224:17:    expected restricted __sum16
> lib/checksum_kunit.c:224:17:    got int
> lib/checksum_kunit.c:224:25: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:224:25:    expected restricted __sum16
> lib/checksum_kunit.c:224:25:    got int
> lib/checksum_kunit.c:224:33: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:224:33:    expected restricted __sum16
> lib/checksum_kunit.c:224:33:    got int
> lib/checksum_kunit.c:224:41: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:224:41:    expected restricted __sum16
> lib/checksum_kunit.c:224:41:    got int
> lib/checksum_kunit.c:224:49: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:224:49:    expected restricted __sum16
> lib/checksum_kunit.c:224:49:    got int
> lib/checksum_kunit.c:224:57: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:224:57:    expected restricted __sum16
> lib/checksum_kunit.c:224:57:    got int
> lib/checksum_kunit.c:224:65: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:224:65:    expected restricted __sum16
> lib/checksum_kunit.c:224:65:    got int
> lib/checksum_kunit.c:224:73: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:224:73:    expected restricted __sum16
> lib/checksum_kunit.c:224:73:    got int
> lib/checksum_kunit.c:225:9: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:225:9:    expected restricted __sum16
> lib/checksum_kunit.c:225:9:    got int
> lib/checksum_kunit.c:225:17: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:225:17:    expected restricted __sum16
> lib/checksum_kunit.c:225:17:    got int
> lib/checksum_kunit.c:225:25: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:225:25:    expected restricted __sum16
> lib/checksum_kunit.c:225:25:    got int
> lib/checksum_kunit.c:225:33: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:225:33:    expected restricted __sum16
> lib/checksum_kunit.c:225:33:    got int
> lib/checksum_kunit.c:225:41: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:225:41:    expected restricted __sum16
> lib/checksum_kunit.c:225:41:    got int
> lib/checksum_kunit.c:225:49: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:225:49:    expected restricted __sum16
> lib/checksum_kunit.c:225:49:    got int
> lib/checksum_kunit.c:225:57: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:225:57:    expected restricted __sum16
> lib/checksum_kunit.c:225:57:    got int
> lib/checksum_kunit.c:225:65: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:225:65:    expected restricted __sum16
> lib/checksum_kunit.c:225:65:    got int
> lib/checksum_kunit.c:225:73: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:225:73:    expected restricted __sum16
> lib/checksum_kunit.c:225:73:    got int
> lib/checksum_kunit.c:226:9: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:226:9:    expected restricted __sum16
> lib/checksum_kunit.c:226:9:    got int
> lib/checksum_kunit.c:226:17: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:226:17:    expected restricted __sum16
> lib/checksum_kunit.c:226:17:    got int
> lib/checksum_kunit.c:226:25: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:226:25:    expected restricted __sum16
> lib/checksum_kunit.c:226:25:    got int
> lib/checksum_kunit.c:226:33: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:226:33:    expected restricted __sum16
> lib/checksum_kunit.c:226:33:    got int
> lib/checksum_kunit.c:226:41: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:226:41:    expected restricted __sum16
> lib/checksum_kunit.c:226:41:    got int
> lib/checksum_kunit.c:226:49: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:226:49:    expected restricted __sum16
> lib/checksum_kunit.c:226:49:    got int
> lib/checksum_kunit.c:226:57: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:226:57:    expected restricted __sum16
> lib/checksum_kunit.c:226:57:    got int
> lib/checksum_kunit.c:226:65: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:226:65:    expected restricted __sum16
> lib/checksum_kunit.c:226:65:    got int
> lib/checksum_kunit.c:226:73: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:226:73:    expected restricted __sum16
> lib/checksum_kunit.c:226:73:    got int
> lib/checksum_kunit.c:227:9: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:227:9:    expected restricted __sum16
> lib/checksum_kunit.c:227:9:    got int
> lib/checksum_kunit.c:227:17: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:227:17:    expected restricted __sum16
> lib/checksum_kunit.c:227:17:    got int
> lib/checksum_kunit.c:227:25: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:227:25:    expected restricted __sum16
> lib/checksum_kunit.c:227:25:    got int
> lib/checksum_kunit.c:227:33: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:227:33:    expected restricted __sum16
> lib/checksum_kunit.c:227:33:    got int
> lib/checksum_kunit.c:227:41: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:227:41:    expected restricted __sum16
> lib/checksum_kunit.c:227:41:    got int
> lib/checksum_kunit.c:227:49: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:227:49:    expected restricted __sum16
> lib/checksum_kunit.c:227:49:    got int
> lib/checksum_kunit.c:227:57: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:227:57:    expected restricted __sum16
> lib/checksum_kunit.c:227:57:    got int
> lib/checksum_kunit.c:227:65: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:227:65:    expected restricted __sum16
> lib/checksum_kunit.c:227:65:    got int
> lib/checksum_kunit.c:227:73: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:227:73:    expected restricted __sum16
> lib/checksum_kunit.c:227:73:    got int
> lib/checksum_kunit.c:228:9: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:228:9:    expected restricted __sum16
> lib/checksum_kunit.c:228:9:    got int
> lib/checksum_kunit.c:228:17: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:228:17:    expected restricted __sum16
> lib/checksum_kunit.c:228:17:    got int
> lib/checksum_kunit.c:228:25: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:228:25:    expected restricted __sum16
> lib/checksum_kunit.c:228:25:    got int
> lib/checksum_kunit.c:228:33: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:228:33:    expected restricted __sum16
> lib/checksum_kunit.c:228:33:    got int
> lib/checksum_kunit.c:228:41: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:228:41:    expected restricted __sum16
> lib/checksum_kunit.c:228:41:    got int
> lib/checksum_kunit.c:228:49: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:228:49:    expected restricted __sum16
> lib/checksum_kunit.c:228:49:    got int
> lib/checksum_kunit.c:228:57: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:228:57:    expected restricted __sum16
> lib/checksum_kunit.c:228:57:    got int
> lib/checksum_kunit.c:228:65: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:228:65:    expected restricted __sum16
> lib/checksum_kunit.c:228:65:    got int
> lib/checksum_kunit.c:228:73: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:228:73:    expected restricted __sum16
> lib/checksum_kunit.c:228:73:    got int
> lib/checksum_kunit.c:229:9: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:229:9:    expected restricted __sum16
> lib/checksum_kunit.c:229:9:    got int
> lib/checksum_kunit.c:229:17: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:229:17:    expected restricted __sum16
> lib/checksum_kunit.c:229:17:    got int
> lib/checksum_kunit.c:229:25: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:229:25:    expected restricted __sum16
> lib/checksum_kunit.c:229:25:    got int
> lib/checksum_kunit.c:229:33: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:229:33:    expected restricted __sum16
> lib/checksum_kunit.c:229:33:    got int
> lib/checksum_kunit.c:229:41: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:229:41:    expected restricted __sum16
> lib/checksum_kunit.c:229:41:    got int
> lib/checksum_kunit.c:229:49: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:229:49:    expected restricted __sum16
> lib/checksum_kunit.c:229:49:    got int
> lib/checksum_kunit.c:229:57: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:229:57:    expected restricted __sum16
> lib/checksum_kunit.c:229:57:    got int
> lib/checksum_kunit.c:229:65: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:229:65:    expected restricted __sum16
> lib/checksum_kunit.c:229:65:    got int
> lib/checksum_kunit.c:229:73: warning: incorrect type in initializer 
> (different base types)
> lib/checksum_kunit.c:229:73:    expected restricted __sum16
> lib/checksum_kunit.c:229:73:    got int
> lib/checksum_kunit.c:230:9: warning: too many warnings