[PATCH 2/3] camellia-aesni-avx-amd64: Move register clearing to assembly functions
Jussi Kivilinna
jussi.kivilinna at iki.fi
Sun Sep 1 15:54:14 CEST 2013
* cipher/camellia-aesni-avx-amd64.S (_gcry_camellia_aesni_avx_ctr_enc)
(_gcry_camellia_aesni_avx_cbc_dec)
(_gcry_camellia_aesni_avx_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_AVX]: 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 at iki.fi>
---
cipher/camellia-aesni-avx-amd64.S | 12 ++++++++++++
cipher/camellia-glue.c | 9 ---------
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/cipher/camellia-aesni-avx-amd64.S b/cipher/camellia-aesni-avx-amd64.S
index b0ef5fd..9873d98 100644
--- a/cipher/camellia-aesni-avx-amd64.S
+++ b/cipher/camellia-aesni-avx-amd64.S
@@ -958,6 +958,8 @@ _gcry_camellia_aesni_avx_ctr_enc:
* %rcx: iv (big endian, 128bit)
*/
+ vzeroupper;
+
subq $(16 * 16), %rsp;
movq %rsp, %rax;
@@ -1054,6 +1056,8 @@ _gcry_camellia_aesni_avx_ctr_enc:
%xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
%xmm8, %rsi);
+ vzeroall;
+
ret;
.size _gcry_camellia_aesni_avx_ctr_enc,.-_gcry_camellia_aesni_avx_ctr_enc;
@@ -1069,6 +1073,8 @@ _gcry_camellia_aesni_avx_cbc_dec:
* %rcx: iv
*/
+ vzeroupper;
+
movq %rcx, %r9;
cmpl $128, key_bitlength(CTX);
@@ -1114,6 +1120,8 @@ _gcry_camellia_aesni_avx_cbc_dec:
movq %r10, (0)(%r9);
movq %r11, (8)(%r9);
+ vzeroall;
+
ret;
.size _gcry_camellia_aesni_avx_cbc_dec,.-_gcry_camellia_aesni_avx_cbc_dec;
@@ -1129,6 +1137,8 @@ _gcry_camellia_aesni_avx_cfb_dec:
* %rcx: iv
*/
+ vzeroupper;
+
subq $(16 * 16), %rsp;
movq %rsp, %rax;
@@ -1179,6 +1189,8 @@ _gcry_camellia_aesni_avx_cfb_dec:
%xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
%xmm8, %rsi);
+ vzeroall;
+
ret;
.size _gcry_camellia_aesni_avx_cfb_dec,.-_gcry_camellia_aesni_avx_cfb_dec;
diff --git a/cipher/camellia-glue.c b/cipher/camellia-glue.c
index 6e2319d..7d8a4cd 100644
--- a/cipher/camellia-glue.c
+++ b/cipher/camellia-glue.c
@@ -344,9 +344,6 @@ _gcry_camellia_ctr_enc(void *context, unsigned char *ctr,
if (did_use_aesni_avx)
{
- /* clear AVX registers */
- asm volatile ("vzeroall;\n":::);
-
if (burn_stack_depth < 16 * CAMELLIA_BLOCK_SIZE + 2 * sizeof(void *))
burn_stack_depth = 16 * CAMELLIA_BLOCK_SIZE + 2 * sizeof(void *);
}
@@ -440,9 +437,6 @@ _gcry_camellia_cbc_dec(void *context, unsigned char *iv,
if (did_use_aesni_avx)
{
- /* clear AVX registers */
- asm volatile ("vzeroall;\n":::);
-
if (burn_stack_depth < 16 * CAMELLIA_BLOCK_SIZE + 2 * sizeof(void *))
burn_stack_depth = 16 * CAMELLIA_BLOCK_SIZE + 2 * sizeof(void *);
}
@@ -531,9 +525,6 @@ _gcry_camellia_cfb_dec(void *context, unsigned char *iv,
if (did_use_aesni_avx)
{
- /* clear AVX registers */
- asm volatile ("vzeroall;\n":::);
-
if (burn_stack_depth < 16 * CAMELLIA_BLOCK_SIZE + 2 * sizeof(void *))
burn_stack_depth = 16 * CAMELLIA_BLOCK_SIZE + 2 * sizeof(void *);
}
More information about the Gcrypt-devel
mailing list