From: Charlie Jenkins <charlie@rivosinc.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org,
Palmer Dabbelt <palmer@rivosinc.com>
Subject: Re: [PATCH] MIPS: Add 'memory' clobber to csum_ipv6_magic() inline assembler
Date: Sun, 11 Feb 2024 19:53:06 -0800 [thread overview]
Message-ID: <ZcmWIhn8/G2QK+jP@ghost> (raw)
In-Reply-To: <20240211160837.2436375-1-linux@roeck-us.net>
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>
next prev parent reply other threads:[~2024-02-12 3:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2024-02-12 22:08 ` Thomas Bogendoerfer
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=ZcmWIhn8/G2QK+jP@ghost \
--to=charlie@rivosinc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=palmer@rivosinc.com \
--cc=tsbogend@alpha.franken.de \
/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