From: Guenter Roeck <linux@roeck-us.net>
To: Christophe Leroy <christophe.leroy@csgroup.eu>,
Charlie Jenkins <charlie@rivosinc.com>,
David Laight <David.Laight@aculab.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Andrew Morton <akpm@linux-foundation.org>,
Helge Deller <deller@gmx.de>,
"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
Parisc List <linux-parisc@vger.kernel.org>,
Arnd Bergmann <arnd@arndb.de>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Palmer Dabbelt <palmer@rivosinc.com>,
Linux ARM <linux-arm-kernel@lists.infradead.org>,
Russell King <linux@armlinux.org.uk>
Subject: Re: [PATCH v10] lib: checksum: Use aligned accesses for ip_fast_csum and csum_ipv6_magic tests
Date: Fri, 1 Mar 2024 12:47:18 -0800 [thread overview]
Message-ID: <11842961-91c2-40bf-9134-7528d30137f3@roeck-us.net> (raw)
In-Reply-To: <0b4a7a9c-dd94-47bd-b9df-4da58be11342@roeck-us.net>
On 3/1/24 08:24, Guenter Roeck wrote:
> On 2/29/24 22:46, Christophe Leroy wrote:
>>
>>
>> Le 26/02/2024 à 17:44, Guenter Roeck a écrit :
>>> On 2/26/24 03:34, Christophe Leroy wrote:
>>>>
>>>>
>>>> Le 23/02/2024 à 23:11, Charlie Jenkins a écrit :
>>>>> The test cases for ip_fast_csum and csum_ipv6_magic were not properly
>>>>> aligning the IP header, which were causing failures on architectures
>>>>> that do not support misaligned accesses like some ARM platforms. To
>>>>> solve this, align the data along (14 + NET_IP_ALIGN) bytes which is the
>>>>> standard alignment of an IP header and must be supported by the
>>>>> architecture.
>>>>
>>>> I'm still wondering what we are really trying to fix here.
>>>>
>>>> All other tests are explicitely testing that it works with any alignment.
>>>>
>>>> Shouldn't ip_fast_csum() and csum_ipv6_magic() work for any alignment as
>>>> well ? I would expect it, I see no comment in arm code which explicits
>>>> that assumption around those functions.
>>>>
>>>> Isn't the problem only the following line, because csum_offset is
>>>> unaligned ?
>>>>
>>>> csum = *(__wsum *)(random_buf + i + csum_offset);
>>>>
>>>> Otherwise, if there really is an alignment issue for the IPv6 source or
>>>> destination address, isn't it enough to perform a 32 bits alignment ?
>>>>
>>>
>>> It isn't just arm.
>>>
>>> Question should be what alignments the functions are supposed to be able
>>> to handle, not what they are optimized for. If byte and/or half word
>>> alignments
>>> are expected to be supported, there is still architecture code which would
>>> have to be fixed. Unaligned accesses are known to fail on hppa64/parisc64
>>> and on sh4, for example. If unaligned accesses are expected to be handled,
>>> it would probably make sense to add a separate test case, though, to
>>> clarify
>>> that the test fails due to alignment issues, not due to input parameters.
>>>
>>
>> When you say "Unaligned accesses are known to fail on hppa64/parisc64
>> and on sh4", do you mean unaligned accesses in general or do you mean
>> ip_fast_csum() with unaligned ip header and csum_ipv6_magic() with
>> unaligned source and dest addresses ?
>>
>> Because later in this thread it is said that only ARM and NIOS2
>> potentially have an issue.
>>
>> And when you say "unaligned", to what level is that ? Is it 4-bytes
>> alignment or more or less ?
>>
>
> This e-mail chain is getting too long. Here is an attempt of a quick summary.
>
> - Someone else suggested that unaligned accesses with nios2 should fail.
> I since then tested and found that they pass at least for the checksum tests,
> while dumping "unaligned access" messages into the kernel log. Other tests
> (specifically gso) cause crashes, but that is unrelated.
>
> - checksum tests on sh4 fail for unaligned data because of a bug introduced
> to the architecture's checksum core with commit cadc4e1a2b4d ("sh: Handle
> calling csum_partial with misaligned data"). The tests pass after reverting
> that patch. I reported this, but that revert (or a fix of the problem it
> introduced) has not been applied to linux-next.
>
> - Checksum tests on unaligned data fail on parisc in mainline due to a number
> of bugs in checksum assembler code (and with upstream qemu due to a bug in
> qemu's hppa64 emulation). All those issues should by now be fixed in linux-next.
> For reference, the following patches (SHAs from next-20240301) are needed to fix
> the known problems:
> 0568b6f0d863 parisc: Strip upper 32 bit of sum in csum_ipv6_magic for 64-bit builds
> 4b75b12d7050 parisc: Fix csum_ipv6_magic on 64-bit systems
> 4408ba75e4ba parisc: Fix csum_ipv6_magic on 32-bit systems
> a2abae8f0b63 parisc: Fix ip_fast_csum
> qemu (v8.2 and later) needs
> https://lore.kernel.org/all/20240217015811.1975411-1-linux@roeck-us.net/T/
> for the hppa64/parisc64 tests to work with qemu.
>
> - Checksum tests on unaligned data cause a crash on arm systems with "thumb"
> instruction set enabled (such as mps2_defconfig and an385). I didn't bother
> checking if the crash is with 1-byte or 2-byte alignment.
>
> - There used to be a crash with checksum tests on m68k because of word alignment
> which the implementation of the unit tests for csum_ipv6_magic() did not take
> into account (this is fixed by the padding in struct csum_ipv6_magic_data).
> I don't know if this patch is needed to fix that problem or if it was since
> fixed differently.
>
> I hope that covers everything. As I said above, the chain is getting long
> and I may have missed something.
>
I knew I missed something. I forgot to mention upstream commit d55347bfe4e6
("MIPS: Add 'memory' clobber to csum_ipv6_magic() inline assembler") witch
fixed problems with csum_ipv6_magic() for mips.
Guenter
next prev parent reply other threads:[~2024-03-01 20:47 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-23 22:11 [PATCH v10] lib: checksum: Use aligned accesses for ip_fast_csum and csum_ipv6_magic tests Charlie Jenkins
2024-02-25 15:58 ` Guenter Roeck
2024-02-26 11:34 ` Christophe Leroy
2024-02-26 11:47 ` Russell King (Oracle)
2024-02-26 11:57 ` Christophe Leroy
2024-02-26 12:03 ` Russell King (Oracle)
2024-02-26 16:44 ` Guenter Roeck
2024-02-26 17:50 ` Russell King (Oracle)
2024-02-26 18:35 ` Charlie Jenkins
2024-02-26 19:06 ` Russell King (Oracle)
2024-02-26 19:19 ` Charlie Jenkins
2024-02-26 22:33 ` David Laight
2024-02-26 23:17 ` Charlie Jenkins
2024-02-26 23:48 ` Guenter Roeck
2024-02-27 6:47 ` Christophe Leroy
2024-02-27 10:28 ` Russell King (Oracle)
2024-02-27 11:32 ` Christophe Leroy
2024-02-27 17:54 ` Charlie Jenkins
2024-02-27 18:11 ` Christophe Leroy
2024-02-27 18:21 ` Charlie Jenkins
2024-02-27 18:35 ` Christophe Leroy
2024-02-27 19:04 ` Charlie Jenkins
2024-02-27 19:31 ` Guenter Roeck
2024-02-27 22:44 ` David Laight
2024-02-28 5:19 ` Guenter Roeck
2024-02-28 0:24 ` Charlie Jenkins
2024-02-28 0:21 ` Charlie Jenkins
2024-02-28 7:25 ` Christophe Leroy
2024-02-28 7:59 ` Guenter Roeck
2024-02-28 10:15 ` Geert Uytterhoeven
2024-02-28 15:40 ` Guenter Roeck
2024-02-29 8:07 ` David Gow
2024-02-29 19:38 ` Charlie Jenkins
2024-02-29 20:22 ` Guenter Roeck
2024-03-01 7:00 ` Christophe Leroy
2024-03-01 6:46 ` Christophe Leroy
2024-03-01 16:24 ` Guenter Roeck
2024-03-01 20:47 ` Guenter Roeck [this message]
2024-02-27 11:17 ` Geert Uytterhoeven
2024-02-27 17:55 ` Charlie Jenkins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11842961-91c2-40bf-9134-7528d30137f3@roeck-us.net \
--to=linux@roeck-us.net \
--cc=David.Laight@aculab.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=charlie@rivosinc.com \
--cc=christophe.leroy@csgroup.eu \
--cc=deller@gmx.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=palmer@dabbelt.com \
--cc=palmer@rivosinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).