aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/crypto
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-08-31 15:11:51 -0400
committerDavid S. Miller <davem@davemloft.net>2012-08-31 15:11:51 -0400
commit7cff82f5f42a938a1b633e121a41d29c81de18bb (patch)
tree80b07a1886e7f4b8caf547e9963245ca4ce75f1b /arch/sparc/crypto
parent4e71bb49f256e4efc94a9fdaaa430d906cd88e6b (diff)
sparc64: Avoid code duplication in crypto assembler.
Put the opcode macros in a common header Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/crypto')
-rw-r--r--arch/sparc/crypto/aes_asm.S56
-rw-r--r--arch/sparc/crypto/camellia_asm.S22
-rw-r--r--arch/sparc/crypto/crc32c_asm.S11
-rw-r--r--arch/sparc/crypto/des_asm.S24
-rw-r--r--arch/sparc/crypto/md5_asm.S8
-rw-r--r--arch/sparc/crypto/opcodes.h97
-rw-r--r--arch/sparc/crypto/sha1_asm.S8
-rw-r--r--arch/sparc/crypto/sha256_asm.S8
-rw-r--r--arch/sparc/crypto/sha512_asm.S8
9 files changed, 117 insertions, 125 deletions
diff --git a/arch/sparc/crypto/aes_asm.S b/arch/sparc/crypto/aes_asm.S
index 0fadad0c60ad..20860885f068 100644
--- a/arch/sparc/crypto/aes_asm.S
+++ b/arch/sparc/crypto/aes_asm.S
@@ -1,61 +1,7 @@
1#include <linux/linkage.h> 1#include <linux/linkage.h>
2#include <asm/visasm.h> 2#include <asm/visasm.h>
3 3
4#define F3F(x,y,z) (((x)<<30)|((y)<<19)|((z)<<5)) 4#include "opcodes.h"
5
6#define FPD_ENCODE(x) (((x) >> 5) | ((x) & ~(0x20)))
7
8#define RS1(x) (FPD_ENCODE(x) << 14)
9#define RS2(x) (FPD_ENCODE(x) << 0)
10#define RS3(x) (FPD_ENCODE(x) << 9)
11#define RD(x) (FPD_ENCODE(x) << 25)
12#define IMM5(x) ((x) << 9)
13
14#define AES_EROUND01(a,b,c,d) \
15 .word (F3F(2, 0x19, 0)|RS1(a)|RS2(b)|RS3(c)|RD(d));
16#define AES_EROUND23(a,b,c,d) \
17 .word (F3F(2, 0x19, 1)|RS1(a)|RS2(b)|RS3(c)|RD(d));
18#define AES_DROUND01(a,b,c,d) \
19 .word (F3F(2, 0x19, 2)|RS1(a)|RS2(b)|RS3(c)|RD(d));
20#define AES_DROUND23(a,b,c,d) \
21 .word (F3F(2, 0x19, 3)|RS1(a)|RS2(b)|RS3(c)|RD(d));
22#define AES_EROUND01_L(a,b,c,d) \
23 .word (F3F(2, 0x19, 4)|RS1(a)|RS2(b)|RS3(c)|RD(d));
24#define AES_EROUND23_L(a,b,c,d) \
25 .word (F3F(2, 0x19, 5)|RS1(a)|RS2(b)|RS3(c)|RD(d));
26#define AES_DROUND01_L(a,b,c,d) \
27 .word (F3F(2, 0x19, 6)|RS1(a)|RS2(b)|RS3(c)|RD(d));
28#define AES_DROUND23_L(a,b,c,d) \
29 .word (F3F(2, 0x19, 7)|RS1(a)|RS2(b)|RS3(c)|RD(d));
30#define AES_KEXPAND1(a,b,c,d) \
31 .word (F3F(2, 0x19, 8)|RS1(a)|RS2(b)|IMM5(c)|RD(d));
32#define AES_KEXPAND0(a,b,c) \
33 .word (F3F(2, 0x36, 0x130)|RS1(a)|RS2(b)|RD(c));
34#define AES_KEXPAND2(a,b,c) \
35 .word (F3F(2, 0x36, 0x131)|RS1(a)|RS2(b)|RD(c));
36
37#define MOVXTOD_G3_F4 \
38 .word 0x89b02303;
39#define MOVXTOD_G7_F6 \
40 .word 0x8db02307;
41#define MOVXTOD_G3_F0 \
42 .word 0x81b02303;
43#define MOVXTOD_G7_F2 \
44 .word 0x85b02307;
45#define MOVXTOD_O0_F0 \
46 .word 0x81b02308;
47#define MOVXTOD_O5_F0 \
48 .word 0x81b0230d;
49#define MOVXTOD_O5_F2 \
50 .word 0x85b0230d;
51#define MOVXTOD_O5_F4 \
52 .word 0x89b0230d;
53#define MOVXTOD_O5_F6 \
54 .word 0x8db0230d;
55#define MOVXTOD_G3_F60 \
56 .word 0xbbb02303;
57#define MOVXTOD_G7_F62 \
58 .word 0xbfb02307;
59 5
60#define ENCRYPT_TWO_ROUNDS(KEY_BASE, I0, I1, T0, T1) \ 6#define ENCRYPT_TWO_ROUNDS(KEY_BASE, I0, I1, T0, T1) \
61 AES_EROUND01(KEY_BASE + 0, I0, I1, T0) \ 7 AES_EROUND01(KEY_BASE + 0, I0, I1, T0) \
diff --git a/arch/sparc/crypto/camellia_asm.S b/arch/sparc/crypto/camellia_asm.S
index b0ddb5bcfe5f..d3ef9c7bbd02 100644
--- a/arch/sparc/crypto/camellia_asm.S
+++ b/arch/sparc/crypto/camellia_asm.S
@@ -1,27 +1,7 @@
1#include <linux/linkage.h> 1#include <linux/linkage.h>
2#include <asm/visasm.h> 2#include <asm/visasm.h>
3 3
4#define F3F(x,y,z) (((x)<<30)|((y)<<19)|((z)<<5)) 4#include "opcodes.h"
5
6#define FPD_ENCODE(x) (((x) >> 5) | ((x) & ~(0x20)))
7
8#define RS1(x) (FPD_ENCODE(x) << 14)
9#define RS2(x) (FPD_ENCODE(x) << 0)
10#define RS3(x) (FPD_ENCODE(x) << 9)
11#define RD(x) (FPD_ENCODE(x) << 25)
12#define IMM5(x) ((x) << 0)
13
14#define CAMELLIA_F(a,b,c,d) \
15 .word (F3F(2, 0x19, 0x00c)|RS1(a)|RS2(b)|RS3(c)|RD(d));
16#define CAMELLIA_FL(a,b,c) \
17 .word (F3F(2, 0x36, 0x13c)|RS1(a)|RS2(b)|RD(c));
18#define CAMELLIA_FLI(a,b,c) \
19 .word (F3F(2, 0x36, 0x13d)|RS1(a)|RS2(b)|RD(c));
20
21#define MOVDTOX_F0_O4 \
22 .word 0x99b02200
23#define MOVDTOX_F2_O5 \
24 .word 0x9bb02202
25 5
26#define CAMELLIA_6ROUNDS(KEY_BASE, I0, I1) \ 6#define CAMELLIA_6ROUNDS(KEY_BASE, I0, I1) \
27 CAMELLIA_F(KEY_BASE + 0, I1, I0, I1) \ 7 CAMELLIA_F(KEY_BASE + 0, I1, I0, I1) \
diff --git a/arch/sparc/crypto/crc32c_asm.S b/arch/sparc/crypto/crc32c_asm.S
index cb479ec72433..2b1976e765b5 100644
--- a/arch/sparc/crypto/crc32c_asm.S
+++ b/arch/sparc/crypto/crc32c_asm.S
@@ -2,16 +2,7 @@
2#include <asm/visasm.h> 2#include <asm/visasm.h>
3#include <asm/asi.h> 3#include <asm/asi.h>
4 4
5#define F3F(x,y,z) (((x)<<30)|((y)<<19)|((z)<<5)) 5#include "opcodes.h"
6
7#define FPD_ENCODE(x) (((x) >> 5) | ((x) & ~(0x20)))
8
9#define RS1(x) (FPD_ENCODE(x) << 14)
10#define RS2(x) (FPD_ENCODE(x) << 0)
11#define RD(x) (FPD_ENCODE(x) << 25)
12
13#define CRC32C(a,b,c) \
14 .word (F3F(2,0x36,0x147)|RS1(a)|RS2(b)|RD(c));
15 6
16ENTRY(crc32c_sparc64) 7ENTRY(crc32c_sparc64)
17 /* %o0=crc32p, %o1=data_ptr, %o2=len */ 8 /* %o0=crc32p, %o1=data_ptr, %o2=len */
diff --git a/arch/sparc/crypto/des_asm.S b/arch/sparc/crypto/des_asm.S
index 589481e53d07..a7da935796e1 100644
--- a/arch/sparc/crypto/des_asm.S
+++ b/arch/sparc/crypto/des_asm.S
@@ -1,29 +1,7 @@
1#include <linux/linkage.h> 1#include <linux/linkage.h>
2#include <asm/visasm.h> 2#include <asm/visasm.h>
3 3
4#define F3F(x,y,z) (((x)<<30)|((y)<<19)|((z)<<5)) 4#include "opcodes.h"
5
6#define FPD_ENCODE(x) (((x) >> 5) | ((x) & ~(0x20)))
7
8#define RS1(x) (FPD_ENCODE(x) << 14)
9#define RS2(x) (FPD_ENCODE(x) << 0)
10#define RS3(x) (FPD_ENCODE(x) << 9)
11#define RD(x) (FPD_ENCODE(x) << 25)
12#define IMM5(x) ((x) << 0)
13
14#define DES_IP(a,b) \
15 .word (F3F(2, 0x36, 0x134)|RS1(a)|RD(b));
16#define DES_IIP(a,b) \
17 .word (F3F(2, 0x36, 0x135)|RS1(a)|RD(b));
18#define DES_KEXPAND(a,b,c) \
19 .word (F3F(2, 0x36, 0x136)|RS1(a)|IMM5(b)|RD(c));
20#define DES_ROUND(a,b,c,d) \
21 .word (F3F(2, 0x19, 0x009)|RS1(a)|RS2(b)|RS3(c)|RD(d));
22
23#define MOVXTOD_G1_F60 \
24 .word 0xbbb02301
25#define MOVXTOD_G1_F62 \
26 .word 0xbfb02301
27 5
28 .align 32 6 .align 32
29ENTRY(des_sparc64_key_expand) 7ENTRY(des_sparc64_key_expand)
diff --git a/arch/sparc/crypto/md5_asm.S b/arch/sparc/crypto/md5_asm.S
index ff90903180eb..3150404e602e 100644
--- a/arch/sparc/crypto/md5_asm.S
+++ b/arch/sparc/crypto/md5_asm.S
@@ -1,6 +1,8 @@
1#include <linux/linkage.h> 1#include <linux/linkage.h>
2#include <asm/visasm.h> 2#include <asm/visasm.h>
3 3
4#include "opcodes.h"
5
4ENTRY(md5_sparc64_transform) 6ENTRY(md5_sparc64_transform)
5 /* %o0 = digest, %o1 = data, %o2 = rounds */ 7 /* %o0 = digest, %o1 = data, %o2 = rounds */
6 VISEntryHalf 8 VISEntryHalf
@@ -21,8 +23,7 @@ ENTRY(md5_sparc64_transform)
21 ldd [%o1 + 0x30], %f20 23 ldd [%o1 + 0x30], %f20
22 ldd [%o1 + 0x38], %f22 24 ldd [%o1 + 0x38], %f22
23 25
24 /* md5 */ 26 MD5
25 .word 0x81b02800
26 27
27 subcc %o2, 1, %o2 28 subcc %o2, 1, %o2
28 bne,pt %xcc, 1b 29 bne,pt %xcc, 1b
@@ -58,8 +59,7 @@ ENTRY(md5_sparc64_transform)
58 faligndata %f22, %f24, %f20 59 faligndata %f22, %f24, %f20
59 faligndata %f24, %f26, %f22 60 faligndata %f24, %f26, %f22
60 61
61 /* md5 */ 62 MD5
62 .word 0x81b02800
63 63
64 subcc %o2, 1, %o2 64 subcc %o2, 1, %o2
65 fsrc2 %f26, %f10 65 fsrc2 %f26, %f10
diff --git a/arch/sparc/crypto/opcodes.h b/arch/sparc/crypto/opcodes.h
new file mode 100644
index 000000000000..b6c4a1556354
--- /dev/null
+++ b/arch/sparc/crypto/opcodes.h
@@ -0,0 +1,97 @@
1#ifndef _OPCODES_H
2#define _OPCODES_H
3
4#define F3F(x,y,z) (((x)<<30)|((y)<<19)|((z)<<5))
5
6#define FPD_ENCODE(x) (((x) >> 5) | ((x) & ~(0x20)))
7
8#define RS1(x) (FPD_ENCODE(x) << 14)
9#define RS2(x) (FPD_ENCODE(x) << 0)
10#define RS3(x) (FPD_ENCODE(x) << 9)
11#define RD(x) (FPD_ENCODE(x) << 25)
12#define IMM5_0(x) ((x) << 0)
13#define IMM5_9(x) ((x) << 9)
14
15#define CRC32C(a,b,c) \
16 .word (F3F(2,0x36,0x147)|RS1(a)|RS2(b)|RD(c));
17
18#define MD5 \
19 .word 0x81b02800;
20#define SHA1 \
21 .word 0x81b02820;
22#define SHA256 \
23 .word 0x81b02840;
24#define SHA512 \
25 .word 0x81b02860;
26
27#define AES_EROUND01(a,b,c,d) \
28 .word (F3F(2, 0x19, 0)|RS1(a)|RS2(b)|RS3(c)|RD(d));
29#define AES_EROUND23(a,b,c,d) \
30 .word (F3F(2, 0x19, 1)|RS1(a)|RS2(b)|RS3(c)|RD(d));
31#define AES_DROUND01(a,b,c,d) \
32 .word (F3F(2, 0x19, 2)|RS1(a)|RS2(b)|RS3(c)|RD(d));
33#define AES_DROUND23(a,b,c,d) \
34 .word (F3F(2, 0x19, 3)|RS1(a)|RS2(b)|RS3(c)|RD(d));
35#define AES_EROUND01_L(a,b,c,d) \
36 .word (F3F(2, 0x19, 4)|RS1(a)|RS2(b)|RS3(c)|RD(d));
37#define AES_EROUND23_L(a,b,c,d) \
38 .word (F3F(2, 0x19, 5)|RS1(a)|RS2(b)|RS3(c)|RD(d));
39#define AES_DROUND01_L(a,b,c,d) \
40 .word (F3F(2, 0x19, 6)|RS1(a)|RS2(b)|RS3(c)|RD(d));
41#define AES_DROUND23_L(a,b,c,d) \
42 .word (F3F(2, 0x19, 7)|RS1(a)|RS2(b)|RS3(c)|RD(d));
43#define AES_KEXPAND1(a,b,c,d) \
44 .word (F3F(2, 0x19, 8)|RS1(a)|RS2(b)|IMM5_9(c)|RD(d));
45#define AES_KEXPAND0(a,b,c) \
46 .word (F3F(2, 0x36, 0x130)|RS1(a)|RS2(b)|RD(c));
47#define AES_KEXPAND2(a,b,c) \
48 .word (F3F(2, 0x36, 0x131)|RS1(a)|RS2(b)|RD(c));
49
50#define DES_IP(a,b) \
51 .word (F3F(2, 0x36, 0x134)|RS1(a)|RD(b));
52#define DES_IIP(a,b) \
53 .word (F3F(2, 0x36, 0x135)|RS1(a)|RD(b));
54#define DES_KEXPAND(a,b,c) \
55 .word (F3F(2, 0x36, 0x136)|RS1(a)|IMM5_0(b)|RD(c));
56#define DES_ROUND(a,b,c,d) \
57 .word (F3F(2, 0x19, 0x009)|RS1(a)|RS2(b)|RS3(c)|RD(d));
58
59#define CAMELLIA_F(a,b,c,d) \
60 .word (F3F(2, 0x19, 0x00c)|RS1(a)|RS2(b)|RS3(c)|RD(d));
61#define CAMELLIA_FL(a,b,c) \
62 .word (F3F(2, 0x36, 0x13c)|RS1(a)|RS2(b)|RD(c));
63#define CAMELLIA_FLI(a,b,c) \
64 .word (F3F(2, 0x36, 0x13d)|RS1(a)|RS2(b)|RD(c));
65
66#define MOVDTOX_F0_O4 \
67 .word 0x99b02200
68#define MOVDTOX_F2_O5 \
69 .word 0x9bb02202
70#define MOVXTOD_G1_F60 \
71 .word 0xbbb02301
72#define MOVXTOD_G1_F62 \
73 .word 0xbfb02301
74#define MOVXTOD_G3_F4 \
75 .word 0x89b02303;
76#define MOVXTOD_G7_F6 \
77 .word 0x8db02307;
78#define MOVXTOD_G3_F0 \
79 .word 0x81b02303;
80#define MOVXTOD_G7_F2 \
81 .word 0x85b02307;
82#define MOVXTOD_O0_F0 \
83 .word 0x81b02308;
84#define MOVXTOD_O5_F0 \
85 .word 0x81b0230d;
86#define MOVXTOD_O5_F2 \
87 .word 0x85b0230d;
88#define MOVXTOD_O5_F4 \
89 .word 0x89b0230d;
90#define MOVXTOD_O5_F6 \
91 .word 0x8db0230d;
92#define MOVXTOD_G3_F60 \
93 .word 0xbbb02303;
94#define MOVXTOD_G7_F62 \
95 .word 0xbfb02307;
96
97#endif /* _OPCODES_H */
diff --git a/arch/sparc/crypto/sha1_asm.S b/arch/sparc/crypto/sha1_asm.S
index 3cd218ac631b..219d10c5ae0e 100644
--- a/arch/sparc/crypto/sha1_asm.S
+++ b/arch/sparc/crypto/sha1_asm.S
@@ -1,6 +1,8 @@
1#include <linux/linkage.h> 1#include <linux/linkage.h>
2#include <asm/visasm.h> 2#include <asm/visasm.h>
3 3
4#include "opcodes.h"
5
4ENTRY(sha1_sparc64_transform) 6ENTRY(sha1_sparc64_transform)
5 /* %o0 = digest, %o1 = data, %o2 = rounds */ 7 /* %o0 = digest, %o1 = data, %o2 = rounds */
6 VISEntryHalf 8 VISEntryHalf
@@ -22,8 +24,7 @@ ENTRY(sha1_sparc64_transform)
22 ldd [%o1 + 0x30], %f20 24 ldd [%o1 + 0x30], %f20
23 ldd [%o1 + 0x38], %f22 25 ldd [%o1 + 0x38], %f22
24 26
25 /* sha1 */ 27 SHA1
26 .word 0x81b02820
27 28
28 subcc %o2, 1, %o2 29 subcc %o2, 1, %o2
29 bne,pt %xcc, 1b 30 bne,pt %xcc, 1b
@@ -60,8 +61,7 @@ ENTRY(sha1_sparc64_transform)
60 faligndata %f22, %f24, %f20 61 faligndata %f22, %f24, %f20
61 faligndata %f24, %f26, %f22 62 faligndata %f24, %f26, %f22
62 63
63 /* sha1 */ 64 SHA1
64 .word 0x81b02820
65 65
66 subcc %o2, 1, %o2 66 subcc %o2, 1, %o2
67 fsrc2 %f26, %f10 67 fsrc2 %f26, %f10
diff --git a/arch/sparc/crypto/sha256_asm.S b/arch/sparc/crypto/sha256_asm.S
index 9da84f5b61f5..b5f3d5826eb4 100644
--- a/arch/sparc/crypto/sha256_asm.S
+++ b/arch/sparc/crypto/sha256_asm.S
@@ -1,6 +1,8 @@
1#include <linux/linkage.h> 1#include <linux/linkage.h>
2#include <asm/visasm.h> 2#include <asm/visasm.h>
3 3
4#include "opcodes.h"
5
4ENTRY(sha256_sparc64_transform) 6ENTRY(sha256_sparc64_transform)
5 /* %o0 = digest, %o1 = data, %o2 = rounds */ 7 /* %o0 = digest, %o1 = data, %o2 = rounds */
6 VISEntryHalf 8 VISEntryHalf
@@ -25,8 +27,7 @@ ENTRY(sha256_sparc64_transform)
25 ldd [%o1 + 0x30], %f20 27 ldd [%o1 + 0x30], %f20
26 ldd [%o1 + 0x38], %f22 28 ldd [%o1 + 0x38], %f22
27 29
28 /* sha256 */ 30 SHA256
29 .word 0x81b02840
30 31
31 subcc %o2, 1, %o2 32 subcc %o2, 1, %o2
32 bne,pt %xcc, 1b 33 bne,pt %xcc, 1b
@@ -66,8 +67,7 @@ ENTRY(sha256_sparc64_transform)
66 faligndata %f22, %f24, %f20 67 faligndata %f22, %f24, %f20
67 faligndata %f24, %f26, %f22 68 faligndata %f24, %f26, %f22
68 69
69 /* sha256 */ 70 SHA256
70 .word 0x81b02840
71 71
72 subcc %o2, 1, %o2 72 subcc %o2, 1, %o2
73 fsrc2 %f26, %f10 73 fsrc2 %f26, %f10
diff --git a/arch/sparc/crypto/sha512_asm.S b/arch/sparc/crypto/sha512_asm.S
index 650ba5742f0e..54bfba713c0e 100644
--- a/arch/sparc/crypto/sha512_asm.S
+++ b/arch/sparc/crypto/sha512_asm.S
@@ -1,6 +1,8 @@
1#include <linux/linkage.h> 1#include <linux/linkage.h>
2#include <asm/visasm.h> 2#include <asm/visasm.h>
3 3
4#include "opcodes.h"
5
4ENTRY(sha512_sparc64_transform) 6ENTRY(sha512_sparc64_transform)
5 /* %o0 = digest, %o1 = data, %o2 = rounds */ 7 /* %o0 = digest, %o1 = data, %o2 = rounds */
6 VISEntry 8 VISEntry
@@ -33,8 +35,7 @@ ENTRY(sha512_sparc64_transform)
33 ldd [%o1 + 0x70], %f44 35 ldd [%o1 + 0x70], %f44
34 ldd [%o1 + 0x78], %f46 36 ldd [%o1 + 0x78], %f46
35 37
36 /* sha512 */ 38 SHA512
37 .word 0x81b02860
38 39
39 subcc %o2, 1, %o2 40 subcc %o2, 1, %o2
40 bne,pt %xcc, 1b 41 bne,pt %xcc, 1b
@@ -90,8 +91,7 @@ ENTRY(sha512_sparc64_transform)
90 faligndata %f46, %f48, %f44 91 faligndata %f46, %f48, %f44
91 faligndata %f48, %f50, %f46 92 faligndata %f48, %f50, %f46
92 93
93 /* sha512 */ 94 SHA512
94 .word 0x81b02860
95 95
96 subcc %o2, 1, %o2 96 subcc %o2, 1, %o2
97 fsrc2 %f50, %f18 97 fsrc2 %f50, %f18