Skip to content

Commit 31d6f93

Browse files
committed
fix AVX-512 XTS impl on windows
1 parent 89889a9 commit 31d6f93

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed

crypto/fipsmodule/aes/asm/aesni-xts-avx512.pl

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -63,33 +63,18 @@
6363
# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6464
my ($key2, $key1, $tweak, $length, $input, $output);
6565

66-
if ($win64) {
67-
$input = "%rcx";
68-
$output = "%rdx";
69-
$length = "%r8";
70-
$key1 = "%r9";
71-
$key2 = "%r10";
72-
$tweak = "%r11";
73-
} else {
7466
$input = "%rdi";
7567
$output = "%rsi";
7668
$length = "%rdx";
7769
$key1 = "%rcx";
7870
$key2 = "%r8";
7971
$tweak = "%r9";
80-
}
8172

8273
# arguments for temp parameters
8374
my ($tmp1, $gf_poly_8b, $gf_poly_8b_temp);
84-
if ($win64) {
85-
$tmp1 = "%r10";
86-
$gf_poly_8b = "%rdi";
87-
$gf_poly_8b_temp = "%rsi";
88-
} else {
8975
$tmp1 = "%r8";
9076
$gf_poly_8b = "%r10";
9177
$gf_poly_8b_temp = "%r11";
92-
}
9378

9479
# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9580
# ;;; Helper functions
@@ -1469,7 +1454,7 @@
14691454
$code.=<<___;
14701455
.globl aes_hw_xts_encrypt_avx512
14711456
.hidden aes_hw_xts_encrypt_avx512
1472-
.type aes_hw_xts_encrypt_avx512,\@abi-omnipotent
1457+
.type aes_hw_xts_encrypt_avx512,\@function,6
14731458
.align 32
14741459
aes_hw_xts_encrypt_avx512:
14751460
.cfi_startproc
@@ -1860,22 +1845,22 @@
18601845
vmovdqa $XMM_STORAGE + 16 * 3($TW), %xmm9
18611846
18621847
# Zero the 64 bytes we just restored to the xmm registers.
1863-
vmovdqa64 %zmm0,$XMM_STORAGE($TW)
1848+
vmovdqu64 %zmm0,$XMM_STORAGE($TW)
18641849
18651850
vmovdqa $XMM_STORAGE + 16 * 4($TW), %xmm10
18661851
vmovdqa $XMM_STORAGE + 16 * 5($TW), %xmm11
18671852
vmovdqa $XMM_STORAGE + 16 * 6($TW), %xmm12
18681853
vmovdqa $XMM_STORAGE + 16 * 7($TW), %xmm13
18691854
18701855
# And again.
1871-
vmovdqa64 %zmm0,$XMM_STORAGE + 16 * 4($TW)
1856+
vmovdqu64 %zmm0,$XMM_STORAGE + 16 * 4($TW)
18721857
18731858
vmovdqa $XMM_STORAGE + 16 * 8($TW), %xmm14
18741859
vmovdqa $XMM_STORAGE + 16 * 9($TW), %xmm15
18751860
18761861
# Last round is only 32 bytes (256-bits), so we use `%ymm` as the
18771862
# source operand.
1878-
vmovdqa %ymm0,$XMM_STORAGE + 16 * 8($TW)
1863+
vmovdqu %ymm0,$XMM_STORAGE + 16 * 8($TW)
18791864
___
18801865
}
18811866

@@ -2113,7 +2098,7 @@
21132098
$code.=<<___;
21142099
.globl aes_hw_xts_decrypt_avx512
21152100
.hidden aes_hw_xts_decrypt_avx512
2116-
.type aes_hw_xts_decrypt_avx512,\@abi-omnipotent
2101+
.type aes_hw_xts_decrypt_avx512,\@function,6
21172102
.align 32
21182103
aes_hw_xts_decrypt_avx512:
21192104
.cfi_startproc
@@ -2635,22 +2620,22 @@
26352620
vmovdqa $XMM_STORAGE + 16 * 3($TW), %xmm9
26362621
26372622
# Zero the 64 bytes we just restored to the xmm registers.
2638-
vmovdqa64 %zmm0,$XMM_STORAGE($TW)
2623+
vmovdqu64 %zmm0,$XMM_STORAGE($TW)
26392624
26402625
vmovdqa $XMM_STORAGE + 16 * 4($TW), %xmm10
26412626
vmovdqa $XMM_STORAGE + 16 * 5($TW), %xmm11
26422627
vmovdqa $XMM_STORAGE + 16 * 6($TW), %xmm12
26432628
vmovdqa $XMM_STORAGE + 16 * 7($TW), %xmm13
26442629
26452630
# And again.
2646-
vmovdqa64 %zmm0,$XMM_STORAGE + 16 * 4($TW)
2631+
vmovdqu64 %zmm0,$XMM_STORAGE + 16 * 4($TW)
26472632
26482633
vmovdqa $XMM_STORAGE + 16 * 8($TW), %xmm14
26492634
vmovdqa $XMM_STORAGE + 16 * 9($TW), %xmm15
26502635
26512636
# Last round is only 32 bytes (256-bits), so we use `%ymm` as the
26522637
# source operand.
2653-
vmovdqa %ymm0,$XMM_STORAGE + 16 * 8($TW)
2638+
vmovdqu %ymm0,$XMM_STORAGE + 16 * 8($TW)
26542639
___
26552640
}
26562641

crypto/fipsmodule/aes/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ OPENSSL_EXPORT int aes_hw_xts_cipher(const uint8_t *in, uint8_t *out, size_t len
161161
const AES_KEY *key1, const AES_KEY *key2,
162162
const uint8_t iv[16], int enc);
163163

164-
#if defined(OPENSSL_X86_64) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) && !defined(OPENSSL_WINDOWS)
164+
#if defined(OPENSSL_X86_64) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX)
165165
#define AES_XTS_X86_64_AVX512
166166
void aes_hw_xts_encrypt_avx512(const uint8_t *in, uint8_t *out, size_t length,
167167
const AES_KEY *key1, const AES_KEY *key2,

0 commit comments

Comments
 (0)