Skip to contentSkip to conversation

"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

DISCUSSION Erhard Furtner 3 participants 8 messages Feb 23, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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.

Regards,
Erhard

#1 lore raw

Hi Erhard, hi Charlie,

Le 23/02/2024 à 02:26, Erhard Furtner a écrit :

Quoted 28 lines

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
[...]

Quoted 1 line

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

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

#2 lore raw
Quoted 40 lines · Christophe Leroy

Hi Erhard, hi Charlie,

Le 23/02/2024 à 02:26, Erhard Furtner a écrit :

Quoted 28 lines

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
[...]

Quoted 1 line

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).

Quoted 6 lines

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/20240221-fix_sparse_errors_checksum_tests-v9-1-bff4d73ab9d1@rivosinc.com/T/#m189783a9b2a7d12e3c34c4a412e65408658db2c9

- Charlie

Quoted 400 lines

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

#3 lore raw

Le 23/02/2024 à 07:12, Charlie Jenkins a écrit :

Quoted 43 lines · Christophe Leroy
Quoted 42 lines

Hi Erhard, hi Charlie,

Le 23/02/2024 à 02:26, Erhard Furtner a écrit :

Quoted 28 lines

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
[...]

Quoted 1 line

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.

Quoted 8 lines
Quoted 4 lines

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/20240221-fix_sparse_errors_checksum_tests-v9-1-bff4d73ab9d1@rivosinc.com/T/#m189783a9b2a7d12e3c34c4a412e65408658db2c9

It doesn't fix the issues, I still get the following with your patch 1/2 applied:

[    6.893141] KTAP version 1
[    6.896118] 1..1
[    6.897764]     KTAP version 1
[    6.900800]     # Subtest: checksum
[    6.904518]     # module: checksum_kunit
[    6.904601]     1..5
[    7.139784]     ok 1 test_csum_fixed_random_inputs
[    7.590056]     ok 2 test_csum_all_carry_inputs
[    8.064415]     ok 3 test_csum_no_carry_inputs
[    8.070065]     # test_ip_fast_csum: ASSERTION FAILED at 
lib/checksum_kunit.c:589
[    8.070065]     Expected ( u64)expected == ( u64)csum_result, but
[    8.070065]         ( u64)expected == 55939 (0xda83)
[    8.070065]         ( u64)csum_result == 33754 (0x83da)
[    8.075836]     not ok 4 test_ip_fast_csum
[    8.101039]     # test_csum_ipv6_magic: ASSERTION FAILED at 
lib/checksum_kunit.c:617
[    8.101039]     Expected ( u64)( __sum16)expected_csum_ipv6_magic[i] 
== ( u64)csum_ipv6_magic(saddr, daddr, len, proto, ( __wsum)csum), but
[    8.101039]         ( u64)( __sum16)expected_csum_ipv6_magic[i] == 
6356 (0x18d4)
[    8.101039]         ( u64)csum_ipv6_magic(saddr, daddr, len, proto, ( 
__wsum)csum) == 43586 (0xaa42)
[    8.106446]     not ok 5 test_csum_ipv6_magic
[    8.143829] # checksum: pass:3 fail:2 skip:0 total:5
[    8.148334] # Totals: pass:3 fail:2 skip:0 total:5
[    8.153173] not ok 1 checksum

All your patch does is to hide the sparse warnings. But forcing a cast doesn't fix byte orders.

Please have a look at commit b38460bc463c ("kunit: Fix checksum tests on big endian CPUs"), there are helpers to put checksums in the correct byte order.

Christophe

#4 lore raw
Quoted 86 lines · Christophe Leroy

Le 23/02/2024 à 07:12, Charlie Jenkins a écrit :

Quoted 43 lines · Christophe Leroy
Quoted 42 lines

Hi Erhard, hi Charlie,

Le 23/02/2024 à 02:26, Erhard Furtner a écrit :

Quoted 28 lines

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
[...]

Quoted 1 line

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.

Quoted 8 lines
Quoted 4 lines

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/20240221-fix_sparse_errors_checksum_tests-v9-1-bff4d73ab9d1@rivosinc.com/T/#m189783a9b2a7d12e3c34c4a412e65408658db2c9

It doesn't fix the issues, I still get the following with your patch 1/2 applied:

[    6.893141] KTAP version 1
[    6.896118] 1..1
[    6.897764]     KTAP version 1
[    6.900800]     # Subtest: checksum
[    6.904518]     # module: checksum_kunit
[    6.904601]     1..5
[    7.139784]     ok 1 test_csum_fixed_random_inputs
[    7.590056]     ok 2 test_csum_all_carry_inputs
[    8.064415]     ok 3 test_csum_no_carry_inputs
[    8.070065]     # test_ip_fast_csum: ASSERTION FAILED at 
lib/checksum_kunit.c:589
[    8.070065]     Expected ( u64)expected == ( u64)csum_result, but
[    8.070065]         ( u64)expected == 55939 (0xda83)
[    8.070065]         ( u64)csum_result == 33754 (0x83da)
[    8.075836]     not ok 4 test_ip_fast_csum
[    8.101039]     # test_csum_ipv6_magic: ASSERTION FAILED at 
lib/checksum_kunit.c:617
[    8.101039]     Expected ( u64)( __sum16)expected_csum_ipv6_magic[i] 
== ( u64)csum_ipv6_magic(saddr, daddr, len, proto, ( __wsum)csum), but
[    8.101039]         ( u64)( __sum16)expected_csum_ipv6_magic[i] == 
6356 (0x18d4)
[    8.101039]         ( u64)csum_ipv6_magic(saddr, daddr, len, proto, ( 
__wsum)csum) == 43586 (0xaa42)
[    8.106446]     not ok 5 test_csum_ipv6_magic
[    8.143829] # checksum: pass:3 fail:2 skip:0 total:5
[    8.148334] # Totals: pass:3 fail:2 skip:0 total:5
[    8.153173] not ok 1 checksum
Quoted 8 lines

All your patch does is to hide the sparse warnings. But forcing a cast doesn't fix byte orders.

Please have a look at commit b38460bc463c ("kunit: Fix checksum tests on big endian CPUs"), there are helpers to put checksums in the correct byte order.

Christophe

Well that's what the second patch is for. Is it failing with the second patch applied?

- Charlie

#5 lore raw

Le 23/02/2024 à 08:00, Charlie Jenkins a écrit :

Quoted 90 lines · Christophe Leroy
Quoted 89 lines

Le 23/02/2024 à 07:12, Charlie Jenkins a écrit :

Quoted 43 lines · Christophe Leroy
Quoted 42 lines

Hi Erhard, hi Charlie,

Le 23/02/2024 à 02:26, Erhard Furtner a écrit :

Quoted 28 lines

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
[...]

Quoted 1 line

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.

Quoted 8 lines
Quoted 4 lines

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/20240221-fix_sparse_errors_checksum_tests-v9-1-bff4d73ab9d1@rivosinc.com/T/#m189783a9b2a7d12e3c34c4a412e65408658db2c9

It doesn't fix the issues, I still get the following with your patch 1/2 applied:

[    6.893141] KTAP version 1
[    6.896118] 1..1
[    6.897764]     KTAP version 1
[    6.900800]     # Subtest: checksum
[    6.904518]     # module: checksum_kunit
[    6.904601]     1..5
[    7.139784]     ok 1 test_csum_fixed_random_inputs
[    7.590056]     ok 2 test_csum_all_carry_inputs
[    8.064415]     ok 3 test_csum_no_carry_inputs
[    8.070065]     # test_ip_fast_csum: ASSERTION FAILED at
lib/checksum_kunit.c:589
[    8.070065]     Expected ( u64)expected == ( u64)csum_result, but
[    8.070065]         ( u64)expected == 55939 (0xda83)
[    8.070065]         ( u64)csum_result == 33754 (0x83da)
[    8.075836]     not ok 4 test_ip_fast_csum
[    8.101039]     # test_csum_ipv6_magic: ASSERTION FAILED at
lib/checksum_kunit.c:617
[    8.101039]     Expected ( u64)( __sum16)expected_csum_ipv6_magic[i]
== ( u64)csum_ipv6_magic(saddr, daddr, len, proto, ( __wsum)csum), but
[    8.101039]         ( u64)( __sum16)expected_csum_ipv6_magic[i] ==
6356 (0x18d4)
[    8.101039]         ( u64)csum_ipv6_magic(saddr, daddr, len, proto, (
__wsum)csum) == 43586 (0xaa42)
[    8.106446]     not ok 5 test_csum_ipv6_magic
[    8.143829] # checksum: pass:3 fail:2 skip:0 total:5
[    8.148334] # Totals: pass:3 fail:2 skip:0 total:5
[    8.153173] not ok 1 checksum

All your patch does is to hide the sparse warnings. But forcing a cast doesn't fix byte orders.

Quoted 9 lines
Quoted 5 lines

Please have a look at commit b38460bc463c ("kunit: Fix checksum tests on big endian CPUs"), there are helpers to put checksums in the correct byte order.

Christophe

Well that's what the second patch is for. Is it failing with the second patch applied?

Yes, with second patch is magically works, meaning the patch description is not correct because the problem for powerpc it not at all related to memory alignment but to endianness. And endianness should have been fixed by patch 1, but instead of it, patch 1 just hides the problem by forcing casts.

The real fix for endianness which should be your patch 1 is the following change. With that change it works perfectly well without any forced cast:

lib/checksum_kunit.c +2 -2
index 225bb7701460..bf70850035c7 100644
@@ -215,7 +215,7 @@ static const u32 init_sums_no_overflow[] = {
  	0xffff0000, 0xfffffffb,
  };
 
-static const __sum16 expected_csum_ipv6_magic[] = {
+static const u16 expected_csum_ipv6_magic[] = {
  	0x18d4, 0x3085, 0x2e4b, 0xd9f4, 0xbdc8, 0x78f,	0x1034, 0x8422, 0x6fc0,
  	0xd2f6, 0xbeb5, 0x9d3,	0x7e2a, 0x312e, 0x778e, 0xc1bb, 0x7cf2, 0x9d1e,
  	0xca21, 0xf3ff, 0x7569, 0xb02e, 0xca86, 0x7e76, 0x4539, 0x45e3, 0xf28d,
@@ -241,7 +241,7 @@ static const __sum16 expected_csum_ipv6_magic[] = {
  	0x3845, 0x1014
  };
 
-static const __sum16 expected_fast_csum[] = {
+static const u16 expected_fast_csum[] = {
  	0xda83, 0x45da, 0x4f46, 0x4e4f, 0x34e,	0xe902, 0xa5e9, 0x87a5, 0x7187,
  	0x5671, 0xf556, 0x6df5, 0x816d, 0x8f81, 0xbb8f, 0xfbba, 0x5afb, 0xbe5a,
  	0xedbe, 0xabee, 0x6aac, 0xe6b,	0xea0d, 0x67ea, 0x7e68, 0x8a7e, 0x6f8a,
@@ -577,7 +577,8 @@ static void test_csum_no_carry_inputs(struct kunit 

*test)

static void test_ip_fast_csum(struct kunit *test) {
- __sum16 csum_result, expected;
+ __sum16 csum_result;
+ u16 expected;

for (int len = IPv4_MIN_WORDS; len < IPv4_MAX_WORDS; len++) {
for (int index = 0; index < NUM_IP_FAST_CSUM_TESTS; index++) {
@@ -586,7 +587,7 @@ static void test_ip_fast_csum(struct kunit *test)
expected_fast_csum[(len - IPv4_MIN_WORDS) *
NUM_IP_FAST_CSUM_TESTS + index];
- CHECK_EQ(expected, csum_result);
+ CHECK_EQ(to_sum16(expected), csum_result);
}
}
}
@@ -598,7 +599,7 @@ static void test_csum_ipv6_magic(struct kunit *test)
const struct in6_addr *daddr;
unsigned int len;
unsigned char proto;
- unsigned int csum;
+ __wsum csum;

const int daddr_offset = sizeof(struct in6_addr);
const int len_offset = sizeof(struct in6_addr) + sizeof(struct in6_addr);
@@ -611,10 +612,10 @@ static void test_csum_ipv6_magic(struct kunit *test)
saddr = (const struct in6_addr *)(random_buf + i); daddr = (const struct in6_addr *)(random_buf + i +
daddr_offset);
- len = *(unsigned int *)(random_buf + i + len_offset);
+ len = le32_to_cpu(*(__le32 *)(random_buf + i + len_offset));
proto = *(random_buf + i + proto_offset);
- csum = *(unsigned int *)(random_buf + i + csum_offset);
- CHECK_EQ(expected_csum_ipv6_magic[i],
+ csum = *(__wsum *)(random_buf + i + csum_offset);
+ CHECK_EQ(to_sum16(expected_csum_ipv6_magic[i]),
csum_ipv6_magic(saddr, daddr, len, proto, csum));
}
#endif /* !CONFIG_NET */
---

Christophe

#6 lore raw
Quoted 77 lines · On Fri, 23 Feb 2024 09:06:56 +0000 Christophe Leroy…

Yes, with second patch is magically works, meaning the patch description is not correct because the problem for powerpc it not at all related to memory alignment but to endianness. And endianness should have been fixed by patch 1, but instead of it, patch 1 just hides the problem by forcing casts.

The real fix for endianness which should be your patch 1 is the following change. With that change it works perfectly well without any forced cast:

lib/checksum_kunit.c +4 -3
index 225bb7701460..bf70850035c7 100644
@@ -215,7 +215,7 @@ static const u32 init_sums_no_overflow[] = {
  	0xffff0000, 0xfffffffb,
  };
 
-static const __sum16 expected_csum_ipv6_magic[] = {
+static const u16 expected_csum_ipv6_magic[] = {
  	0x18d4, 0x3085, 0x2e4b, 0xd9f4, 0xbdc8, 0x78f,	0x1034, 0x8422, 0x6fc0,
  	0xd2f6, 0xbeb5, 0x9d3,	0x7e2a, 0x312e, 0x778e, 0xc1bb, 0x7cf2, 0x9d1e,
  	0xca21, 0xf3ff, 0x7569, 0xb02e, 0xca86, 0x7e76, 0x4539, 0x45e3, 0xf28d,
@@ -241,7 +241,7 @@ static const __sum16 expected_csum_ipv6_magic[] = {
  	0x3845, 0x1014
  };
 
-static const __sum16 expected_fast_csum[] = {
+static const u16 expected_fast_csum[] = {
  	0xda83, 0x45da, 0x4f46, 0x4e4f, 0x34e,	0xe902, 0xa5e9, 0x87a5, 0x7187,
  	0x5671, 0xf556, 0x6df5, 0x816d, 0x8f81, 0xbb8f, 0xfbba, 0x5afb, 0xbe5a,
  	0xedbe, 0xabee, 0x6aac, 0xe6b,	0xea0d, 0x67ea, 0x7e68, 0x8a7e, 0x6f8a,
@@ -577,7 +577,8 @@ static void test_csum_no_carry_inputs(struct kunit 
 *test)
 
  static void test_ip_fast_csum(struct kunit *test)
  {
-	__sum16 csum_result, expected;
+	__sum16 csum_result;
+	u16 expected;
 
  	for (int len = IPv4_MIN_WORDS; len < IPv4_MAX_WORDS; len++) {
  		for (int index = 0; index < NUM_IP_FAST_CSUM_TESTS; index++) {
lib/checksum_kunit.c +5 -6
@@ -586,7 +587,7 @@ static void test_ip_fast_csum(struct kunit *test)
  				expected_fast_csum[(len - IPv4_MIN_WORDS) *
  						   NUM_IP_FAST_CSUM_TESTS +
  						   index];
-			CHECK_EQ(expected, csum_result);
+			CHECK_EQ(to_sum16(expected), csum_result);
  		}
  	}
  }
@@ -598,7 +599,7 @@ static void test_csum_ipv6_magic(struct kunit *test)
  	const struct in6_addr *daddr;
  	unsigned int len;
  	unsigned char proto;
-	unsigned int csum;
+	__wsum csum;
 
  	const int daddr_offset = sizeof(struct in6_addr);
  	const int len_offset = sizeof(struct in6_addr) + sizeof(struct in6_addr);
@@ -611,10 +612,10 @@ static void test_csum_ipv6_magic(struct kunit *test)
  		saddr = (const struct in6_addr *)(random_buf + i);
  		daddr = (const struct in6_addr *)(random_buf + i +
  						  daddr_offset);
-		len = *(unsigned int *)(random_buf + i + len_offset);
+		len = le32_to_cpu(*(__le32 *)(random_buf + i + len_offset));
  		proto = *(random_buf + i + proto_offset);
-		csum = *(unsigned int *)(random_buf + i + csum_offset);
-		CHECK_EQ(expected_csum_ipv6_magic[i],
+		csum = *(__wsum *)(random_buf + i + csum_offset);
+		CHECK_EQ(to_sum16(expected_csum_ipv6_magic[i]),
  			 csum_ipv6_magic(saddr, daddr, len, proto, csum));
  	}
  #endif /* !CONFIG_NET */
---
Quoted 1 line

Christophe

Your patch applied on top of 6.8-rc5 fixes the issue. Thanks!

And I take your remarks here as a hint for the other "drm_test_fb_xrgb8888_to_xrgb2101010 on Big Endian machines" issue I posted. ;) Let's see what I can do.

Regards,
Erhard

#7 lore raw
In reply to Christophe Leroy
Quoted 109 lines · Christophe Leroy

Le 23/02/2024 à 08:00, Charlie Jenkins a écrit :

Quoted 90 lines · Christophe Leroy
Quoted 89 lines

Le 23/02/2024 à 07:12, Charlie Jenkins a écrit :

Quoted 43 lines · Christophe Leroy
Quoted 42 lines

Hi Erhard, hi Charlie,

Le 23/02/2024 à 02:26, Erhard Furtner a écrit :

Quoted 28 lines

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
[...]

Quoted 1 line

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.

Quoted 8 lines
Quoted 4 lines

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/20240221-fix_sparse_errors_checksum_tests-v9-1-bff4d73ab9d1@rivosinc.com/T/#m189783a9b2a7d12e3c34c4a412e65408658db2c9

It doesn't fix the issues, I still get the following with your patch 1/2 applied:

[    6.893141] KTAP version 1
[    6.896118] 1..1
[    6.897764]     KTAP version 1
[    6.900800]     # Subtest: checksum
[    6.904518]     # module: checksum_kunit
[    6.904601]     1..5
[    7.139784]     ok 1 test_csum_fixed_random_inputs
[    7.590056]     ok 2 test_csum_all_carry_inputs
[    8.064415]     ok 3 test_csum_no_carry_inputs
[    8.070065]     # test_ip_fast_csum: ASSERTION FAILED at
lib/checksum_kunit.c:589
[    8.070065]     Expected ( u64)expected == ( u64)csum_result, but
[    8.070065]         ( u64)expected == 55939 (0xda83)
[    8.070065]         ( u64)csum_result == 33754 (0x83da)
[    8.075836]     not ok 4 test_ip_fast_csum
[    8.101039]     # test_csum_ipv6_magic: ASSERTION FAILED at
lib/checksum_kunit.c:617
[    8.101039]     Expected ( u64)( __sum16)expected_csum_ipv6_magic[i]
== ( u64)csum_ipv6_magic(saddr, daddr, len, proto, ( __wsum)csum), but
[    8.101039]         ( u64)( __sum16)expected_csum_ipv6_magic[i] ==
6356 (0x18d4)
[    8.101039]         ( u64)csum_ipv6_magic(saddr, daddr, len, proto, (
__wsum)csum) == 43586 (0xaa42)
[    8.106446]     not ok 5 test_csum_ipv6_magic
[    8.143829] # checksum: pass:3 fail:2 skip:0 total:5
[    8.148334] # Totals: pass:3 fail:2 skip:0 total:5
[    8.153173] not ok 1 checksum

All your patch does is to hide the sparse warnings. But forcing a cast doesn't fix byte orders.

Quoted 9 lines
Quoted 5 lines

Please have a look at commit b38460bc463c ("kunit: Fix checksum tests on big endian CPUs"), there are helpers to put checksums in the correct byte order.

Christophe

Well that's what the second patch is for. Is it failing with the second patch applied?

Yes, with second patch is magically works, meaning the patch description is not correct because the problem for powerpc it not at all related to memory alignment but to endianness. And endianness should have been fixed by patch 1, but instead of it, patch 1 just hides the problem by forcing casts.

Quoted 3 lines

The real fix for endianness which should be your patch 1 is the following change. With that change it works perfectly well without any forced cast:

Saying without "any forced casted" is misleading. You are just hiding the forced cast behind a function call. to_sum16 is defined as (__force __sum16)le16_to_cpu((__force __le16)x) which does two forced casts. Since this is networking code, htons makes more logical sense here and it is the same result.

Sparse simply requires forced casts, as the networking types uses restricted types. I can rearrange the patches so that the first patch is not solely fixing the sparse forced casts and include the endianness fixes from the second patch.

I see how the title of the second patch is confusing since it only says alignment, but I included endianness in the description which I assumed would sufficiently convey the point.

- Charlie

Quoted 69 lines
lib/checksum_kunit.c +4 -3
index 225bb7701460..bf70850035c7 100644
@@ -215,7 +215,7 @@ static const u32 init_sums_no_overflow[] = {
  	0xffff0000, 0xfffffffb,
  };
 
-static const __sum16 expected_csum_ipv6_magic[] = {
+static const u16 expected_csum_ipv6_magic[] = {
  	0x18d4, 0x3085, 0x2e4b, 0xd9f4, 0xbdc8, 0x78f,	0x1034, 0x8422, 0x6fc0,
  	0xd2f6, 0xbeb5, 0x9d3,	0x7e2a, 0x312e, 0x778e, 0xc1bb, 0x7cf2, 0x9d1e,
  	0xca21, 0xf3ff, 0x7569, 0xb02e, 0xca86, 0x7e76, 0x4539, 0x45e3, 0xf28d,
@@ -241,7 +241,7 @@ static const __sum16 expected_csum_ipv6_magic[] = {
  	0x3845, 0x1014
  };
 
-static const __sum16 expected_fast_csum[] = {
+static const u16 expected_fast_csum[] = {
  	0xda83, 0x45da, 0x4f46, 0x4e4f, 0x34e,	0xe902, 0xa5e9, 0x87a5, 0x7187,
  	0x5671, 0xf556, 0x6df5, 0x816d, 0x8f81, 0xbb8f, 0xfbba, 0x5afb, 0xbe5a,
  	0xedbe, 0xabee, 0x6aac, 0xe6b,	0xea0d, 0x67ea, 0x7e68, 0x8a7e, 0x6f8a,
@@ -577,7 +577,8 @@ static void test_csum_no_carry_inputs(struct kunit 
 *test)
 
  static void test_ip_fast_csum(struct kunit *test)
  {
-	__sum16 csum_result, expected;
+	__sum16 csum_result;
+	u16 expected;
 
  	for (int len = IPv4_MIN_WORDS; len < IPv4_MAX_WORDS; len++) {
  		for (int index = 0; index < NUM_IP_FAST_CSUM_TESTS; index++) {
lib/checksum_kunit.c +5 -6
@@ -586,7 +587,7 @@ static void test_ip_fast_csum(struct kunit *test)
  				expected_fast_csum[(len - IPv4_MIN_WORDS) *
  						   NUM_IP_FAST_CSUM_TESTS +
  						   index];
-			CHECK_EQ(expected, csum_result);
+			CHECK_EQ(to_sum16(expected), csum_result);
  		}
  	}
  }
@@ -598,7 +599,7 @@ static void test_csum_ipv6_magic(struct kunit *test)
  	const struct in6_addr *daddr;
  	unsigned int len;
  	unsigned char proto;
-	unsigned int csum;
+	__wsum csum;
 
  	const int daddr_offset = sizeof(struct in6_addr);
  	const int len_offset = sizeof(struct in6_addr) + sizeof(struct in6_addr);
@@ -611,10 +612,10 @@ static void test_csum_ipv6_magic(struct kunit *test)
  		saddr = (const struct in6_addr *)(random_buf + i);
  		daddr = (const struct in6_addr *)(random_buf + i +
  						  daddr_offset);
-		len = *(unsigned int *)(random_buf + i + len_offset);
+		len = le32_to_cpu(*(__le32 *)(random_buf + i + len_offset));
  		proto = *(random_buf + i + proto_offset);
-		csum = *(unsigned int *)(random_buf + i + csum_offset);
-		CHECK_EQ(expected_csum_ipv6_magic[i],
+		csum = *(__wsum *)(random_buf + i + csum_offset);
+		CHECK_EQ(to_sum16(expected_csum_ipv6_magic[i]),
  			 csum_ipv6_magic(saddr, daddr, len, proto, csum));
  	}
  #endif /* !CONFIG_NET */
---

Christophe