linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Paul Mackerras <paulus@ozlabs.org>
To: LEROY Christophe <christophe.leroy@c-s.fr>
Cc: Shile Zhang <shile.zhang@nokia.com>,
	linuxppc-dev@lists.ozlabs.org,
	Michael Ellerman <mpe@ellerman.id.au>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [PATCH] powerpc/64: Fix checksum folding in csum_add
Date: Thu, 29 Mar 2018 07:40:27 +1100	[thread overview]
Message-ID: <20180328204027.GA2069@fergus.ozlabs.ibm.com> (raw)
In-Reply-To: <20180327172232.Horde.q3HjdRzVlIYmg2LP87jw8A1@messagerie.si.c-s.fr>

On Tue, Mar 27, 2018 at 05:22:32PM +0200, LEROY Christophe wrote:
> Shile Zhang <shile.zhang@nokia.com> a écrit :
> 
> >fix the missed point in Paul's patch:
> >"powerpc/64: Fix checksum folding in csum_tcpudp_nofold and
> >ip_fast_csum_nofold"
> >
> >Signed-off-by: Shile Zhang <shile.zhang@nokia.com>
> >---
> > arch/powerpc/include/asm/checksum.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> >diff --git a/arch/powerpc/include/asm/checksum.h
> >b/arch/powerpc/include/asm/checksum.h
> >index 5b1a6e3..430d038 100644
> >--- a/arch/powerpc/include/asm/checksum.h
> >+++ b/arch/powerpc/include/asm/checksum.h
> >@@ -108,7 +108,7 @@ static inline __wsum csum_add(__wsum csum, __wsum addend)
> >
> > #ifdef __powerpc64__
> > 	res += (__force u64)addend;
> >-	return (__force __wsum)((u32)res + (res >> 32));
> >+	return (__force __wsum) from64to32(res);
> 
> Did you encounter a bug due to that ?
> As far as i understand, csum and addend are 32 bits so can't exceed 0xffffffff
> Then their sum won't exceed 0x1fffffffe. So the sum of upper and lower part
> won't carry

If the sum of the two halves was 0x1fffffffe, then that previously got
truncated to 32 bits and returned as 0xfffffffe, which is wrong - the
result should be 0xffffffff.

Paul.

  reply	other threads:[~2018-03-28 20:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-04  9:03 [PATCH] powerpc/64: Fix checksum folding in csum_add Shile Zhang
2017-03-03  3:50 ` Paul Mackerras
2017-03-08  7:25 ` Michael Ellerman
2018-03-27 15:22 ` [PATCH] " LEROY Christophe
2018-03-28 20:40   ` Paul Mackerras [this message]
2018-03-29 15:36     ` LEROY Christophe

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=20180328204027.GA2069@fergus.ozlabs.ibm.com \
    --to=paulus@ozlabs.org \
    --cc=benh@kernel.crashing.org \
    --cc=christophe.leroy@c-s.fr \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=shile.zhang@nokia.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 NNTP newsgroup(s).