mirror of https://git.zx2c4.com/WireGuard
chacha20: enable sse2 path
This commit is contained in:
parent
0c1b6e5172
commit
7a45413771
|
@ -10,6 +10,8 @@
|
|||
|
||||
asmlinkage void hchacha20_ssse3(u32 *derived_key, const u8 *nonce,
|
||||
const u8 *key);
|
||||
asmlinkage void chacha20_sse2(u8 *out, const u8 *in, const size_t len,
|
||||
const u32 key[8], const u32 counter[4]);
|
||||
asmlinkage void chacha20_ssse3(u8 *out, const u8 *in, const size_t len,
|
||||
const u32 key[8], const u32 counter[4]);
|
||||
asmlinkage void chacha20_avx2(u8 *out, const u8 *in, const size_t len,
|
||||
|
@ -61,8 +63,7 @@ static inline bool chacha20_arch(struct chacha20_ctx *ctx, u8 *dst,
|
|||
BUILD_BUG_ON(PAGE_SIZE < CHACHA20_BLOCK_SIZE ||
|
||||
PAGE_SIZE % CHACHA20_BLOCK_SIZE);
|
||||
|
||||
if (!IS_ENABLED(CONFIG_AS_SSSE3) || !chacha20_use_ssse3 ||
|
||||
len <= CHACHA20_BLOCK_SIZE || !simd_use(simd_context))
|
||||
if (len <= CHACHA20_BLOCK_SIZE || !simd_use(simd_context))
|
||||
return false;
|
||||
|
||||
for (;;) {
|
||||
|
@ -77,8 +78,10 @@ static inline bool chacha20_arch(struct chacha20_ctx *ctx, u8 *dst,
|
|||
else if (IS_ENABLED(CONFIG_AS_AVX2) && chacha20_use_avx2 &&
|
||||
len >= CHACHA20_BLOCK_SIZE * 4)
|
||||
chacha20_avx2(dst, src, bytes, ctx->key, ctx->counter);
|
||||
else
|
||||
else if (IS_ENABLED(CONFIG_AS_SSSE3) && chacha20_use_ssse3)
|
||||
chacha20_ssse3(dst, src, bytes, ctx->key, ctx->counter);
|
||||
else
|
||||
chacha20_sse2(dst, src, bytes, ctx->key, ctx->counter);
|
||||
ctx->counter[0] += (bytes + 63) / 64;
|
||||
len -= bytes;
|
||||
if (!len)
|
||||
|
|
|
@ -272,7 +272,7 @@ my @x=map("\"$_\"",@x);
|
|||
|
||||
########################################################################
|
||||
# Generic code path that handles all lengths on pre-SSSE3 processors.
|
||||
&declare_function("ChaCha20_ctr32", 64);
|
||||
&declare_function("chacha20_sse2", 64);
|
||||
$code.=<<___;
|
||||
.cfi_startproc
|
||||
cmp \$0,$len
|
||||
|
@ -465,7 +465,7 @@ $code.=<<___;
|
|||
ret
|
||||
.cfi_endproc
|
||||
___
|
||||
&end_function("ChaCha20_ctr32");
|
||||
&end_function("chacha20_sse2");
|
||||
|
||||
########################################################################
|
||||
# SSSE3 code path that handles shorter lengths
|
||||
|
@ -3967,9 +3967,9 @@ simd_handler:
|
|||
|
||||
.section .pdata
|
||||
.align 4
|
||||
.rva .LSEH_begin_ChaCha20_ctr32
|
||||
.rva .LSEH_end_ChaCha20_ctr32
|
||||
.rva .LSEH_info_ChaCha20_ctr32
|
||||
.rva .LSEH_begin_chacha20_sse2
|
||||
.rva .LSEH_end_chacha20_sse2
|
||||
.rva .LSEH_info_chacha20_sse2
|
||||
|
||||
.rva .LSEH_begin_ChaCha20_ssse3
|
||||
.rva .LSEH_end_ChaCha20_ssse3
|
||||
|
@ -4013,7 +4013,7 @@ ___
|
|||
$code.=<<___;
|
||||
.section .xdata
|
||||
.align 8
|
||||
.LSEH_info_ChaCha20_ctr32:
|
||||
.LSEH_info_chacha20_sse2:
|
||||
.byte 9,0,0,0
|
||||
.rva se_handler
|
||||
|
||||
|
|
Loading…
Reference in New Issue