Skip to content

Commit 611d532

Browse files
Ard Biesheuvelherbertx
authored andcommitted
crypto: arm64/chacha20 - take may_use_simd() into account
To accommodate systems that disallow the use of kernel mode NEON in some circumstances, take the return value of may_use_simd into account when deciding whether to invoke the C fallback routine. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent e211506 commit 611d532

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/arm64/crypto/chacha20-neon-glue.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* ChaCha20 256-bit cipher algorithm, RFC7539, arm64 NEON functions
33
*
4-
* Copyright (C) 2016 Linaro, Ltd. <ard.biesheuvel@linaro.org>
4+
* Copyright (C) 2016 - 2017 Linaro, Ltd. <ard.biesheuvel@linaro.org>
55
*
66
* This program is free software; you can redistribute it and/or modify
77
* it under the terms of the GNU General Public License version 2 as
@@ -26,6 +26,7 @@
2626

2727
#include <asm/hwcap.h>
2828
#include <asm/neon.h>
29+
#include <asm/simd.h>
2930

3031
asmlinkage void chacha20_block_xor_neon(u32 *state, u8 *dst, const u8 *src);
3132
asmlinkage void chacha20_4block_xor_neon(u32 *state, u8 *dst, const u8 *src);
@@ -64,7 +65,7 @@ static int chacha20_neon(struct skcipher_request *req)
6465
u32 state[16];
6566
int err;
6667

67-
if (req->cryptlen <= CHACHA20_BLOCK_SIZE)
68+
if (!may_use_simd() || req->cryptlen <= CHACHA20_BLOCK_SIZE)
6869
return crypto_chacha20_crypt(req);
6970

7071
err = skcipher_walk_virt(&walk, req, true);

0 commit comments

Comments
 (0)