From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sakura.ysato.name (ik1-413-38519.vs.sakura.ne.jp [153.127.30.23]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 79DDE620; Sun, 11 Feb 2024 14:41:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=153.127.30.23 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707662474; cv=none; b=ARTtK0IhEkyqm7MPmelcRkOHnPGBlKGDRsnNnmr5VwYsL7UhtdBpCGqiXFxm2xrC6JqiCQr2xlV0Ypq0Uw8GbXdXslC3iNJMfCehsbyZDq/c7skn4Ue+AzIPAAVTyuq+cQzRtOMPkDJnF/e6ajdWs6E9MCNFRxo/o4SzPjwRSeU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707662474; c=relaxed/simple; bh=saHnz5HQOUfPqpppSKihGyAod1P85+vCaxqke6d5rpw=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=qO4tMk/e1rLUA9Lx2QmnaUZT15Fle2DoFr7955Vc3DReaT+jNGkRf6DgRpGUQzGZkuiqQISOn08SfQyNG7amH+QVIoxuVNQP2DnwGvO4gkfROKLMdV0gDh2w0fd2U3sopQ/9QTi+wTlZX24i1Tf9dcY+sDkE+Pp0L71Xou3YGQ4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=users.sourceforge.jp; spf=fail smtp.mailfrom=users.sourceforge.jp; arc=none smtp.client-ip=153.127.30.23 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=users.sourceforge.jp Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=users.sourceforge.jp Received: from SIOS1075.ysato.ml (ZM005235.ppp.dion.ne.jp [222.8.5.235]) by sakura.ysato.name (Postfix) with ESMTPSA id 2E3F91C01CB; Sun, 11 Feb 2024 23:35:35 +0900 (JST) Date: Sun, 11 Feb 2024 23:35:34 +0900 Message-ID: <87bk8nkr0p.wl-ysato@users.sourceforge.jp> From: Yoshinori Sato To: Guenter Roeck Cc: Rich Felker , John Paul Adrian Glaubitz , linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: Problems with csum_partial with misaligned buffers on sh4 platform In-Reply-To: <65ed7c95-712c-410b-84f3-58496b0c9649@roeck-us.net> References: <65ed7c95-712c-410b-84f3-58496b0c9649@roeck-us.net> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII On Sun, 11 Feb 2024 00:12:39 +0900, Guenter Roeck wrote: > > Hi, > > when running checksum unit tests on sh4 qemu emulations, I get the following > errors. > > KTAP version 1 > # Subtest: checksum > # module: checksum_kunit > 1..5 > # test_csum_fixed_random_inputs: ASSERTION FAILED at lib/checksum_kunit.c:500 > Expected ( u64)result == ( u64)expec, but > ( u64)result == 53378 (0xd082) > ( u64)expec == 33488 (0x82d0) > not ok 1 test_csum_fixed_random_inputs > # test_csum_all_carry_inputs: ASSERTION FAILED at lib/checksum_kunit.c:525 > Expected ( u64)result == ( u64)expec, but > ( u64)result == 65281 (0xff01) > ( u64)expec == 65280 (0xff00) > not ok 2 test_csum_all_carry_inputs > # test_csum_no_carry_inputs: ASSERTION FAILED at lib/checksum_kunit.c:573 > Expected ( u64)result == ( u64)expec, but > ( u64)result == 65535 (0xffff) > ( u64)expec == 65534 (0xfffe) > not ok 3 test_csum_no_carry_inputs > ok 4 test_ip_fast_csum > ok 5 test_csum_ipv6_magic > # checksum: pass:2 fail:3 skip:0 total:5 > > The above is with from a little endian system. On a big endian system, > the test result is as follows. > > KTAP version 1 > # Subtest: checksum > # module: checksum_kunit > 1..5 > # test_csum_fixed_random_inputs: ASSERTION FAILED at lib/checksum_kunit.c:500 > Expected ( u64)result == ( u64)expec, but > ( u64)result == 33488 (0x82d0) > ( u64)expec == 53378 (0xd082) > not ok 1 test_csum_fixed_random_inputs > # test_csum_all_carry_inputs: ASSERTION FAILED at lib/checksum_kunit.c:525 > Expected ( u64)result == ( u64)expec, but > ( u64)result == 65281 (0xff01) > ( u64)expec == 255 (0xff) > not ok 2 test_csum_all_carry_inputs > # test_csum_no_carry_inputs: ASSERTION FAILED at lib/checksum_kunit.c:565 > Expected ( u64)result == ( u64)expec, but > ( u64)result == 1020 (0x3fc) > ( u64)expec == 0 (0x0) > not 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:0 fail:5 skip:0 total:5 > > Note that test_ip_fast_csum and test_csum_ipv6_magic fail on all big endian > systems due to a bug in the test code, unrelated to this problem. > > Analysis shows that the errors are seen only if the buffer is misaligned. > Looking into arch/sh/lib/checksum.S, I found commit cadc4e1a2b4d2 ("sh: > Handle calling csum_partial with misaligned data") which seemed to be > related. Reverting that commit fixes the problem. > This suggests that something may be wrong with that commit. Alternatively, > of course, it may be possible that something is wrong with the qemu > emulation, but that seems unlikely. I checked that part of the code, and it only uses basic instructions. If there is a problem with these instructions, other problems should occur, but I have never seen such a phenomenon. So I think the culprit is in that commit, not qemu. I think it's better to use GENERIC_CSUM since the previous code is also not very efficient. > Thanks, > Guenter -- Yosinori Sato