* [PATCH v2] parisc: Strip upper 32 bit of sum in csum_ipv6_magic for 64-bit builds
@ 2024-02-27 20:33 Guenter Roeck
2024-02-27 21:43 ` Helge Deller
0 siblings, 1 reply; 2+ messages in thread
From: Guenter Roeck @ 2024-02-27 20:33 UTC (permalink / raw)
To: Helge Deller
Cc: James E . J . Bottomley, linux-parisc, linux-kernel,
Guenter Roeck
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")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: Updated subject, clarified that the problem only affects 64-bit builds,
added Helge's Acked-by: tag.
arch/parisc/include/asm/checksum.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/parisc/include/asm/checksum.h b/arch/parisc/include/asm/checksum.h
index c949aa20fa16..2aceebcd695c 100644
--- a/arch/parisc/include/asm/checksum.h
+++ b/arch/parisc/include/asm/checksum.h
@@ -126,6 +126,7 @@ static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
** Try to keep 4 registers with "live" values ahead of the ALU.
*/
+" depdi 0, 31, 32, %0\n"/* clear upper half of incoming checksum */
" ldd,ma 8(%1), %4\n" /* get 1st saddr word */
" ldd,ma 8(%2), %5\n" /* get 1st daddr word */
" add %4, %0, %0\n"
--
2.39.2
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] parisc: Strip upper 32 bit of sum in csum_ipv6_magic for 64-bit builds
2024-02-27 20:33 [PATCH v2] parisc: Strip upper 32 bit of sum in csum_ipv6_magic for 64-bit builds Guenter Roeck
@ 2024-02-27 21:43 ` Helge Deller
0 siblings, 0 replies; 2+ messages in thread
From: Helge Deller @ 2024-02-27 21:43 UTC (permalink / raw)
To: Guenter Roeck; +Cc: James E . J . Bottomley, linux-parisc, linux-kernel
On 2/27/24 21:33, Guenter Roeck wrote:
> 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")
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
applied.
Thanks!
Helge
> ---
> v2: Updated subject, clarified that the problem only affects 64-bit builds,
> added Helge's Acked-by: tag.
>
> arch/parisc/include/asm/checksum.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/parisc/include/asm/checksum.h b/arch/parisc/include/asm/checksum.h
> index c949aa20fa16..2aceebcd695c 100644
> --- a/arch/parisc/include/asm/checksum.h
> +++ b/arch/parisc/include/asm/checksum.h
> @@ -126,6 +126,7 @@ static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
> ** Try to keep 4 registers with "live" values ahead of the ALU.
> */
>
> +" depdi 0, 31, 32, %0\n"/* clear upper half of incoming checksum */
> " ldd,ma 8(%1), %4\n" /* get 1st saddr word */
> " ldd,ma 8(%2), %5\n" /* get 1st daddr word */
> " add %4, %0, %0\n"
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-27 21:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-27 20:33 [PATCH v2] parisc: Strip upper 32 bit of sum in csum_ipv6_magic for 64-bit builds Guenter Roeck
2024-02-27 21:43 ` Helge Deller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox