* [PATCH] MIPS: Add 'memory' clobber to csum_ipv6_magic() inline assembler
@ 2024-02-11 16:08 Guenter Roeck
2024-02-12 3:53 ` Charlie Jenkins
2024-02-12 22:08 ` Thomas Bogendoerfer
0 siblings, 2 replies; 3+ messages in thread
From: Guenter Roeck @ 2024-02-11 16:08 UTC (permalink / raw)
To: Thomas Bogendoerfer
Cc: linux-mips, linux-kernel, Guenter Roeck, Charlie Jenkins,
Palmer Dabbelt
After 'lib: checksum: Use aligned accesses for ip_fast_csum and
csum_ipv6_magic tests' was applied, the test_csum_ipv6_magic unit test
started failing for all mips platforms, both little and bit endian.
Oddly enough, adding debug code into test_csum_ipv6_magic() made the
problem disappear.
The gcc manual says:
"The "memory" clobber tells the compiler that the assembly code performs
memory reads or writes to items other than those listed in the input
and output operands (for example, accessing the memory pointed to by one
of the input parameters)
"
This is definitely the case for csum_ipv6_magic(). Indeed, adding the
'memory' clobber fixes the problem.
Cc: Charlie Jenkins <charlie@rivosinc.com>
Cc: Palmer Dabbelt <palmer@rivosinc.com>
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
arch/mips/include/asm/checksum.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/mips/include/asm/checksum.h b/arch/mips/include/asm/checksum.h
index 4044eaf989ac..0921ddda11a4 100644
--- a/arch/mips/include/asm/checksum.h
+++ b/arch/mips/include/asm/checksum.h
@@ -241,7 +241,8 @@ static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
" .set pop"
: "=&r" (sum), "=&r" (tmp)
: "r" (saddr), "r" (daddr),
- "0" (htonl(len)), "r" (htonl(proto)), "r" (sum));
+ "0" (htonl(len)), "r" (htonl(proto)), "r" (sum)
+ : "memory");
return csum_fold(sum);
}
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] MIPS: Add 'memory' clobber to csum_ipv6_magic() inline assembler
2024-02-11 16:08 [PATCH] MIPS: Add 'memory' clobber to csum_ipv6_magic() inline assembler Guenter Roeck
@ 2024-02-12 3:53 ` Charlie Jenkins
2024-02-12 22:08 ` Thomas Bogendoerfer
1 sibling, 0 replies; 3+ messages in thread
From: Charlie Jenkins @ 2024-02-12 3:53 UTC (permalink / raw)
To: Guenter Roeck
Cc: Thomas Bogendoerfer, linux-mips, linux-kernel, Palmer Dabbelt
On Sun, Feb 11, 2024 at 08:08:37AM -0800, Guenter Roeck wrote:
> After 'lib: checksum: Use aligned accesses for ip_fast_csum and
> csum_ipv6_magic tests' was applied, the test_csum_ipv6_magic unit test
> started failing for all mips platforms, both little and bit endian.
> Oddly enough, adding debug code into test_csum_ipv6_magic() made the
> problem disappear.
>
> The gcc manual says:
>
> "The "memory" clobber tells the compiler that the assembly code performs
> memory reads or writes to items other than those listed in the input
> and output operands (for example, accessing the memory pointed to by one
> of the input parameters)
> "
>
> This is definitely the case for csum_ipv6_magic(). Indeed, adding the
> 'memory' clobber fixes the problem.
>
> Cc: Charlie Jenkins <charlie@rivosinc.com>
> Cc: Palmer Dabbelt <palmer@rivosinc.com>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> arch/mips/include/asm/checksum.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/mips/include/asm/checksum.h b/arch/mips/include/asm/checksum.h
> index 4044eaf989ac..0921ddda11a4 100644
> --- a/arch/mips/include/asm/checksum.h
> +++ b/arch/mips/include/asm/checksum.h
> @@ -241,7 +241,8 @@ static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
> " .set pop"
> : "=&r" (sum), "=&r" (tmp)
> : "r" (saddr), "r" (daddr),
> - "0" (htonl(len)), "r" (htonl(proto)), "r" (sum));
> + "0" (htonl(len)), "r" (htonl(proto)), "r" (sum)
> + : "memory");
>
> return csum_fold(sum);
> }
> --
> 2.39.2
>
Thank you for looking into this. It fixed the failure on my mips64el
qemu setup.
Reviewed-by: Charlie Jenkins <charlie@rivosinc.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] MIPS: Add 'memory' clobber to csum_ipv6_magic() inline assembler
2024-02-11 16:08 [PATCH] MIPS: Add 'memory' clobber to csum_ipv6_magic() inline assembler Guenter Roeck
2024-02-12 3:53 ` Charlie Jenkins
@ 2024-02-12 22:08 ` Thomas Bogendoerfer
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Bogendoerfer @ 2024-02-12 22:08 UTC (permalink / raw)
To: Guenter Roeck; +Cc: linux-mips, linux-kernel, Charlie Jenkins, Palmer Dabbelt
On Sun, Feb 11, 2024 at 08:08:37AM -0800, Guenter Roeck wrote:
> After 'lib: checksum: Use aligned accesses for ip_fast_csum and
> csum_ipv6_magic tests' was applied, the test_csum_ipv6_magic unit test
> started failing for all mips platforms, both little and bit endian.
> Oddly enough, adding debug code into test_csum_ipv6_magic() made the
> problem disappear.
>
> The gcc manual says:
>
> "The "memory" clobber tells the compiler that the assembly code performs
> memory reads or writes to items other than those listed in the input
> and output operands (for example, accessing the memory pointed to by one
> of the input parameters)
> "
>
> This is definitely the case for csum_ipv6_magic(). Indeed, adding the
> 'memory' clobber fixes the problem.
>
> Cc: Charlie Jenkins <charlie@rivosinc.com>
> Cc: Palmer Dabbelt <palmer@rivosinc.com>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> arch/mips/include/asm/checksum.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/mips/include/asm/checksum.h b/arch/mips/include/asm/checksum.h
> index 4044eaf989ac..0921ddda11a4 100644
> --- a/arch/mips/include/asm/checksum.h
> +++ b/arch/mips/include/asm/checksum.h
> @@ -241,7 +241,8 @@ static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
> " .set pop"
> : "=&r" (sum), "=&r" (tmp)
> : "r" (saddr), "r" (daddr),
> - "0" (htonl(len)), "r" (htonl(proto)), "r" (sum));
> + "0" (htonl(len)), "r" (htonl(proto)), "r" (sum)
> + : "memory");
>
> return csum_fold(sum);
> }
> --
> 2.39.2
applied to mips-fixes.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-12 22:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-11 16:08 [PATCH] MIPS: Add 'memory' clobber to csum_ipv6_magic() inline assembler Guenter Roeck
2024-02-12 3:53 ` Charlie Jenkins
2024-02-12 22:08 ` Thomas Bogendoerfer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox