From 3ff3990849b8650bec8ca388697744fbe2a5495a Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 23 Sep 2018 03:53:35 +0200 Subject: crypto-arm: rework KERNEL_MODE_NEON handling again --- src/crypto/zinc/chacha20/chacha20-arm-glue.h | 9 ++------- src/crypto/zinc/chacha20/chacha20-arm.S | 2 +- src/crypto/zinc/chacha20/chacha20-arm64.S | 2 ++ src/crypto/zinc/curve25519/curve25519-arm-glue.h | 9 ++------- src/crypto/zinc/curve25519/curve25519-arm.S | 4 ++-- src/crypto/zinc/poly1305/poly1305-arm-glue.h | 13 ++++--------- src/crypto/zinc/poly1305/poly1305-arm.S | 2 +- src/crypto/zinc/poly1305/poly1305-arm64.S | 2 ++ 8 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/crypto/zinc/chacha20/chacha20-arm-glue.h b/src/crypto/zinc/chacha20/chacha20-arm-glue.h index 26fa4f2..1f1add0 100644 --- a/src/crypto/zinc/chacha20/chacha20-arm-glue.h +++ b/src/crypto/zinc/chacha20/chacha20-arm-glue.h @@ -10,17 +10,12 @@ #include #endif -#define ARM_USE_NEON (defined(CONFIG_KERNEL_MODE_NEON) && \ - (defined(CONFIG_ARM64) || \ - (defined(__LINUX_ARM_ARCH__) && \ - __LINUX_ARM_ARCH__ == 7))) - asmlinkage void chacha20_arm(u8 *out, const u8 *in, const size_t len, const u32 key[8], const u32 counter[4]); #if defined(CONFIG_ARM) asmlinkage void hchacha20_arm(const u32 state[16], u32 out[8]); #endif -#if ARM_USE_NEON +#if defined(CONFIG_KERNEL_MODE_NEON) asmlinkage void chacha20_neon(u8 *out, const u8 *in, const size_t len, const u32 key[8], const u32 counter[4]); #endif @@ -50,7 +45,7 @@ static inline bool chacha20_arch(struct chacha20_ctx *state, u8 *dst, const u8 *src, size_t len, simd_context_t *simd_context) { -#if ARM_USE_NEON +#if defined(CONFIG_KERNEL_MODE_NEON) if (chacha20_use_neon && len >= CHACHA20_BLOCK_SIZE * 3 && simd_use(simd_context)) chacha20_neon(dst, src, len, state->key, state->counter); diff --git a/src/crypto/zinc/chacha20/chacha20-arm.S b/src/crypto/zinc/chacha20/chacha20-arm.S index dec2eb6..7ac2e26 100644 --- a/src/crypto/zinc/chacha20/chacha20-arm.S +++ b/src/crypto/zinc/chacha20/chacha20-arm.S @@ -465,7 +465,7 @@ ENTRY(hchacha20_arm) pop {r4-r11,pc} ENDPROC(hchacha20_arm) -#if __LINUX_ARM_ARCH__ >= 7 && IS_ENABLED(CONFIG_KERNEL_MODE_NEON) +#ifdef CONFIG_KERNEL_MODE_NEON /* * This following NEON routine was ported from Andy Polyakov's implementation * from CRYPTOGAMS. It begins with parts of the CRYPTOGAMS scalar routine, diff --git a/src/crypto/zinc/chacha20/chacha20-arm64.S b/src/crypto/zinc/chacha20/chacha20-arm64.S index ba82286..1aeadab 100644 --- a/src/crypto/zinc/chacha20/chacha20-arm64.S +++ b/src/crypto/zinc/chacha20/chacha20-arm64.S @@ -289,6 +289,7 @@ ENTRY(chacha20_arm) ret ENDPROC(chacha20_arm) +#ifdef CONFIG_KERNEL_MODE_NEON .align 5 ENTRY(chacha20_neon) cbz x2,.Labort_neon @@ -1940,3 +1941,4 @@ ENTRY(chacha20_neon) .Labort_neon: ret ENDPROC(chacha20_neon) +#endif diff --git a/src/crypto/zinc/curve25519/curve25519-arm-glue.h b/src/crypto/zinc/curve25519/curve25519-arm-glue.h index e9496b0..6b20931 100644 --- a/src/crypto/zinc/curve25519/curve25519-arm-glue.h +++ b/src/crypto/zinc/curve25519/curve25519-arm-glue.h @@ -7,12 +7,7 @@ #include #include -#define ARM_USE_NEON (defined(CONFIG_KERNEL_MODE_NEON) && \ - (defined(CONFIG_ARM64) || \ - (defined(__LINUX_ARM_ARCH__) && \ - __LINUX_ARM_ARCH__ == 7))) - -#if ARM_USE_NEON +#if defined(CONFIG_KERNEL_MODE_NEON) asmlinkage void curve25519_neon(u8 mypublic[CURVE25519_POINT_SIZE], const u8 secret[CURVE25519_POINT_SIZE], const u8 basepoint[CURVE25519_POINT_SIZE]); @@ -29,7 +24,7 @@ static inline bool curve25519_arch(u8 mypublic[CURVE25519_POINT_SIZE], const u8 secret[CURVE25519_POINT_SIZE], const u8 basepoint[CURVE25519_POINT_SIZE]) { -#if ARM_USE_NEON +#if defined(CONFIG_KERNEL_MODE_NEON) if (curve25519_use_neon && may_use_simd()) { kernel_neon_begin(); curve25519_neon(mypublic, secret, basepoint); diff --git a/src/crypto/zinc/curve25519/curve25519-arm.S b/src/crypto/zinc/curve25519/curve25519-arm.S index 01cb4ad..db6570c 100644 --- a/src/crypto/zinc/curve25519/curve25519-arm.S +++ b/src/crypto/zinc/curve25519/curve25519-arm.S @@ -7,11 +7,12 @@ * but has subsequently been manually reworked for use in kernel space. */ -#if IS_ENABLED(CONFIG_KERNEL_MODE_NEON) && __LINUX_ARM_ARCH__ == 7 +#ifdef CONFIG_KERNEL_MODE_NEON #include .text .fpu neon +.arch armv7-a .align 4 ENTRY(curve25519_neon) @@ -2091,5 +2092,4 @@ ENTRY(curve25519_neon) mov sp, ip pop {r4-r11, pc} ENDPROC(curve25519_neon) - #endif diff --git a/src/crypto/zinc/poly1305/poly1305-arm-glue.h b/src/crypto/zinc/poly1305/poly1305-arm-glue.h index fb7be17..ddeb58a 100644 --- a/src/crypto/zinc/poly1305/poly1305-arm-glue.h +++ b/src/crypto/zinc/poly1305/poly1305-arm-glue.h @@ -6,16 +6,11 @@ #include #include -#define ARM_USE_NEON (defined(CONFIG_KERNEL_MODE_NEON) && \ - (defined(CONFIG_ARM64) || \ - (defined(__LINUX_ARM_ARCH__) && \ - __LINUX_ARM_ARCH__ == 7))) - asmlinkage void poly1305_init_arm(void *ctx, const u8 key[16]); asmlinkage void poly1305_blocks_arm(void *ctx, const u8 *inp, const size_t len, const u32 padbit); asmlinkage void poly1305_emit_arm(void *ctx, u8 mac[16], const u32 nonce[4]); -#if ARM_USE_NEON +#if defined(CONFIG_KERNEL_MODE_NEON) asmlinkage void poly1305_blocks_neon(void *ctx, const u8 *inp, const size_t len, const u32 padbit); asmlinkage void poly1305_emit_neon(void *ctx, u8 mac[16], const u32 nonce[4]); @@ -57,7 +52,7 @@ struct poly1305_arch_internal { }; #endif -#if ARM_USE_NEON +#if defined(CONFIG_KERNEL_MODE_NEON) static void convert_to_base2_64(void *ctx) { struct poly1305_arch_internal *state = ctx; @@ -95,7 +90,7 @@ static inline bool poly1305_blocks_arch(void *ctx, const u8 *inp, const size_t len, const u32 padbit, simd_context_t *simd_context) { -#if ARM_USE_NEON +#if defined(CONFIG_KERNEL_MODE_NEON) if (poly1305_use_neon && simd_use(simd_context)) { poly1305_blocks_neon(ctx, inp, len, padbit); return true; @@ -111,7 +106,7 @@ static inline bool poly1305_emit_arch(void *ctx, u8 mac[POLY1305_MAC_SIZE], const u32 nonce[4], simd_context_t *simd_context) { -#if ARM_USE_NEON +#if defined(CONFIG_KERNEL_MODE_NEON) if (poly1305_use_neon && simd_use(simd_context)) { poly1305_emit_neon(ctx, mac, nonce); return true; diff --git a/src/crypto/zinc/poly1305/poly1305-arm.S b/src/crypto/zinc/poly1305/poly1305-arm.S index 84c96c3..4a0e9d4 100644 --- a/src/crypto/zinc/poly1305/poly1305-arm.S +++ b/src/crypto/zinc/poly1305/poly1305-arm.S @@ -339,7 +339,7 @@ ENTRY(poly1305_emit_arm) ENDPROC(poly1305_emit_arm) -#if __LINUX_ARM_ARCH__ >= 7 +#ifdef CONFIG_KERNEL_MODE_NEON .fpu neon .align 5 diff --git a/src/crypto/zinc/poly1305/poly1305-arm64.S b/src/crypto/zinc/poly1305/poly1305-arm64.S index 4ccd3d5..84a6544 100644 --- a/src/crypto/zinc/poly1305/poly1305-arm64.S +++ b/src/crypto/zinc/poly1305/poly1305-arm64.S @@ -186,6 +186,7 @@ __poly1305_splat: ret +#ifdef CONFIG_KERNEL_MODE_NEON .align 5 ENTRY(poly1305_blocks_neon) ldr x17,[x0,#24] @@ -820,3 +821,4 @@ ENDPROC(poly1305_emit_neon) .align 5 .Lzeros: .long 0,0,0,0,0,0,0,0 +#endif -- cgit v1.2.3-59-g8ed1b