linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/64: Fix checksum folding in csum_add
@ 2017-02-04  9:03 Shile Zhang
  2017-03-03  3:50 ` Paul Mackerras
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Shile Zhang @ 2017-02-04  9:03 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linuxppc-dev, Shile Zhang

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);
 #else
 	asm("addc %0,%0,%1;"
 	    "addze %0,%0;"
-- 
2.6.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] powerpc/64: Fix checksum folding in csum_add
  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
  2 siblings, 0 replies; 6+ messages in thread
From: Paul Mackerras @ 2017-03-03  3:50 UTC (permalink / raw)
  To: Shile Zhang; +Cc: Benjamin Herrenschmidt, Michael Ellerman, linuxppc-dev

On Sat, Feb 04, 2017 at 05:03:40PM +0800, Shile Zhang wrote:
> 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>

Acked-by: Paul Mackerras <paulus@ozlabs.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: powerpc/64: Fix checksum folding in csum_add
  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
  2 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2017-03-08  7:25 UTC (permalink / raw)
  To: Shile Zhang, Benjamin Herrenschmidt, Paul Mackerras
  Cc: Shile Zhang, linuxppc-dev

On Sat, 2017-02-04 at 09:03:40 UTC, Shile Zhang wrote:
> 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>
> Acked-by: Paul Mackerras <paulus@ozlabs.org>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/6ad966d7303b70165228dba1ee8da1

cheers

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] powerpc/64: Fix checksum folding in csum_add
  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 ` LEROY Christophe
  2018-03-28 20:40   ` Paul Mackerras
  2 siblings, 1 reply; 6+ messages in thread
From: LEROY Christophe @ 2018-03-27 15:22 UTC (permalink / raw)
  To: Shile Zhang
  Cc: linuxppc-dev, Michael Ellerman, Paul Mackerras,
	Benjamin Herrenschmidt

Shile Zhang <shile.zhang@nokia.com> a =C3=A9crit=C2=A0:

> 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=20=20
>=20b/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 add=
end)
>
>  #ifdef __powerpc64__
>  	res +=3D (__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 0xfffff=
fff
Then their sum won't exceed 0x1fffffffe. So the sum of upper and lower=20=
=20
part=20won't carry

Christophe

>  #else
>  	asm("addc %0,%0,%1;"
>  	    "addze %0,%0;"
> --
> 2.6.2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] powerpc/64: Fix checksum folding in csum_add
  2018-03-27 15:22 ` [PATCH] " LEROY Christophe
@ 2018-03-28 20:40   ` Paul Mackerras
  2018-03-29 15:36     ` LEROY Christophe
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Mackerras @ 2018-03-28 20:40 UTC (permalink / raw)
  To: LEROY Christophe
  Cc: Shile Zhang, linuxppc-dev, Michael Ellerman,
	Benjamin Herrenschmidt

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] powerpc/64: Fix checksum folding in csum_add
  2018-03-28 20:40   ` Paul Mackerras
@ 2018-03-29 15:36     ` LEROY Christophe
  0 siblings, 0 replies; 6+ messages in thread
From: LEROY Christophe @ 2018-03-29 15:36 UTC (permalink / raw)
  To: Paul Mackerras
  Cc: Benjamin Herrenschmidt, Michael Ellerman, linuxppc-dev,
	Shile Zhang

Paul Mackerras <paulus@ozlabs.org> a =C3=A9crit=C2=A0:

> On Tue, Mar 27, 2018 at 05:22:32PM +0200, LEROY Christophe wrote:
>> Shile Zhang <shile.zhang@nokia.com> a =C3=A9crit=C2=A0:
>>
>> >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,=20=20
>>=20__wsum addend)
>> >
>> > #ifdef __powerpc64__
>> > 	res +=3D (__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=20=
=20
>>=200xffffffff
>> Then their sum won't exceed 0x1fffffffe. So the sum of upper and lower p=
art
>> 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.
>

It is the sum of the two arguments of csum_add() which can't exceed=20=20
0x1fffffffe
So=20the sum of the two halves will be 0xffffffff which is the expected res=
ult.

The issue would start with res =3D 0x1ffffffff, in that case the sum of=20=
=20
the=20two halves would be 0x100000000 which would have been truncated to=20=
=20
0=20whereas we expect the result to be 1 in that case.
But in order to obtain res =3D 0x1ffffffff or higher, you have to sum at=20=
=20
least=20three 32 bits numbers. You can't obtain such a value with a sum=20=
=20
of=20two 32 bits numbers.

Christophe

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-03-29 15:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2018-03-29 15:36     ` LEROY Christophe

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).