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>
This commit is contained in:
Jussi Kivilinna 2013-01-19 13:38:50 +02:00 коммит произвёл Herbert Xu
Родитель 66e5bd0063
Коммит 3f29974383
2 изменённых файлов: 20 добавлений и 25 удалений

Просмотреть файл

@ -36,6 +36,7 @@
.file "aes-i586-asm.S" .file "aes-i586-asm.S"
.text .text
#include <linux/linkage.h>
#include <asm/asm-offsets.h> #include <asm/asm-offsets.h>
#define tlen 1024 // length of each of 4 'xor' arrays (256 32-bit words) #define tlen 1024 // length of each of 4 'xor' arrays (256 32-bit words)
@ -219,14 +220,10 @@
// AES (Rijndael) Encryption Subroutine // AES (Rijndael) Encryption Subroutine
/* void aes_enc_blk(struct crypto_aes_ctx *ctx, u8 *out_blk, const u8 *in_blk) */ /* void aes_enc_blk(struct crypto_aes_ctx *ctx, u8 *out_blk, const u8 *in_blk) */
.global aes_enc_blk
.extern crypto_ft_tab .extern crypto_ft_tab
.extern crypto_fl_tab .extern crypto_fl_tab
.align 4 ENTRY(aes_enc_blk)
aes_enc_blk:
push %ebp push %ebp
mov ctx(%esp),%ebp mov ctx(%esp),%ebp
@ -290,18 +287,15 @@ aes_enc_blk:
mov %r0,(%ebp) mov %r0,(%ebp)
pop %ebp pop %ebp
ret ret
ENDPROC(aes_enc_blk)
// AES (Rijndael) Decryption Subroutine // AES (Rijndael) Decryption Subroutine
/* void aes_dec_blk(struct crypto_aes_ctx *ctx, u8 *out_blk, const u8 *in_blk) */ /* void aes_dec_blk(struct crypto_aes_ctx *ctx, u8 *out_blk, const u8 *in_blk) */
.global aes_dec_blk
.extern crypto_it_tab .extern crypto_it_tab
.extern crypto_il_tab .extern crypto_il_tab
.align 4 ENTRY(aes_dec_blk)
aes_dec_blk:
push %ebp push %ebp
mov ctx(%esp),%ebp mov ctx(%esp),%ebp
@ -365,3 +359,4 @@ aes_dec_blk:
mov %r0,(%ebp) mov %r0,(%ebp)
pop %ebp pop %ebp
ret ret
ENDPROC(aes_dec_blk)

Просмотреть файл

@ -15,6 +15,7 @@
.text .text
#include <linux/linkage.h>
#include <asm/asm-offsets.h> #include <asm/asm-offsets.h>
#define R1 %rax #define R1 %rax
@ -49,10 +50,8 @@
#define R11 %r11 #define R11 %r11
#define prologue(FUNC,KEY,B128,B192,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11) \ #define prologue(FUNC,KEY,B128,B192,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11) \
.global FUNC; \ ENTRY(FUNC); \
.type FUNC,@function; \ movq r1,r2; \
.align 8; \
FUNC: movq r1,r2; \
movq r3,r4; \ movq r3,r4; \
leaq KEY+48(r8),r9; \ leaq KEY+48(r8),r9; \
movq r10,r11; \ movq r10,r11; \
@ -71,14 +70,15 @@ FUNC: movq r1,r2; \
je B192; \ je B192; \
leaq 32(r9),r9; leaq 32(r9),r9;
#define epilogue(r1,r2,r3,r4,r5,r6,r7,r8,r9) \ #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
movq r1,r2; \ movq r1,r2; \
movq r3,r4; \ movq r3,r4; \
movl r5 ## E,(r9); \ movl r5 ## E,(r9); \
movl r6 ## E,4(r9); \ movl r6 ## E,4(r9); \
movl r7 ## E,8(r9); \ movl r7 ## E,8(r9); \
movl r8 ## E,12(r9); \ movl r8 ## E,12(r9); \
ret; ret; \
ENDPROC(FUNC);
#define round(TAB,OFFSET,r1,r2,r3,r4,r5,r6,r7,r8,ra,rb,rc,rd) \ #define round(TAB,OFFSET,r1,r2,r3,r4,r5,r6,r7,r8,ra,rb,rc,rd) \
movzbl r2 ## H,r5 ## E; \ movzbl r2 ## H,r5 ## E; \
@ -133,7 +133,7 @@ FUNC: movq r1,r2; \
#define entry(FUNC,KEY,B128,B192) \ #define entry(FUNC,KEY,B128,B192) \
prologue(FUNC,KEY,B128,B192,R2,R8,R7,R9,R1,R3,R4,R6,R10,R5,R11) prologue(FUNC,KEY,B128,B192,R2,R8,R7,R9,R1,R3,R4,R6,R10,R5,R11)
#define return epilogue(R8,R2,R9,R7,R5,R6,R3,R4,R11) #define return(FUNC) epilogue(FUNC,R8,R2,R9,R7,R5,R6,R3,R4,R11)
#define encrypt_round(TAB,OFFSET) \ #define encrypt_round(TAB,OFFSET) \
round(TAB,OFFSET,R1,R2,R3,R4,R5,R6,R7,R10,R5,R6,R3,R4) \ round(TAB,OFFSET,R1,R2,R3,R4,R5,R6,R7,R10,R5,R6,R3,R4) \
@ -151,12 +151,12 @@ FUNC: movq r1,r2; \
/* void aes_enc_blk(stuct crypto_tfm *tfm, u8 *out, const u8 *in) */ /* void aes_enc_blk(stuct crypto_tfm *tfm, u8 *out, const u8 *in) */
entry(aes_enc_blk,0,enc128,enc192) entry(aes_enc_blk,0,.Le128,.Le192)
encrypt_round(crypto_ft_tab,-96) encrypt_round(crypto_ft_tab,-96)
encrypt_round(crypto_ft_tab,-80) encrypt_round(crypto_ft_tab,-80)
enc192: encrypt_round(crypto_ft_tab,-64) .Le192: encrypt_round(crypto_ft_tab,-64)
encrypt_round(crypto_ft_tab,-48) encrypt_round(crypto_ft_tab,-48)
enc128: encrypt_round(crypto_ft_tab,-32) .Le128: encrypt_round(crypto_ft_tab,-32)
encrypt_round(crypto_ft_tab,-16) encrypt_round(crypto_ft_tab,-16)
encrypt_round(crypto_ft_tab, 0) encrypt_round(crypto_ft_tab, 0)
encrypt_round(crypto_ft_tab, 16) encrypt_round(crypto_ft_tab, 16)
@ -166,16 +166,16 @@ enc128: encrypt_round(crypto_ft_tab,-32)
encrypt_round(crypto_ft_tab, 80) encrypt_round(crypto_ft_tab, 80)
encrypt_round(crypto_ft_tab, 96) encrypt_round(crypto_ft_tab, 96)
encrypt_final(crypto_fl_tab,112) encrypt_final(crypto_fl_tab,112)
return return(aes_enc_blk)
/* void aes_dec_blk(struct crypto_tfm *tfm, u8 *out, const u8 *in) */ /* void aes_dec_blk(struct crypto_tfm *tfm, u8 *out, const u8 *in) */
entry(aes_dec_blk,240,dec128,dec192) entry(aes_dec_blk,240,.Ld128,.Ld192)
decrypt_round(crypto_it_tab,-96) decrypt_round(crypto_it_tab,-96)
decrypt_round(crypto_it_tab,-80) decrypt_round(crypto_it_tab,-80)
dec192: decrypt_round(crypto_it_tab,-64) .Ld192: decrypt_round(crypto_it_tab,-64)
decrypt_round(crypto_it_tab,-48) decrypt_round(crypto_it_tab,-48)
dec128: decrypt_round(crypto_it_tab,-32) .Ld128: decrypt_round(crypto_it_tab,-32)
decrypt_round(crypto_it_tab,-16) decrypt_round(crypto_it_tab,-16)
decrypt_round(crypto_it_tab, 0) decrypt_round(crypto_it_tab, 0)
decrypt_round(crypto_it_tab, 16) decrypt_round(crypto_it_tab, 16)
@ -185,4 +185,4 @@ dec128: decrypt_round(crypto_it_tab,-32)
decrypt_round(crypto_it_tab, 80) decrypt_round(crypto_it_tab, 80)
decrypt_round(crypto_it_tab, 96) decrypt_round(crypto_it_tab, 96)
decrypt_final(crypto_il_tab,112) decrypt_final(crypto_il_tab,112)
return return(aes_dec_blk)