This patch fixes clobbering of XMM6-XMM9 registers by the assembler implementation of aesni_ecb_encrypt(). Windows x86_64 ABI requires XMM6-XMM15 registers to be preserved by callee, unlike System V x86_64 ABI.

--- a/crypto/aes/asm/aesni-x86_64.pl    2014-09-25 22:02:56.000000000 +0300
+++ b/crypto/aes/asm/aesni-x86_64.pl    2014-10-14 13:00:42.085931400 +0300
@@ -584,6 +584,15 @@
 .type    aesni_ecb_encrypt,\@function,5
 .align    16
 aesni_ecb_encrypt:
+___
+$code.=<<___ if ($win64);
+ lea -0x48(%rsp),%rsp # 4*16 bytes for XMM regs + 8 bytes for stack alignment
+    movdqa    %xmm6,(%rsp)
+    movdqa    %xmm7,0x10(%rsp)
+    movdqa    %xmm8,0x20(%rsp)
+    movdqa    %xmm9,0x30(%rsp)
+___
+$code.=<<___;
     and    \$-16,$len
     jz    .Lecb_ret

@@ -862,6 +871,15 @@
     movups    $inout5,0x50($out)

 .Lecb_ret:
+___
+$code.=<<___ if ($win64);
+    movdqa    (%rsp),%xmm6
+    movdqa    0x10(%rsp),%xmm7
+    movdqa    0x20(%rsp),%xmm8
+    movdqa    0x30(%rsp),%xmm9
+    lea    0x48(%rsp),%rsp
+___
+$code.=<<___;
     ret
 .size    aesni_ecb_encrypt,.-aesni_ecb_encrypt
 ___

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       openssl-dev@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to