[PATCH] crypto: sha1-powerpc: little-endian support

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE3594d

8 messages, 4 authors, 2016-10-04 · open the first message on its own page

[PATCH] crypto: sha1-powerpc: little-endian support

From: Marcelo Cerri <hidden>
Date: 2016-09-23 19:32:59

The driver does not handle endianness properly when loading the input
data.

Signed-off-by: Marcelo Cerri <redacted>
---
 arch/powerpc/crypto/sha1-powerpc-asm.S | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/crypto/sha1-powerpc-asm.S b/arch/powerpc/crypto/sha1-powerpc-asm.S
index 125e165..82ddc9b 100644
--- a/arch/powerpc/crypto/sha1-powerpc-asm.S
+++ b/arch/powerpc/crypto/sha1-powerpc-asm.S
@@ -7,6 +7,15 @@
 #include <asm/ppc_asm.h>
 #include <asm/asm-offsets.h>
 
+#ifdef __BIG_ENDIAN__
+#define LWZ(rt, d, ra)	\
+	lwz	rt,d(ra)
+#else
+#define LWZ(rt, d, ra)	\
+	li	rt,d;	\
+	lwbrx	rt,rt,ra
+#endif
+
 /*
  * We roll the registers for T, A, B, C, D, E around on each
  * iteration; T on iteration t is A on iteration t+1, and so on.
@@ -23,7 +32,7 @@
 #define W(t)	(((t)%16)+16)
 
 #define LOADW(t)				\
-	lwz	W(t),(t)*4(r4)
+	LWZ(W(t),(t)*4,r4)
 
 #define STEPD0_LOAD(t)				\
 	andc	r0,RD(t),RB(t);		\
@@ -33,7 +42,7 @@
 	add	r0,RE(t),r15;			\
 	add	RT(t),RT(t),r6;		\
 	add	r14,r0,W(t);			\
-	lwz	W((t)+4),((t)+4)*4(r4);	\
+	LWZ(W((t)+4),((t)+4)*4,r4);	\
 	rotlwi	RB(t),RB(t),30;			\
 	add	RT(t),RT(t),r14
 
-- 
2.7.4

Re: [PATCH] crypto: sha1-powerpc: little-endian support

From: Paulo Flabiano Smorigo <hidden>
Date: 2016-09-27 00:46:42

Fri, Sep 23, 2016 at 04:31:56PM -0300, Marcelo Cerri wrote:
The driver does not handle endianness properly when loading the input
data.
Indeed. I tested in both endianesses and it's working fine. Thanks!

Herbert, can we go ahead with this fix?
quoted hunk
Signed-off-by: Marcelo Cerri <redacted>
---
 arch/powerpc/crypto/sha1-powerpc-asm.S | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/crypto/sha1-powerpc-asm.S b/arch/powerpc/crypto/sha1-powerpc-asm.S
index 125e165..82ddc9b 100644
--- a/arch/powerpc/crypto/sha1-powerpc-asm.S
+++ b/arch/powerpc/crypto/sha1-powerpc-asm.S
@@ -7,6 +7,15 @@
 #include <asm/ppc_asm.h>
 #include <asm/asm-offsets.h>

+#ifdef __BIG_ENDIAN__
+#define LWZ(rt, d, ra)	\
+	lwz	rt,d(ra)
+#else
+#define LWZ(rt, d, ra)	\
+	li	rt,d;	\
+	lwbrx	rt,rt,ra
+#endif
+
 /*
  * We roll the registers for T, A, B, C, D, E around on each
  * iteration; T on iteration t is A on iteration t+1, and so on.
@@ -23,7 +32,7 @@
 #define W(t)	(((t)%16)+16)

 #define LOADW(t)				\
-	lwz	W(t),(t)*4(r4)
+	LWZ(W(t),(t)*4,r4)

 #define STEPD0_LOAD(t)				\
 	andc	r0,RD(t),RB(t);		\
@@ -33,7 +42,7 @@
 	add	r0,RE(t),r15;			\
 	add	RT(t),RT(t),r6;		\
 	add	r14,r0,W(t);			\
-	lwz	W((t)+4),((t)+4)*4(r4);	\
+	LWZ(W((t)+4),((t)+4)*4,r4);	\
 	rotlwi	RB(t),RB(t),30;			\
 	add	RT(t),RT(t),r14
-- 
2.7.4
-- 
Paulo Flabiano Smorigo
IBM Linux Technology Center

Re: [PATCH] crypto: sha1-powerpc: little-endian support

From: Marcelo Cerri <hidden>
Date: 2016-09-28 13:16:06

Hi Herbert,

Any thoughts on this one?

-- 
Regards,
Marcelo

On Fri, Sep 23, 2016 at 04:31:56PM -0300, Marcelo Cerri wrote:
quoted hunk
The driver does not handle endianness properly when loading the input
data.

Signed-off-by: Marcelo Cerri <redacted>
---
 arch/powerpc/crypto/sha1-powerpc-asm.S | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/crypto/sha1-powerpc-asm.S b/arch/powerpc/crypto/sha1-powerpc-asm.S
index 125e165..82ddc9b 100644
--- a/arch/powerpc/crypto/sha1-powerpc-asm.S
+++ b/arch/powerpc/crypto/sha1-powerpc-asm.S
@@ -7,6 +7,15 @@
 #include <asm/ppc_asm.h>
 #include <asm/asm-offsets.h>
 
+#ifdef __BIG_ENDIAN__
+#define LWZ(rt, d, ra)	\
+	lwz	rt,d(ra)
+#else
+#define LWZ(rt, d, ra)	\
+	li	rt,d;	\
+	lwbrx	rt,rt,ra
+#endif
+
 /*
  * We roll the registers for T, A, B, C, D, E around on each
  * iteration; T on iteration t is A on iteration t+1, and so on.
@@ -23,7 +32,7 @@
 #define W(t)	(((t)%16)+16)
 
 #define LOADW(t)				\
-	lwz	W(t),(t)*4(r4)
+	LWZ(W(t),(t)*4,r4)
 
 #define STEPD0_LOAD(t)				\
 	andc	r0,RD(t),RB(t);		\
@@ -33,7 +42,7 @@
 	add	r0,RE(t),r15;			\
 	add	RT(t),RT(t),r6;		\
 	add	r14,r0,W(t);			\
-	lwz	W((t)+4),((t)+4)*4(r4);	\
+	LWZ(W((t)+4),((t)+4)*4,r4);	\
 	rotlwi	RB(t),RB(t),30;			\
 	add	RT(t),RT(t),r14
 
-- 
2.7.4

Re: [PATCH] crypto: sha1-powerpc: little-endian support

From: Herbert Xu <herbert@gondor.apana.org.au>
Date: 2016-09-28 13:20:56

On Wed, Sep 28, 2016 at 10:15:51AM -0300, Marcelo Cerri wrote:
Hi Herbert,

Any thoughts on this one?
Can this patch wait until the next merge window? On the broken
platforms it should just fail the self-test, right?

Cheers,
-- 
Email: Herbert Xu [off-list ref]
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: [PATCH] crypto: sha1-powerpc: little-endian support

From: Marcelo Cerri <hidden>
Date: 2016-09-28 13:27:34

On Wed, Sep 28, 2016 at 09:20:15PM +0800, Herbert Xu wrote:
On Wed, Sep 28, 2016 at 10:15:51AM -0300, Marcelo Cerri wrote:
quoted
Hi Herbert,

Any thoughts on this one?
Can this patch wait until the next merge window? On the broken
platforms it should just fail the self-test, right?
Yes. It fails on any LE platform (including Ubuntu and RHEL 7.1).
Cheers,
-- 
Email: Herbert Xu [off-list ref]
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
-- 
Regards,
Marcelo

Re: [PATCH] crypto: sha1-powerpc: little-endian support

From: Herbert Xu <herbert@gondor.apana.org.au>
Date: 2016-10-02 14:38:14

On Fri, Sep 23, 2016 at 04:31:56PM -0300, Marcelo Cerri wrote:
The driver does not handle endianness properly when loading the input
data.

Signed-off-by: Marcelo Cerri <redacted>
Patch applied.  Thanks.
-- 
Email: Herbert Xu [off-list ref]
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: [PATCH] crypto: sha1-powerpc: little-endian support

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2016-10-04 06:23:22

Marcelo Cerri [off-list ref] writes:
[ Unknown signature status ]
On Wed, Sep 28, 2016 at 09:20:15PM +0800, Herbert Xu wrote:
quoted
On Wed, Sep 28, 2016 at 10:15:51AM -0300, Marcelo Cerri wrote:
quoted
Hi Herbert,

Any thoughts on this one?
Can this patch wait until the next merge window? On the broken
platforms it should just fail the self-test, right?
Yes. It fails on any LE platform (including Ubuntu and RHEL 7.1).
How are you testing this? I thought I was running the crypto tests but
I've never seen this fail.

cheers

Re: [PATCH] crypto: sha1-powerpc: little-endian support

From: Marcelo Cerri <hidden>
Date: 2016-10-04 12:07:47

Hi Michael,

On Ubuntu, CRYPTO_MANAGER_DISABLE_TESTS is set by default. So I had to
disable this config in order to make sha1-powerpc fail in the crypto API
tests. However, even with tests disabled, any usage of sha1-powerpc
should result in incorrect results.

-- 
Regards,
Marcelo

On Tue, Oct 04, 2016 at 05:23:16PM +1100, Michael Ellerman wrote:
Marcelo Cerri [off-list ref] writes:
quoted
[ Unknown signature status ]
On Wed, Sep 28, 2016 at 09:20:15PM +0800, Herbert Xu wrote:
quoted
On Wed, Sep 28, 2016 at 10:15:51AM -0300, Marcelo Cerri wrote:
quoted
Hi Herbert,

Any thoughts on this one?
Can this patch wait until the next merge window? On the broken
platforms it should just fail the self-test, right?
Yes. It fails on any LE platform (including Ubuntu and RHEL 7.1).
How are you testing this? I thought I was running the crypto tests but
I've never seen this fail.

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help