Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: arm/sha512-neon - Use API partial block handling

Use the Crypto API partial block handling.

Also remove the unnecessary SIMD fallback path.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+13 -30
+13 -30
arch/arm/crypto/sha512-neon-glue.c
··· 5 5 * Copyright (C) 2015 Linaro Ltd <ard.biesheuvel@linaro.org> 6 6 */ 7 7 8 + #include <asm/neon.h> 8 9 #include <crypto/internal/hash.h> 9 - #include <crypto/internal/simd.h> 10 10 #include <crypto/sha2.h> 11 11 #include <crypto/sha512_base.h> 12 - #include <linux/crypto.h> 12 + #include <linux/kernel.h> 13 13 #include <linux/module.h> 14 - 15 - #include <asm/simd.h> 16 - #include <asm/neon.h> 17 14 18 15 #include "sha512.h" 19 16 ··· 23 26 static int sha512_neon_update(struct shash_desc *desc, const u8 *data, 24 27 unsigned int len) 25 28 { 26 - struct sha512_state *sctx = shash_desc_ctx(desc); 27 - 28 - if (!crypto_simd_usable() || 29 - (sctx->count[0] % SHA512_BLOCK_SIZE) + len < SHA512_BLOCK_SIZE) 30 - return sha512_arm_update(desc, data, len); 29 + int remain; 31 30 32 31 kernel_neon_begin(); 33 - sha512_base_do_update(desc, data, len, sha512_block_data_order_neon); 32 + remain = sha512_base_do_update_blocks(desc, data, len, 33 + sha512_block_data_order_neon); 34 34 kernel_neon_end(); 35 - 36 - return 0; 35 + return remain; 37 36 } 38 37 39 38 static int sha512_neon_finup(struct shash_desc *desc, const u8 *data, 40 39 unsigned int len, u8 *out) 41 40 { 42 - if (!crypto_simd_usable()) 43 - return sha512_arm_finup(desc, data, len, out); 44 - 45 41 kernel_neon_begin(); 46 - if (len) 47 - sha512_base_do_update(desc, data, len, 48 - sha512_block_data_order_neon); 49 - sha512_base_do_finalize(desc, sha512_block_data_order_neon); 42 + sha512_base_do_finup(desc, data, len, sha512_block_data_order_neon); 50 43 kernel_neon_end(); 51 - 52 44 return sha512_base_finish(desc, out); 53 - } 54 - 55 - static int sha512_neon_final(struct shash_desc *desc, u8 *out) 56 - { 57 - return sha512_neon_finup(desc, NULL, 0, out); 58 45 } 59 46 60 47 struct shash_alg sha512_neon_algs[] = { { 61 48 .init = sha384_base_init, 62 49 .update = sha512_neon_update, 63 - .final = sha512_neon_final, 64 50 .finup = sha512_neon_finup, 65 - .descsize = sizeof(struct sha512_state), 51 + .descsize = SHA512_STATE_SIZE, 66 52 .digestsize = SHA384_DIGEST_SIZE, 67 53 .base = { 68 54 .cra_name = "sha384", 69 55 .cra_driver_name = "sha384-neon", 70 56 .cra_priority = 300, 57 + .cra_flags = CRYPTO_AHASH_ALG_BLOCK_ONLY | 58 + CRYPTO_AHASH_ALG_FINUP_MAX, 71 59 .cra_blocksize = SHA384_BLOCK_SIZE, 72 60 .cra_module = THIS_MODULE, 73 61 ··· 60 78 }, { 61 79 .init = sha512_base_init, 62 80 .update = sha512_neon_update, 63 - .final = sha512_neon_final, 64 81 .finup = sha512_neon_finup, 65 - .descsize = sizeof(struct sha512_state), 82 + .descsize = SHA512_STATE_SIZE, 66 83 .digestsize = SHA512_DIGEST_SIZE, 67 84 .base = { 68 85 .cra_name = "sha512", 69 86 .cra_driver_name = "sha512-neon", 70 87 .cra_priority = 300, 88 + .cra_flags = CRYPTO_AHASH_ALG_BLOCK_ONLY | 89 + CRYPTO_AHASH_ALG_FINUP_MAX, 71 90 .cra_blocksize = SHA512_BLOCK_SIZE, 72 91 .cra_module = THIS_MODULE, 73 92 }