aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/crypto
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-09-02 02:05:43 -0400
committerDavid S. Miller <davem@davemloft.net>2012-09-02 02:05:43 -0400
commit699871bc943be418be13208526bc613d68017fab (patch)
treed65e584a1b7d71601a8acfae81262237c402b5e1 /arch/sparc/crypto
parent7cff82f5f42a938a1b633e121a41d29c81de18bb (diff)
sparc64: Fix bugs in unrolled 256-bit loops.
Some dm-crypt testing revealed several bugs in the 256-bit unrolled loops. The DECRYPT_256_2() macro had two errors: 1) Missing reload of KEY registers %f60 and %f62 2) Missing "\" in penultimate line of definition. In aes_sparc64_ecb_decrypt_256, we were storing the second half of the encryption result from the wrong source registers. In aes_sparc64_ctr_crypt_256 we have to be careful when we fall out of the 32-byte-at-a-time loop and handle a trailing 16-byte chunk. In that case we've clobbered the final key holding registers and have to restore them before executing the ENCRYPT_256() macro. Inside of the 32-byte-at-a-time loop things are OK, because we do this key register restoring during the first few rounds of the ENCRYPT_256_2() macro. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/crypto')
-rw-r--r--arch/sparc/crypto/aes_asm.S12
1 files changed, 9 insertions, 3 deletions
diff --git a/arch/sparc/crypto/aes_asm.S b/arch/sparc/crypto/aes_asm.S
index 20860885f068..23f6cbb910d3 100644
--- a/arch/sparc/crypto/aes_asm.S
+++ b/arch/sparc/crypto/aes_asm.S
@@ -188,6 +188,8 @@
188 ldd [%o0 + 0x18], %f56; \ 188 ldd [%o0 + 0x18], %f56; \
189 ldd [%o0 + 0x10], %f58; \ 189 ldd [%o0 + 0x10], %f58; \
190 DECRYPT_256_TWO_ROUNDS_2(KEY_BASE + 8, I0, I1, I2, I3, KEY_BASE + 0) \ 190 DECRYPT_256_TWO_ROUNDS_2(KEY_BASE + 8, I0, I1, I2, I3, KEY_BASE + 0) \
191 ldd [%o0 + 0x08], %f60; \
192 ldd [%o0 + 0x00], %f62; \
191 DECRYPT_256_TWO_ROUNDS_2(KEY_BASE + 16, I0, I1, I2, I3, KEY_BASE + 0) \ 193 DECRYPT_256_TWO_ROUNDS_2(KEY_BASE + 16, I0, I1, I2, I3, KEY_BASE + 0) \
192 DECRYPT_256_TWO_ROUNDS_2(KEY_BASE + 24, I0, I1, I2, I3, KEY_BASE + 0) \ 194 DECRYPT_256_TWO_ROUNDS_2(KEY_BASE + 24, I0, I1, I2, I3, KEY_BASE + 0) \
193 DECRYPT_256_TWO_ROUNDS_2(KEY_BASE + 32, I0, I1, I2, I3, KEY_BASE + 0) \ 195 DECRYPT_256_TWO_ROUNDS_2(KEY_BASE + 32, I0, I1, I2, I3, KEY_BASE + 0) \
@@ -201,7 +203,7 @@
201 ldd [%o0 + 0xd8], %f8; \ 203 ldd [%o0 + 0xd8], %f8; \
202 ldd [%o0 + 0xd0], %f10; \ 204 ldd [%o0 + 0xd0], %f10; \
203 AES_DROUND23_L(KEY_BASE + 52, KEY_BASE + 4, KEY_BASE + 6, I3) \ 205 AES_DROUND23_L(KEY_BASE + 52, KEY_BASE + 4, KEY_BASE + 6, I3) \
204 AES_DROUND01_L(KEY_BASE + 54, KEY_BASE + 4, KEY_BASE + 6, I2) 206 AES_DROUND01_L(KEY_BASE + 54, KEY_BASE + 4, KEY_BASE + 6, I2) \
205 ldd [%o0 + 0xc8], %f12; \ 207 ldd [%o0 + 0xc8], %f12; \
206 ldd [%o0 + 0xc0], %f14; 208 ldd [%o0 + 0xc0], %f14;
207 209
@@ -1144,8 +1146,8 @@ ENTRY(aes_sparc64_ecb_decrypt_256)
1144 DECRYPT_256_2(8, 4, 6, 0, 2) 1146 DECRYPT_256_2(8, 4, 6, 0, 2)
1145 std %f4, [%o2 + 0x00] 1147 std %f4, [%o2 + 0x00]
1146 std %f6, [%o2 + 0x08] 1148 std %f6, [%o2 + 0x08]
1147 std %f60, [%o2 + 0x10] 1149 std %f0, [%o2 + 0x10]
1148 std %f62, [%o2 + 0x18] 1150 std %f2, [%o2 + 0x18]
1149 sub %o3, 0x20, %o3 1151 sub %o3, 0x20, %o3
1150 add %o1, 0x20, %o1 1152 add %o1, 0x20, %o1
1151 brgz,pt %o3, 1b 1153 brgz,pt %o3, 1b
@@ -1509,6 +1511,10 @@ ENTRY(aes_sparc64_ctr_crypt_256)
1509 add %o2, 0x20, %o2 1511 add %o2, 0x20, %o2
1510 brlz,pt %o3, 11f 1512 brlz,pt %o3, 11f
1511 nop 1513 nop
1514 ldd [%o0 + 0xd0], %f56
1515 ldd [%o0 + 0xd8], %f58
1516 ldd [%o0 + 0xe0], %f60
1517 ldd [%o0 + 0xe8], %f62
151210: xor %g1, %g3, %o5 151810: xor %g1, %g3, %o5
1513 MOVXTOD_O5_F0 1519 MOVXTOD_O5_F0
1514 xor %g2, %g7, %o5 1520 xor %g2, %g7, %o5