All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] powerpc: use big endian to hash len and proto in csum_ipv6_magic
@ 2018-09-08 10:15 Xin Long
  2018-09-08 16:33   ` LEROY Christophe
  2018-09-12  6:01 ` David Miller
  0 siblings, 2 replies; 6+ messages in thread
From: Xin Long @ 2018-09-08 10:15 UTC (permalink / raw)
  To: network dev, linuxppc-dev
  Cc: Christophe Leroy, Michael Ellerman, Roopa Prabhu

The function csum_ipv6_magic doesn't convert len and proto to big
endian before doing ipv6 csum hash, which is not consistent with
RFC and other arches.

Jianlin found it when ICMPv6 packets from other hosts were dropped
in the powerpc64 system.

This patch is to fix it by using instruction 'lwbrx' to do this
conversion in powerpc32/64 csum_ipv6_magic.

Fixes: e9c4943a107b ("powerpc: Implement csum_ipv6_magic in assembly")
Reported-by: Jianlin Shi <jishi@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 arch/powerpc/lib/checksum_32.S | 4 ++++
 arch/powerpc/lib/checksum_64.S | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/arch/powerpc/lib/checksum_32.S b/arch/powerpc/lib/checksum_32.S
index aa22406..7d3446e 100644
--- a/arch/powerpc/lib/checksum_32.S
+++ b/arch/powerpc/lib/checksum_32.S
@@ -325,6 +325,10 @@ _GLOBAL(csum_ipv6_magic)
 	adde	r0, r0, r9
 	lwz	r11, 12(r4)
 	adde	r0, r0, r10
+	STWX_BE	r5, 0, r1
+	lwz	r5, 0(r1)
+	STWX_BE	r6, 0, r1
+	lwz	r6, 0(r1)
 	add	r5, r5, r6	/* assumption: len + proto doesn't carry */
 	adde	r0, r0, r11
 	adde	r0, r0, r5
diff --git a/arch/powerpc/lib/checksum_64.S b/arch/powerpc/lib/checksum_64.S
index 886ed94..302e732 100644
--- a/arch/powerpc/lib/checksum_64.S
+++ b/arch/powerpc/lib/checksum_64.S
@@ -439,6 +439,10 @@ EXPORT_SYMBOL(csum_partial_copy_generic)
 _GLOBAL(csum_ipv6_magic)
 	ld	r8, 0(r3)
 	ld	r9, 8(r3)
+	STWX_BE	r5, 0, r1
+	lwz	r5, 0(r1)
+	STWX_BE	r6, 0, r1
+	lwz	r6, 0(r1)
 	add	r5, r5, r6
 	addc	r0, r8, r9
 	ld	r10, 0(r4)
-- 
2.1.0

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

* Re: [PATCH net] powerpc: use big endian to hash len and proto in csum_ipv6_magic
  2018-09-08 10:15 [PATCH net] powerpc: use big endian to hash len and proto in csum_ipv6_magic Xin Long
@ 2018-09-08 16:33   ` LEROY Christophe
  2018-09-12  6:01 ` David Miller
  1 sibling, 0 replies; 6+ messages in thread
From: LEROY Christophe @ 2018-09-08 16:33 UTC (permalink / raw)
  To: Xin Long; +Cc: Roopa Prabhu, Michael Ellerman, linuxppc-dev, network dev

Xin Long <lucien.xin@gmail.com> a écrit :

> The function csum_ipv6_magic doesn't convert len and proto to big
> endian before doing ipv6 csum hash, which is not consistent with
> RFC and other arches.
>
> Jianlin found it when ICMPv6 packets from other hosts were dropped
> in the powerpc64 system.
>
> This patch is to fix it by using instruction 'lwbrx' to do this
> conversion in powerpc32/64 csum_ipv6_magic.
>
> Fixes: e9c4943a107b ("powerpc: Implement csum_ipv6_magic in assembly")
> Reported-by: Jianlin Shi <jishi@redhat.com>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
>  arch/powerpc/lib/checksum_32.S | 4 ++++
>  arch/powerpc/lib/checksum_64.S | 4 ++++
>  2 files changed, 8 insertions(+)
>
> diff --git a/arch/powerpc/lib/checksum_32.S b/arch/powerpc/lib/checksum_32.S
> index aa22406..7d3446e 100644
> --- a/arch/powerpc/lib/checksum_32.S
> +++ b/arch/powerpc/lib/checksum_32.S
> @@ -325,6 +325,10 @@ _GLOBAL(csum_ipv6_magic)
>  	adde	r0, r0, r9
>  	lwz	r11, 12(r4)
>  	adde	r0, r0, r10
> +	STWX_BE	r5, 0, r1
> +	lwz	r5, 0(r1)
> +	STWX_BE	r6, 0, r1
> +	lwz	r6, 0(r1)

PPC32 doesn't support little endian, so nothing to do here.

>  	add	r5, r5, r6	/* assumption: len + proto doesn't carry */
>  	adde	r0, r0, r11
>  	adde	r0, r0, r5
> diff --git a/arch/powerpc/lib/checksum_64.S b/arch/powerpc/lib/checksum_64.S
> index 886ed94..302e732 100644
> --- a/arch/powerpc/lib/checksum_64.S
> +++ b/arch/powerpc/lib/checksum_64.S
> @@ -439,6 +439,10 @@ EXPORT_SYMBOL(csum_partial_copy_generic)
>  _GLOBAL(csum_ipv6_magic)
>  	ld	r8, 0(r3)
>  	ld	r9, 8(r3)
> +	STWX_BE	r5, 0, r1
> +	lwz	r5, 0(r1)
> +	STWX_BE	r6, 0, r1
> +	lwz	r6, 0(r1)
>  	add	r5, r5, r6

This is overkill. For LE it should be enough to rotate r5 by 8 bits  
after the sum. Best place to do it would be after ld r11 I think.

Christophe

>  	addc	r0, r8, r9
>  	ld	r10, 0(r4)
> --
> 2.1.0

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

* Re: [PATCH net] powerpc: use big endian to hash len and proto in csum_ipv6_magic
@ 2018-09-08 16:33   ` LEROY Christophe
  0 siblings, 0 replies; 6+ messages in thread
From: LEROY Christophe @ 2018-09-08 16:33 UTC (permalink / raw)
  To: Xin Long; +Cc: Roopa Prabhu, Michael Ellerman, linuxppc-dev, network dev

Xin Long <lucien.xin@gmail.com> a =C3=A9crit=C2=A0:

> The function csum_ipv6_magic doesn't convert len and proto to big
> endian before doing ipv6 csum hash, which is not consistent with
> RFC and other arches.
>
> Jianlin found it when ICMPv6 packets from other hosts were dropped
> in the powerpc64 system.
>
> This patch is to fix it by using instruction 'lwbrx' to do this
> conversion in powerpc32/64 csum_ipv6_magic.
>
> Fixes: e9c4943a107b ("powerpc: Implement csum_ipv6_magic in assembly")
> Reported-by: Jianlin Shi <jishi@redhat.com>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
>  arch/powerpc/lib/checksum_32.S | 4 ++++
>  arch/powerpc/lib/checksum_64.S | 4 ++++
>  2 files changed, 8 insertions(+)
>
> diff --git a/arch/powerpc/lib/checksum_32.S b/arch/powerpc/lib/checksum_3=
2.S
> index aa22406..7d3446e 100644
> --- a/arch/powerpc/lib/checksum_32.S
> +++ b/arch/powerpc/lib/checksum_32.S
> @@ -325,6 +325,10 @@ _GLOBAL(csum_ipv6_magic)
>  	adde	r0, r0, r9
>  	lwz	r11, 12(r4)
>  	adde	r0, r0, r10
> +	STWX_BE	r5, 0, r1
> +	lwz	r5, 0(r1)
> +	STWX_BE	r6, 0, r1
> +	lwz	r6, 0(r1)

PPC32 doesn't support little endian, so nothing to do here.

>  	add	r5, r5, r6	/* assumption: len + proto doesn't carry */
>  	adde	r0, r0, r11
>  	adde	r0, r0, r5
> diff --git a/arch/powerpc/lib/checksum_64.S b/arch/powerpc/lib/checksum_6=
4.S
> index 886ed94..302e732 100644
> --- a/arch/powerpc/lib/checksum_64.S
> +++ b/arch/powerpc/lib/checksum_64.S
> @@ -439,6 +439,10 @@ EXPORT_SYMBOL(csum_partial_copy_generic)
>  _GLOBAL(csum_ipv6_magic)
>  	ld	r8, 0(r3)
>  	ld	r9, 8(r3)
> +	STWX_BE	r5, 0, r1
> +	lwz	r5, 0(r1)
> +	STWX_BE	r6, 0, r1
> +	lwz	r6, 0(r1)
>  	add	r5, r5, r6

This is overkill. For LE it should be enough to rotate r5 by 8 bits=20=20
after=20the sum. Best place to do it would be after ld r11 I think.

Christophe

>  	addc	r0, r8, r9
>  	ld	r10, 0(r4)
> --
> 2.1.0

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

* Re: [PATCH net] powerpc: use big endian to hash len and proto in csum_ipv6_magic
  2018-09-08 10:15 [PATCH net] powerpc: use big endian to hash len and proto in csum_ipv6_magic Xin Long
  2018-09-08 16:33   ` LEROY Christophe
@ 2018-09-12  6:01 ` David Miller
  2018-09-12  6:27   ` Christophe LEROY
  2018-09-12  6:27   ` Xin Long
  1 sibling, 2 replies; 6+ messages in thread
From: David Miller @ 2018-09-12  6:01 UTC (permalink / raw)
  To: lucien.xin; +Cc: netdev, linuxppc-dev, christophe.leroy, mpe, roopa

From: Xin Long <lucien.xin@gmail.com>
Date: Sat,  8 Sep 2018 18:15:12 +0800

> The function csum_ipv6_magic doesn't convert len and proto to big
> endian before doing ipv6 csum hash, which is not consistent with
> RFC and other arches.
> 
> Jianlin found it when ICMPv6 packets from other hosts were dropped
> in the powerpc64 system.
> 
> This patch is to fix it by using instruction 'lwbrx' to do this
> conversion in powerpc32/64 csum_ipv6_magic.
> 
> Fixes: e9c4943a107b ("powerpc: Implement csum_ipv6_magic in assembly")
> Reported-by: Jianlin Shi <jishi@redhat.com>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>

Xin, please address the feedback you were given.

Thank you.

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

* Re: [PATCH net] powerpc: use big endian to hash len and proto in csum_ipv6_magic
  2018-09-12  6:01 ` David Miller
@ 2018-09-12  6:27   ` Christophe LEROY
  2018-09-12  6:27   ` Xin Long
  1 sibling, 0 replies; 6+ messages in thread
From: Christophe LEROY @ 2018-09-12  6:27 UTC (permalink / raw)
  To: David Miller, lucien.xin; +Cc: netdev, linuxppc-dev, mpe, roopa


Le 12/09/2018 à 08:01, David Miller a écrit :
> From: Xin Long <lucien.xin@gmail.com>
> Date: Sat,  8 Sep 2018 18:15:12 +0800
> 
>> The function csum_ipv6_magic doesn't convert len and proto to big
>> endian before doing ipv6 csum hash, which is not consistent with
>> RFC and other arches.
>>
>> Jianlin found it when ICMPv6 packets from other hosts were dropped
>> in the powerpc64 system.
>>
>> This patch is to fix it by using instruction 'lwbrx' to do this
>> conversion in powerpc32/64 csum_ipv6_magic.
>>
>> Fixes: e9c4943a107b ("powerpc: Implement csum_ipv6_magic in assembly")
>> Reported-by: Jianlin Shi <jishi@redhat.com>
>> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> 
> Xin, please address the feedback you were given.

I submitted an alternative fix, and Lucien Xin gave its Tested-by:

See https://patchwork.ozlabs.org/patch/967868/

Christophe

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

* Re: [PATCH net] powerpc: use big endian to hash len and proto in csum_ipv6_magic
  2018-09-12  6:01 ` David Miller
  2018-09-12  6:27   ` Christophe LEROY
@ 2018-09-12  6:27   ` Xin Long
  1 sibling, 0 replies; 6+ messages in thread
From: Xin Long @ 2018-09-12  6:27 UTC (permalink / raw)
  To: davem
  Cc: network dev, linuxppc-dev, Christophe Leroy, Michael Ellerman,
	Roopa Prabhu

On Wed, Sep 12, 2018 at 2:01 PM David Miller <davem@davemloft.net> wrote:
>
> From: Xin Long <lucien.xin@gmail.com>
> Date: Sat,  8 Sep 2018 18:15:12 +0800
>
> > The function csum_ipv6_magic doesn't convert len and proto to big
> > endian before doing ipv6 csum hash, which is not consistent with
> > RFC and other arches.
> >
> > Jianlin found it when ICMPv6 packets from other hosts were dropped
> > in the powerpc64 system.
> >
> > This patch is to fix it by using instruction 'lwbrx' to do this
> > conversion in powerpc32/64 csum_ipv6_magic.
> >
> > Fixes: e9c4943a107b ("powerpc: Implement csum_ipv6_magic in assembly")
> > Reported-by: Jianlin Shi <jishi@redhat.com>
> > Signed-off-by: Xin Long <lucien.xin@gmail.com>
>
> Xin, please address the feedback you were given.
Christophe posted another one,
https://lore.kernel.org/patchwork/patch/983905/

Sorry, I didn't notice netdev wasn't in its CC-list.

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

end of thread, other threads:[~2018-09-12 11:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-08 10:15 [PATCH net] powerpc: use big endian to hash len and proto in csum_ipv6_magic Xin Long
2018-09-08 16:33 ` LEROY Christophe
2018-09-08 16:33   ` LEROY Christophe
2018-09-12  6:01 ` David Miller
2018-09-12  6:27   ` Christophe LEROY
2018-09-12  6:27   ` Xin Long

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.