summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-02-14 09:24:54 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-02-14 09:24:54 -0800
commitfd4703b312ea360a7acafb6b0dc468e958beecbf (patch)
tree3d30522502afbeeaa82848ef34f6de122e606a1c
parent7c20cd130a12b26855fc9a5293b77ea9f611019d (diff)
downloadlongterm-queue-2.6.32-fd4703b312ea360a7acafb6b0dc468e958beecbf.tar.gz
2.6.32-stable patches
added patches: crypto-sha512-avoid-stack-bloat-on-i386.patch crypto-sha512-use-binary-and-instead-of-modulus.patch
-rw-r--r--queue-2.6.32/crypto-sha512-avoid-stack-bloat-on-i386.patch111
-rw-r--r--queue-2.6.32/crypto-sha512-use-binary-and-instead-of-modulus.patch40
-rw-r--r--queue-2.6.32/series2
3 files changed, 153 insertions, 0 deletions
diff --git a/queue-2.6.32/crypto-sha512-avoid-stack-bloat-on-i386.patch b/queue-2.6.32/crypto-sha512-avoid-stack-bloat-on-i386.patch
new file mode 100644
index 0000000..2b7b393
--- /dev/null
+++ b/queue-2.6.32/crypto-sha512-avoid-stack-bloat-on-i386.patch
@@ -0,0 +1,111 @@
+From 3a92d687c8015860a19213e3c102cad6b722f83c Mon Sep 17 00:00:00 2001
+From: Herbert Xu <herbert@gondor.apana.org.au>
+Date: Sun, 5 Feb 2012 15:09:28 +1100
+Subject: crypto: sha512 - Avoid stack bloat on i386
+
+From: Herbert Xu <herbert@gondor.apana.org.au>
+
+commit 3a92d687c8015860a19213e3c102cad6b722f83c upstream.
+
+Unfortunately in reducing W from 80 to 16 we ended up unrolling
+the loop twice. As gcc has issues dealing with 64-bit ops on
+i386 this means that we end up using even more stack space (>1K).
+
+This patch solves the W reduction by moving LOAD_OP/BLEND_OP
+into the loop itself, thus avoiding the need to duplicate it.
+
+While the stack space still isn't great (>0.5K) it is at least
+in the same ball park as the amount of stack used for our C sha1
+implementation.
+
+Note that this patch basically reverts to the original code so
+the diff looks bigger than it really is.
+
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ crypto/sha512_generic.c | 68 ++++++++++++++++++++++--------------------------
+ 1 file changed, 32 insertions(+), 36 deletions(-)
+
+--- a/crypto/sha512_generic.c
++++ b/crypto/sha512_generic.c
+@@ -89,46 +89,42 @@ sha512_transform(u64 *state, const u8 *i
+ int i;
+ u64 W[16];
+
+- /* load the input */
+- for (i = 0; i < 16; i++)
+- LOAD_OP(i, W, input);
+-
+ /* load the state into our registers */
+ a=state[0]; b=state[1]; c=state[2]; d=state[3];
+ e=state[4]; f=state[5]; g=state[6]; h=state[7];
+
+-#define SHA512_0_15(i, a, b, c, d, e, f, g, h) \
+- t1 = h + e1(e) + Ch(e, f, g) + sha512_K[i] + W[i]; \
+- t2 = e0(a) + Maj(a, b, c); \
+- d += t1; \
+- h = t1 + t2
+-
+-#define SHA512_16_79(i, a, b, c, d, e, f, g, h) \
+- BLEND_OP(i, W); \
+- t1 = h + e1(e) + Ch(e, f, g) + sha512_K[i] + W[(i)&15]; \
+- t2 = e0(a) + Maj(a, b, c); \
+- d += t1; \
+- h = t1 + t2
+-
+- for (i = 0; i < 16; i += 8) {
+- SHA512_0_15(i, a, b, c, d, e, f, g, h);
+- SHA512_0_15(i + 1, h, a, b, c, d, e, f, g);
+- SHA512_0_15(i + 2, g, h, a, b, c, d, e, f);
+- SHA512_0_15(i + 3, f, g, h, a, b, c, d, e);
+- SHA512_0_15(i + 4, e, f, g, h, a, b, c, d);
+- SHA512_0_15(i + 5, d, e, f, g, h, a, b, c);
+- SHA512_0_15(i + 6, c, d, e, f, g, h, a, b);
+- SHA512_0_15(i + 7, b, c, d, e, f, g, h, a);
+- }
+- for (i = 16; i < 80; i += 8) {
+- SHA512_16_79(i, a, b, c, d, e, f, g, h);
+- SHA512_16_79(i + 1, h, a, b, c, d, e, f, g);
+- SHA512_16_79(i + 2, g, h, a, b, c, d, e, f);
+- SHA512_16_79(i + 3, f, g, h, a, b, c, d, e);
+- SHA512_16_79(i + 4, e, f, g, h, a, b, c, d);
+- SHA512_16_79(i + 5, d, e, f, g, h, a, b, c);
+- SHA512_16_79(i + 6, c, d, e, f, g, h, a, b);
+- SHA512_16_79(i + 7, b, c, d, e, f, g, h, a);
++ /* now iterate */
++ for (i=0; i<80; i+=8) {
++ if (!(i & 8)) {
++ int j;
++
++ if (i < 16) {
++ /* load the input */
++ for (j = 0; j < 16; j++)
++ LOAD_OP(i + j, W, input);
++ } else {
++ for (j = 0; j < 16; j++) {
++ BLEND_OP(i + j, W);
++ }
++ }
++ }
++
++ t1 = h + e1(e) + Ch(e,f,g) + sha512_K[i ] + W[(i & 15)];
++ t2 = e0(a) + Maj(a,b,c); d+=t1; h=t1+t2;
++ t1 = g + e1(d) + Ch(d,e,f) + sha512_K[i+1] + W[(i & 15) + 1];
++ t2 = e0(h) + Maj(h,a,b); c+=t1; g=t1+t2;
++ t1 = f + e1(c) + Ch(c,d,e) + sha512_K[i+2] + W[(i & 15) + 2];
++ t2 = e0(g) + Maj(g,h,a); b+=t1; f=t1+t2;
++ t1 = e + e1(b) + Ch(b,c,d) + sha512_K[i+3] + W[(i & 15) + 3];
++ t2 = e0(f) + Maj(f,g,h); a+=t1; e=t1+t2;
++ t1 = d + e1(a) + Ch(a,b,c) + sha512_K[i+4] + W[(i & 15) + 4];
++ t2 = e0(e) + Maj(e,f,g); h+=t1; d=t1+t2;
++ t1 = c + e1(h) + Ch(h,a,b) + sha512_K[i+5] + W[(i & 15) + 5];
++ t2 = e0(d) + Maj(d,e,f); g+=t1; c=t1+t2;
++ t1 = b + e1(g) + Ch(g,h,a) + sha512_K[i+6] + W[(i & 15) + 6];
++ t2 = e0(c) + Maj(c,d,e); f+=t1; b=t1+t2;
++ t1 = a + e1(f) + Ch(f,g,h) + sha512_K[i+7] + W[(i & 15) + 7];
++ t2 = e0(b) + Maj(b,c,d); e+=t1; a=t1+t2;
+ }
+
+ state[0] += a; state[1] += b; state[2] += c; state[3] += d;
diff --git a/queue-2.6.32/crypto-sha512-use-binary-and-instead-of-modulus.patch b/queue-2.6.32/crypto-sha512-use-binary-and-instead-of-modulus.patch
new file mode 100644
index 0000000..2dba02d
--- /dev/null
+++ b/queue-2.6.32/crypto-sha512-use-binary-and-instead-of-modulus.patch
@@ -0,0 +1,40 @@
+From 58d7d18b5268febb8b1391c6dffc8e2aaa751fcd Mon Sep 17 00:00:00 2001
+From: Herbert Xu <herbert@gondor.apana.org.au>
+Date: Thu, 26 Jan 2012 15:03:16 +1100
+Subject: crypto: sha512 - Use binary and instead of modulus
+
+From: Herbert Xu <herbert@gondor.apana.org.au>
+
+commit 58d7d18b5268febb8b1391c6dffc8e2aaa751fcd upstream.
+
+The previous patch used the modulus operator over a power of 2
+unnecessarily which may produce suboptimal binary code. This
+patch changes changes them to binary ands instead.
+
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ crypto/sha512_generic.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/crypto/sha512_generic.c
++++ b/crypto/sha512_generic.c
+@@ -78,7 +78,7 @@ static inline void LOAD_OP(int I, u64 *W
+
+ static inline void BLEND_OP(int I, u64 *W)
+ {
+- W[I % 16] += s1(W[(I-2) % 16]) + W[(I-7) % 16] + s0(W[(I-15) % 16]);
++ W[I & 15] += s1(W[(I-2) & 15]) + W[(I-7) & 15] + s0(W[(I-15) & 15]);
+ }
+
+ static void
+@@ -105,7 +105,7 @@ sha512_transform(u64 *state, const u8 *i
+
+ #define SHA512_16_79(i, a, b, c, d, e, f, g, h) \
+ BLEND_OP(i, W); \
+- t1 = h + e1(e) + Ch(e, f, g) + sha512_K[i] + W[(i)%16]; \
++ t1 = h + e1(e) + Ch(e, f, g) + sha512_K[i] + W[(i)&15]; \
+ t2 = e0(a) + Maj(a, b, c); \
+ d += t1; \
+ h = t1 + t2
diff --git a/queue-2.6.32/series b/queue-2.6.32/series
index cc1d630..45c3bf9 100644
--- a/queue-2.6.32/series
+++ b/queue-2.6.32/series
@@ -6,3 +6,5 @@ mac80211-timeout-a-single-frame-in-the-rx-reorder-buffer.patch
kernel.h-fix-wrong-usage-of-__ratelimit.patch
printk_ratelimited-fix-uninitialized-spinlock.patch
hwmon-f75375s-fix-automatic-pwm-mode-setting-for-f75373-f75375.patch
+crypto-sha512-use-binary-and-instead-of-modulus.patch
+crypto-sha512-avoid-stack-bloat-on-i386.patch