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

crypto: aegis128-neon - Move to more abstract 'ksimd' guard API

Move away from calling kernel_neon_begin() and kernel_neon_end()
directly, and instead, use the newly introduced scoped_ksimd() API. This
permits arm64 to modify the kernel mode NEON API without affecting code
that is shared between ARM and arm64.

Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

+12 -21
+12 -21
crypto/aegis128-neon.c
··· 4 4 */ 5 5 6 6 #include <asm/cpufeature.h> 7 - #include <asm/neon.h> 7 + #include <asm/simd.h> 8 8 9 9 #include "aegis.h" 10 10 #include "aegis-neon.h" ··· 24 24 const union aegis_block *key, 25 25 const u8 *iv) 26 26 { 27 - kernel_neon_begin(); 28 - crypto_aegis128_init_neon(state, key, iv); 29 - kernel_neon_end(); 27 + scoped_ksimd() 28 + crypto_aegis128_init_neon(state, key, iv); 30 29 } 31 30 32 31 void crypto_aegis128_update_simd(struct aegis_state *state, const void *msg) 33 32 { 34 - kernel_neon_begin(); 35 - crypto_aegis128_update_neon(state, msg); 36 - kernel_neon_end(); 33 + scoped_ksimd() 34 + crypto_aegis128_update_neon(state, msg); 37 35 } 38 36 39 37 void crypto_aegis128_encrypt_chunk_simd(struct aegis_state *state, u8 *dst, 40 38 const u8 *src, unsigned int size) 41 39 { 42 - kernel_neon_begin(); 43 - crypto_aegis128_encrypt_chunk_neon(state, dst, src, size); 44 - kernel_neon_end(); 40 + scoped_ksimd() 41 + crypto_aegis128_encrypt_chunk_neon(state, dst, src, size); 45 42 } 46 43 47 44 void crypto_aegis128_decrypt_chunk_simd(struct aegis_state *state, u8 *dst, 48 45 const u8 *src, unsigned int size) 49 46 { 50 - kernel_neon_begin(); 51 - crypto_aegis128_decrypt_chunk_neon(state, dst, src, size); 52 - kernel_neon_end(); 47 + scoped_ksimd() 48 + crypto_aegis128_decrypt_chunk_neon(state, dst, src, size); 53 49 } 54 50 55 51 int crypto_aegis128_final_simd(struct aegis_state *state, ··· 54 58 unsigned int cryptlen, 55 59 unsigned int authsize) 56 60 { 57 - int ret; 58 - 59 - kernel_neon_begin(); 60 - ret = crypto_aegis128_final_neon(state, tag_xor, assoclen, cryptlen, 61 - authsize); 62 - kernel_neon_end(); 63 - 64 - return ret; 61 + scoped_ksimd() 62 + return crypto_aegis128_final_neon(state, tag_xor, assoclen, 63 + cryptlen, authsize); 65 64 }