]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
parisc: Strip upper 32 bit of sum in csum_ipv6_magic for 64-bit builds
authorGuenter Roeck <linux@roeck-us.net>
Tue, 27 Feb 2024 20:33:51 +0000 (12:33 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Apr 2024 13:28:22 +0000 (15:28 +0200)
commit644604e6f0143297172c0429ee6c85f3b3e805ea
tree3a3e78198412f833e58b7ed0da8dbbbe693e0974
parentd4b71ff9c9187afd8d29ef41a93ee6e5b8b54b25
parisc: Strip upper 32 bit of sum in csum_ipv6_magic for 64-bit builds

[ Upstream commit 0568b6f0d863643db2edcc7be31165740c89fa82 ]

IPv6 checksum tests with unaligned addresses on 64-bit builds result
in unexpected failures.

Expected expected == csum_result, but
    expected == 46591 (0xb5ff)
    csum_result == 46381 (0xb52d)
with alignment offset 1

Oddly enough, the problem disappeared after adding test code into
the beginning of csum_ipv6_magic().

As it turns out, the 'sum' parameter of csum_ipv6_magic() is declared as
__wsum, which is a 32-bit variable. However, it is treated as 64-bit
variable in the 64-bit assembler code. Tests showed that the upper 32 bit
of the register used to pass the variable are _not_ cleared when entering
the function. This can result in checksum calculation errors.

Clearing the upper 32 bit of 'sum' as first operation in the assembler
code fixes the problem.

Acked-by: Helge Deller <deller@gmx.de>
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/parisc/include/asm/checksum.h