From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752462AbcHDDxr (ORCPT ); Wed, 3 Aug 2016 23:53:47 -0400 Received: from host.buserror.net ([209.198.135.123]:55725 "EHLO host.buserror.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750775AbcHDDxq (ORCPT ); Wed, 3 Aug 2016 23:53:46 -0400 Message-ID: <1470282813.25630.242.camel@buserror.net> From: Scott Wood To: Christophe Leroy , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, stable@vger.kernel.org, antoine.blangy@c-s.fr, segher@kernel.crashing.org, Alessio Igor Bogani Date: Wed, 03 Aug 2016 22:53:33 -0500 In-Reply-To: <20160802080705.69A9F1A2394@localhost.localdomain> References: <20160802080705.69A9F1A2394@localhost.localdomain> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 75.72.173.242 X-SA-Exim-Mail-From: oss@buserror.net X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * -15 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Subject: Re: [PATCH v2] powerpc/32: fix csum_partial_copy_generic() X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:57:07 +0000) X-SA-Exim-Scanned: Yes (on host.buserror.net) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2016-08-02 at 10:07 +0200, Christophe Leroy wrote: > commit 7aef4136566b0 ("powerpc32: rewrite csum_partial_copy_generic() > based on copy_tofrom_user()") introduced a bug when destination > address is odd and initial csum is not null > > In that (rare) case the initial csum value has to be rotated one byte > as well as the resulting value is > > This patch also fixes related comments > > Fixes: 7aef4136566b0 ("powerpc32: rewrite csum_partial_copy_generic() > based on copy_tofrom_user()") > Cc: stable@vger.kernel.org > > Signed-off-by: Christophe Leroy > --- >  v2: updated comments as suggested by Segher > >  arch/powerpc/lib/checksum_32.S | 7 ++++--- >  1 file changed, 4 insertions(+), 3 deletions(-) Alessio, can you confirm whether this fixes the problem you reported? -Scott > > diff --git a/arch/powerpc/lib/checksum_32.S b/arch/powerpc/lib/checksum_32.S > index d90870a..0a57fe6 100644 > --- a/arch/powerpc/lib/checksum_32.S > +++ b/arch/powerpc/lib/checksum_32.S > @@ -127,8 +127,9 @@ _GLOBAL(csum_partial_copy_generic) >   stw r7,12(r1) >   stw r8,8(r1) >   > - andi. r0,r4,1 /* is destination > address even ? */ > - cmplwi cr7,r0,0 > + rlwinm r0,r4,3,0x8 > + rlwnm r6,r6,r0,0,31 /* odd destination address: > rotate one byte */ > + cmplwi cr7,r0,0 /* is destination address even ? */ >   addic r12,r6,0 >   addi r6,r4,-4 >   neg r0,r4 > @@ -237,7 +238,7 @@ _GLOBAL(csum_partial_copy_generic) >  66: addze r3,r12 >   addi r1,r1,16 >   beqlr+ cr7 > - rlwinm r3,r3,8,0,31 /* swap bytes for odd destination > */ > + rlwinm r3,r3,8,0,31 /* odd destination address: > rotate one byte */ >   blr >   >  /* read fault */