Skip to content

Commit f0c81fa

Browse files
committed
Adapt BoringSSL implementation to mirror existing AVX assembly file
Signed-off-by: Joel Low <[email protected]>
1 parent 492acd6 commit f0c81fa

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

module/icp/asm-x86_64/modes/aesni-gcm-avx2.S

+29-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
// This file is generated from a similarly-named Perl script in the BoringSSL
22
// source tree. Do not edit by hand.
33

4-
#include <openssl/asm_base.h>
4+
#if defined(__x86_64__) && defined(HAVE_AVX) && \
5+
defined(HAVE_VAES) && defined(HAVE_VPCLMULQDQ)
6+
7+
#define _ASM
8+
#include <sys/asm_linkage.h>
9+
10+
/* Windows userland links with OpenSSL */
11+
#if !defined (_WIN32) || defined (_KERNEL)
12+
13+
#ifndef _CET_ENDBR
14+
#define _CET_ENDBR
15+
#endif
516

6-
#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__)
717
.section .rodata
818
.align 16
919

@@ -48,7 +58,11 @@ _CET_ENDBR
4858

4959

5060

51-
vpshufd $0x4e,(%rsi),%xmm3
61+
vmovdqu (%rsi),%xmm3
62+
// KCF/ICP stores H in network byte order with the hi qword first
63+
// so we need to swap all bytes, not the 2 qwords.
64+
vmovdqu .Lbswap_mask(%rip),%xmm4
65+
vpshufb %xmm4,%xmm3,%xmm3
5266

5367

5468

@@ -381,8 +395,8 @@ _CET_ENDBR
381395

382396

383397

384-
movl 240(%rcx),%r10d
385-
leal -20(,%r10,4),%r10d
398+
movl 504(%rcx),%r10d // ICP has a larger offset for rounds.
399+
leal -24(,%r10,4),%r10d // ICP uses 10,12,14 not 9,11,13 for rounds.
386400

387401

388402

@@ -917,8 +931,8 @@ _CET_ENDBR
917931

918932

919933

920-
movl 240(%rcx),%r10d
921-
leal -20(,%r10,4),%r10d
934+
movl 504(%rcx),%r10d // ICP has a larger offset for rounds.
935+
leal -24(,%r10,4),%r10d // ICP uses 10,12,14 not 9,11,13 for rounds.
922936

923937

924938

@@ -1315,4 +1329,12 @@ _CET_ENDBR
13151329

13161330
.cfi_endproc
13171331
.size aes_gcm_dec_update_vaes_avx2, . - aes_gcm_dec_update_vaes_avx2
1332+
1333+
#endif /* !_WIN32 || _KERNEL */
1334+
1335+
/* Mark the stack non-executable. */
1336+
#if defined(__linux__) && defined(__ELF__)
1337+
.section .note.GNU-stack,"",%progbits
13181338
#endif
1339+
1340+
#endif /* defined(__x86_64__) && defined(HAVE_AVX) && defined(HAVE_AES) ... */

0 commit comments

Comments
 (0)