diff options
author | Jussi Kivilinna <jussi.kivilinna@mbnet.fi> | 2013-01-19 06:38:50 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2013-01-19 18:16:47 -0500 |
commit | 3f299743839ae0a4c183035c36aa1e2807e53fe4 (patch) | |
tree | ce1c7b55097c9f0695fe92d3be5f79d5e0c4e44a /arch/x86/crypto | |
parent | 66e5bd0063f4efd99c9c7e3bc23344dfd88bf98d (diff) |
crypto: x86/aes - assembler clean-ups: use ENTRY/ENDPROC, localize jump targets
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'arch/x86/crypto')
-rw-r--r-- | arch/x86/crypto/aes-i586-asm_32.S | 15 | ||||
-rw-r--r-- | arch/x86/crypto/aes-x86_64-asm_64.S | 30 |
2 files changed, 20 insertions, 25 deletions
diff --git a/arch/x86/crypto/aes-i586-asm_32.S b/arch/x86/crypto/aes-i586-asm_32.S index b949ec2f9af4..2849dbc59e11 100644 --- a/arch/x86/crypto/aes-i586-asm_32.S +++ b/arch/x86/crypto/aes-i586-asm_32.S | |||
@@ -36,6 +36,7 @@ | |||
36 | .file "aes-i586-asm.S" | 36 | .file "aes-i586-asm.S" |
37 | .text | 37 | .text |
38 | 38 | ||
39 | #include <linux/linkage.h> | ||
39 | #include <asm/asm-offsets.h> | 40 | #include <asm/asm-offsets.h> |
40 | 41 | ||
41 | #define tlen 1024 // length of each of 4 'xor' arrays (256 32-bit words) | 42 | #define tlen 1024 // length of each of 4 'xor' arrays (256 32-bit words) |
@@ -219,14 +220,10 @@ | |||
219 | // AES (Rijndael) Encryption Subroutine | 220 | // AES (Rijndael) Encryption Subroutine |
220 | /* void aes_enc_blk(struct crypto_aes_ctx *ctx, u8 *out_blk, const u8 *in_blk) */ | 221 | /* void aes_enc_blk(struct crypto_aes_ctx *ctx, u8 *out_blk, const u8 *in_blk) */ |
221 | 222 | ||
222 | .global aes_enc_blk | ||
223 | |||
224 | .extern crypto_ft_tab | 223 | .extern crypto_ft_tab |
225 | .extern crypto_fl_tab | 224 | .extern crypto_fl_tab |
226 | 225 | ||
227 | .align 4 | 226 | ENTRY(aes_enc_blk) |
228 | |||
229 | aes_enc_blk: | ||
230 | push %ebp | 227 | push %ebp |
231 | mov ctx(%esp),%ebp | 228 | mov ctx(%esp),%ebp |
232 | 229 | ||
@@ -290,18 +287,15 @@ aes_enc_blk: | |||
290 | mov %r0,(%ebp) | 287 | mov %r0,(%ebp) |
291 | pop %ebp | 288 | pop %ebp |
292 | ret | 289 | ret |
290 | ENDPROC(aes_enc_blk) | ||
293 | 291 | ||
294 | // AES (Rijndael) Decryption Subroutine | 292 | // AES (Rijndael) Decryption Subroutine |
295 | /* void aes_dec_blk(struct crypto_aes_ctx *ctx, u8 *out_blk, const u8 *in_blk) */ | 293 | /* void aes_dec_blk(struct crypto_aes_ctx *ctx, u8 *out_blk, const u8 *in_blk) */ |
296 | 294 | ||
297 | .global aes_dec_blk | ||
298 | |||
299 | .extern crypto_it_tab | 295 | .extern crypto_it_tab |
300 | .extern crypto_il_tab | 296 | .extern crypto_il_tab |
301 | 297 | ||
302 | .align 4 | 298 | ENTRY(aes_dec_blk) |
303 | |||
304 | aes_dec_blk: | ||
305 | push %ebp | 299 | push %ebp |
306 | mov ctx(%esp),%ebp | 300 | mov ctx(%esp),%ebp |
307 | 301 | ||
@@ -365,3 +359,4 @@ aes_dec_blk: | |||
365 | mov %r0,(%ebp) | 359 | mov %r0,(%ebp) |
366 | pop %ebp | 360 | pop %ebp |
367 | ret | 361 | ret |
362 | ENDPROC(aes_dec_blk) | ||
diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S index 5b577d5a059b..910565547163 100644 --- a/arch/x86/crypto/aes-x86_64-asm_64.S +++ b/arch/x86/crypto/aes-x86_64-asm_64.S | |||
@@ -15,6 +15,7 @@ | |||
15 | 15 | ||
16 | .text | 16 | .text |
17 | 17 | ||
18 | #include <linux/linkage.h> | ||
18 | #include <asm/asm-offsets.h> | 19 | #include <asm/asm-offsets.h> |
19 | 20 | ||
20 | #define R1 %rax | 21 | #define R1 %rax |
@@ -49,10 +50,8 @@ | |||
49 | #define R11 %r11 | 50 | #define R11 %r11 |
50 | 51 | ||
51 | #define prologue(FUNC,KEY,B128,B192,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11) \ | 52 | #define prologue(FUNC,KEY,B128,B192,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11) \ |
52 | .global FUNC; \ | 53 | ENTRY(FUNC); \ |
53 | .type FUNC,@function; \ | 54 | movq r1,r2; \ |
54 | .align 8; \ | ||
55 | FUNC: movq r1,r2; \ | ||
56 | movq r3,r4; \ | 55 | movq r3,r4; \ |
57 | leaq KEY+48(r8),r9; \ | 56 | leaq KEY+48(r8),r9; \ |
58 | movq r10,r11; \ | 57 | movq r10,r11; \ |
@@ -71,14 +70,15 @@ FUNC: movq r1,r2; \ | |||
71 | je B192; \ | 70 | je B192; \ |
72 | leaq 32(r9),r9; | 71 | leaq 32(r9),r9; |
73 | 72 | ||
74 | #define epilogue(r1,r2,r3,r4,r5,r6,r7,r8,r9) \ | 73 | #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \ |
75 | movq r1,r2; \ | 74 | movq r1,r2; \ |
76 | movq r3,r4; \ | 75 | movq r3,r4; \ |
77 | movl r5 ## E,(r9); \ | 76 | movl r5 ## E,(r9); \ |
78 | movl r6 ## E,4(r9); \ | 77 | movl r6 ## E,4(r9); \ |
79 | movl r7 ## E,8(r9); \ | 78 | movl r7 ## E,8(r9); \ |
80 | movl r8 ## E,12(r9); \ | 79 | movl r8 ## E,12(r9); \ |
81 | ret; | 80 | ret; \ |
81 | ENDPROC(FUNC); | ||
82 | 82 | ||
83 | #define round(TAB,OFFSET,r1,r2,r3,r4,r5,r6,r7,r8,ra,rb,rc,rd) \ | 83 | #define round(TAB,OFFSET,r1,r2,r3,r4,r5,r6,r7,r8,ra,rb,rc,rd) \ |
84 | movzbl r2 ## H,r5 ## E; \ | 84 | movzbl r2 ## H,r5 ## E; \ |
@@ -133,7 +133,7 @@ FUNC: movq r1,r2; \ | |||
133 | #define entry(FUNC,KEY,B128,B192) \ | 133 | #define entry(FUNC,KEY,B128,B192) \ |
134 | prologue(FUNC,KEY,B128,B192,R2,R8,R7,R9,R1,R3,R4,R6,R10,R5,R11) | 134 | prologue(FUNC,KEY,B128,B192,R2,R8,R7,R9,R1,R3,R4,R6,R10,R5,R11) |
135 | 135 | ||
136 | #define return epilogue(R8,R2,R9,R7,R5,R6,R3,R4,R11) | 136 | #define return(FUNC) epilogue(FUNC,R8,R2,R9,R7,R5,R6,R3,R4,R11) |
137 | 137 | ||
138 | #define encrypt_round(TAB,OFFSET) \ | 138 | #define encrypt_round(TAB,OFFSET) \ |
139 | round(TAB,OFFSET,R1,R2,R3,R4,R5,R6,R7,R10,R5,R6,R3,R4) \ | 139 | round(TAB,OFFSET,R1,R2,R3,R4,R5,R6,R7,R10,R5,R6,R3,R4) \ |
@@ -151,12 +151,12 @@ FUNC: movq r1,r2; \ | |||
151 | 151 | ||
152 | /* void aes_enc_blk(stuct crypto_tfm *tfm, u8 *out, const u8 *in) */ | 152 | /* void aes_enc_blk(stuct crypto_tfm *tfm, u8 *out, const u8 *in) */ |
153 | 153 | ||
154 | entry(aes_enc_blk,0,enc128,enc192) | 154 | entry(aes_enc_blk,0,.Le128,.Le192) |
155 | encrypt_round(crypto_ft_tab,-96) | 155 | encrypt_round(crypto_ft_tab,-96) |
156 | encrypt_round(crypto_ft_tab,-80) | 156 | encrypt_round(crypto_ft_tab,-80) |
157 | enc192: encrypt_round(crypto_ft_tab,-64) | 157 | .Le192: encrypt_round(crypto_ft_tab,-64) |
158 | encrypt_round(crypto_ft_tab,-48) | 158 | encrypt_round(crypto_ft_tab,-48) |
159 | enc128: encrypt_round(crypto_ft_tab,-32) | 159 | .Le128: encrypt_round(crypto_ft_tab,-32) |
160 | encrypt_round(crypto_ft_tab,-16) | 160 | encrypt_round(crypto_ft_tab,-16) |
161 | encrypt_round(crypto_ft_tab, 0) | 161 | encrypt_round(crypto_ft_tab, 0) |
162 | encrypt_round(crypto_ft_tab, 16) | 162 | encrypt_round(crypto_ft_tab, 16) |
@@ -166,16 +166,16 @@ enc128: encrypt_round(crypto_ft_tab,-32) | |||
166 | encrypt_round(crypto_ft_tab, 80) | 166 | encrypt_round(crypto_ft_tab, 80) |
167 | encrypt_round(crypto_ft_tab, 96) | 167 | encrypt_round(crypto_ft_tab, 96) |
168 | encrypt_final(crypto_fl_tab,112) | 168 | encrypt_final(crypto_fl_tab,112) |
169 | return | 169 | return(aes_enc_blk) |
170 | 170 | ||
171 | /* void aes_dec_blk(struct crypto_tfm *tfm, u8 *out, const u8 *in) */ | 171 | /* void aes_dec_blk(struct crypto_tfm *tfm, u8 *out, const u8 *in) */ |
172 | 172 | ||
173 | entry(aes_dec_blk,240,dec128,dec192) | 173 | entry(aes_dec_blk,240,.Ld128,.Ld192) |
174 | decrypt_round(crypto_it_tab,-96) | 174 | decrypt_round(crypto_it_tab,-96) |
175 | decrypt_round(crypto_it_tab,-80) | 175 | decrypt_round(crypto_it_tab,-80) |
176 | dec192: decrypt_round(crypto_it_tab,-64) | 176 | .Ld192: decrypt_round(crypto_it_tab,-64) |
177 | decrypt_round(crypto_it_tab,-48) | 177 | decrypt_round(crypto_it_tab,-48) |
178 | dec128: decrypt_round(crypto_it_tab,-32) | 178 | .Ld128: decrypt_round(crypto_it_tab,-32) |
179 | decrypt_round(crypto_it_tab,-16) | 179 | decrypt_round(crypto_it_tab,-16) |
180 | decrypt_round(crypto_it_tab, 0) | 180 | decrypt_round(crypto_it_tab, 0) |
181 | decrypt_round(crypto_it_tab, 16) | 181 | decrypt_round(crypto_it_tab, 16) |
@@ -185,4 +185,4 @@ dec128: decrypt_round(crypto_it_tab,-32) | |||
185 | decrypt_round(crypto_it_tab, 80) | 185 | decrypt_round(crypto_it_tab, 80) |
186 | decrypt_round(crypto_it_tab, 96) | 186 | decrypt_round(crypto_it_tab, 96) |
187 | decrypt_final(crypto_il_tab,112) | 187 | decrypt_final(crypto_il_tab,112) |
188 | return | 188 | return(aes_dec_blk) |