camellia-aesni-avx2-amd64: Move register clearing to assembly functions
authorJussi Kivilinna <jussi.kivilinna@iki.fi>
Sun, 1 Sep 2013 13:50:55 +0000 (16:50 +0300)
committerJussi Kivilinna <jussi.kivilinna@iki.fi>
Sun, 1 Sep 2013 13:50:55 +0000 (16:50 +0300)
* cipher/camellia-aesni-avx2-amd64.S
(_gcry_camellia_aesni_avx2_ctr_enc): Add 'vzeroall'.
(_gcry_camellia_aesni_avx2_cbc_dec)
(_gcry_camellia_aesni_avx2_cfb_dec): Add 'vzeroupper' at head and
'vzeroall' at tail.
* cipher/camellia-glue.c (_gcry_serpent_ctr_enc, _gcry_serpent_cbc_dec)
(_gcry_serpent_avx2_cfb_dec) [USE_AESNI_AVX2]: Remove register
clearing.
--

Patch moves register clearing with 'vzeroall' to assembly functions and
adds missing 'vzeroupper' instructions at head of assembly functions.

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
cipher/camellia-aesni-avx2-amd64.S
cipher/camellia-glue.c

index da427b4..7e31323 100644 (file)
@@ -1104,6 +1104,8 @@ _gcry_camellia_aesni_avx2_ctr_enc:
                     %ymm15, %ymm14, %ymm13, %ymm12, %ymm11, %ymm10, %ymm9,
                     %ymm8, %rsi);
 
+       vzeroall;
+
        ret;
 .size _gcry_camellia_aesni_avx2_ctr_enc,.-_gcry_camellia_aesni_avx2_ctr_enc;
 
@@ -1119,6 +1121,8 @@ _gcry_camellia_aesni_avx2_cbc_dec:
         *      %rcx: iv
         */
 
+       vzeroupper;
+
        movq %rcx, %r9;
 
        cmpl $128, key_bitlength(CTX);
@@ -1171,6 +1175,8 @@ _gcry_camellia_aesni_avx2_cbc_dec:
        movq %rax, (0)(%r9);
        movq %rcx, (8)(%r9);
 
+       vzeroall;
+
        ret;
 .size _gcry_camellia_aesni_avx2_cbc_dec,.-_gcry_camellia_aesni_avx2_cbc_dec;
 
@@ -1186,6 +1192,8 @@ _gcry_camellia_aesni_avx2_cfb_dec:
         *      %rcx: iv
         */
 
+       vzeroupper;
+
        movq %rsp, %r10;
        subq $(16 * 32), %rsp;
        andq $~31, %rsp;
@@ -1240,6 +1248,8 @@ _gcry_camellia_aesni_avx2_cfb_dec:
                     %ymm15, %ymm14, %ymm13, %ymm12, %ymm11, %ymm10, %ymm9,
                     %ymm8, %rsi);
 
+       vzeroall;
+
        ret;
 .size _gcry_camellia_aesni_avx2_cfb_dec,.-_gcry_camellia_aesni_avx2_cfb_dec;
 
index 7d8a4cd..d6d6005 100644 (file)
@@ -314,9 +314,6 @@ _gcry_camellia_ctr_enc(void *context, unsigned char *ctr,
           int avx2_burn_stack_depth = 32 * CAMELLIA_BLOCK_SIZE + 16 +
                                         2 * sizeof(void *);
 
-          /* clear AVX registers */
-          asm volatile ("vzeroall;\n":::);
-
           if (burn_stack_depth < avx2_burn_stack_depth)
             burn_stack_depth = avx2_burn_stack_depth;
         }
@@ -408,9 +405,6 @@ _gcry_camellia_cbc_dec(void *context, unsigned char *iv,
           int avx2_burn_stack_depth = 32 * CAMELLIA_BLOCK_SIZE + 16 +
                                         2 * sizeof(void *);
 
-          /* clear AVX registers */
-          asm volatile ("vzeroall;\n":::);
-
           if (burn_stack_depth < avx2_burn_stack_depth)
             burn_stack_depth = avx2_burn_stack_depth;
         }
@@ -496,9 +490,6 @@ _gcry_camellia_cfb_dec(void *context, unsigned char *iv,
           int avx2_burn_stack_depth = 32 * CAMELLIA_BLOCK_SIZE + 16 +
                                         2 * sizeof(void *);
 
-          /* clear AVX registers */
-          asm volatile ("vzeroall;\n":::);
-
           if (burn_stack_depth < avx2_burn_stack_depth)
             burn_stack_depth = avx2_burn_stack_depth;
         }