diff options
author | Damjan Marion <damarion@cisco.com> | 2020-05-11 14:03:29 +0200 |
---|---|---|
committer | Damjan Marion <damarion@cisco.com> | 2020-05-11 21:09:04 +0200 |
commit | 73a60b2da44847f3725d362a49207330d4d22aa5 (patch) | |
tree | 28cce70187bb368298dea6f2cfabed573a7e500f /src/plugins | |
parent | 1ae16c8f3bebe33b2404ad845a2f09f910a06390 (diff) |
crypto-native: properly deal with broken or outdated toolchains
Avoids crash due to missing symbol, when build system detects toolchain
which is not able to produce binaries for all targets we need....
Type: fix
Change-Id: I77ee63cb8dca3c9e4e83a6235c60f1439a472444
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/crypto_native/CMakeLists.txt | 13 | ||||
-rw-r--r-- | src/plugins/crypto_native/aes_cbc.c | 8 | ||||
-rw-r--r-- | src/plugins/crypto_native/aes_gcm.c | 8 | ||||
-rw-r--r-- | src/plugins/crypto_native/crypto_native.h | 20 | ||||
-rw-r--r-- | src/plugins/crypto_native/main.c | 47 |
5 files changed, 54 insertions, 42 deletions
diff --git a/src/plugins/crypto_native/CMakeLists.txt b/src/plugins/crypto_native/CMakeLists.txt index c6d916ddbbd..e71df3d6a98 100644 --- a/src/plugins/crypto_native/CMakeLists.txt +++ b/src/plugins/crypto_native/CMakeLists.txt @@ -12,13 +12,13 @@ # limitations under the License. if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*") - list(APPEND VARIANTS "sse42\;-march=silvermont") - list(APPEND VARIANTS "avx2\;-march=core-avx2") - if(compiler_flag_march_skylake_avx512) - list(APPEND VARIANTS "avx512\;-march=skylake-avx512") + list(APPEND VARIANTS "slm\;-march=silvermont") + list(APPEND VARIANTS "hsw\;-march=haswell") + if(compiler_flag_march_skylake_avx512 AND compiler_flag_mprefer_vector_width) + list(APPEND VARIANTS "skx\;-march=skylake-avx512 -mprefer-vector-width=256") endif() - if(compiler_flag_march_icelake_client) - list(APPEND VARIANTS "vaesni\;-march=icelake-client") + if(compiler_flag_march_icelake_client AND compiler_flag_mprefer_vector_width) + list(APPEND VARIANTS "icl\;-march=icelake-client -mprefer-vector-width=512") endif() set (COMPILE_FILES aes_cbc.c aes_gcm.c) set (COMPILE_OPTS -Wall -fno-common -maes) @@ -42,6 +42,7 @@ foreach(VARIANT ${VARIANTS}) set(l crypto_native_${v}) add_library(${l} OBJECT ${COMPILE_FILES}) set_target_properties(${l} PROPERTIES POSITION_INDEPENDENT_CODE ON) + separate_arguments(f) target_compile_options(${l} PUBLIC ${f} ${COMPILE_OPTS}) target_sources(crypto_native_plugin PRIVATE $<TARGET_OBJECTS:${l}>) endforeach() diff --git a/src/plugins/crypto_native/aes_cbc.c b/src/plugins/crypto_native/aes_cbc.c index e147ca66511..7589b4552d3 100644 --- a/src/plugins/crypto_native/aes_cbc.c +++ b/src/plugins/crypto_native/aes_cbc.c @@ -474,15 +474,15 @@ foreach_aes_cbc_handler_type; clib_error_t * #ifdef __VAES__ -crypto_native_aes_cbc_init_vaes (vlib_main_t * vm) +crypto_native_aes_cbc_init_icl (vlib_main_t * vm) #elif __AVX512F__ -crypto_native_aes_cbc_init_avx512 (vlib_main_t * vm) +crypto_native_aes_cbc_init_skx (vlib_main_t * vm) #elif __aarch64__ crypto_native_aes_cbc_init_neon (vlib_main_t * vm) #elif __AVX2__ -crypto_native_aes_cbc_init_avx2 (vlib_main_t * vm) +crypto_native_aes_cbc_init_hsw (vlib_main_t * vm) #else -crypto_native_aes_cbc_init_sse42 (vlib_main_t * vm) +crypto_native_aes_cbc_init_slm (vlib_main_t * vm) #endif { crypto_native_main_t *cm = &crypto_native_main; diff --git a/src/plugins/crypto_native/aes_gcm.c b/src/plugins/crypto_native/aes_gcm.c index 16bcfc4b01d..9aeed9dee2e 100644 --- a/src/plugins/crypto_native/aes_gcm.c +++ b/src/plugins/crypto_native/aes_gcm.c @@ -1196,15 +1196,15 @@ foreach_aes_gcm_handler_type; clib_error_t * #ifdef __VAES__ -crypto_native_aes_gcm_init_vaes (vlib_main_t * vm) +crypto_native_aes_gcm_init_icl (vlib_main_t * vm) #elif __AVX512F__ -crypto_native_aes_gcm_init_avx512 (vlib_main_t * vm) +crypto_native_aes_gcm_init_skx (vlib_main_t * vm) #elif __AVX2__ -crypto_native_aes_gcm_init_avx2 (vlib_main_t * vm) +crypto_native_aes_gcm_init_hsw (vlib_main_t * vm) #elif __aarch64__ crypto_native_aes_gcm_init_neon (vlib_main_t * vm) #else -crypto_native_aes_gcm_init_sse42 (vlib_main_t * vm) +crypto_native_aes_gcm_init_slm (vlib_main_t * vm) #endif { crypto_native_main_t *cm = &crypto_native_main; diff --git a/src/plugins/crypto_native/crypto_native.h b/src/plugins/crypto_native/crypto_native.h index b83dd773e44..f1153737dea 100644 --- a/src/plugins/crypto_native/crypto_native.h +++ b/src/plugins/crypto_native/crypto_native.h @@ -36,17 +36,15 @@ typedef struct extern crypto_native_main_t crypto_native_main; -clib_error_t *crypto_native_aes_cbc_init_sse42 (vlib_main_t * vm); -clib_error_t *crypto_native_aes_cbc_init_avx2 (vlib_main_t * vm); -clib_error_t *crypto_native_aes_cbc_init_avx512 (vlib_main_t * vm); -clib_error_t *crypto_native_aes_cbc_init_vaes (vlib_main_t * vm); -clib_error_t *crypto_native_aes_cbc_init_neon (vlib_main_t * vm); - -clib_error_t *crypto_native_aes_gcm_init_sse42 (vlib_main_t * vm); -clib_error_t *crypto_native_aes_gcm_init_avx2 (vlib_main_t * vm); -clib_error_t *crypto_native_aes_gcm_init_avx512 (vlib_main_t * vm); -clib_error_t *crypto_native_aes_gcm_init_vaes (vlib_main_t * vm); -clib_error_t *crypto_native_aes_gcm_init_neon (vlib_main_t * vm); +#define foreach_crypto_native_march_variant _(slm) _(hsw) _(skx) _(icl) _(neon) + +#define _(v) \ +clib_error_t __clib_weak *crypto_native_aes_cbc_init_##v (vlib_main_t * vm); \ +clib_error_t __clib_weak *crypto_native_aes_gcm_init_##v (vlib_main_t * vm); \ + +foreach_crypto_native_march_variant; +#undef _ + #endif /* __crypto_native_h__ */ /* diff --git a/src/plugins/crypto_native/main.c b/src/plugins/crypto_native/main.c index 7a42e4b416b..5d6e647ed4c 100644 --- a/src/plugins/crypto_native/main.c +++ b/src/plugins/crypto_native/main.c @@ -77,39 +77,52 @@ crypto_native_init (vlib_main_t * vm) vnet_crypto_register_engine (vm, "native", 100, "Native ISA Optimized Crypto"); + if (0); #if __x86_64__ - if (clib_cpu_supports_vaes ()) - error = crypto_native_aes_cbc_init_vaes (vm); - else if (clib_cpu_supports_avx512f ()) - error = crypto_native_aes_cbc_init_avx512 (vm); - else if (clib_cpu_supports_avx2 ()) - error = crypto_native_aes_cbc_init_avx2 (vm); + else if (crypto_native_aes_cbc_init_icl && clib_cpu_supports_vaes ()) + error = crypto_native_aes_cbc_init_icl (vm); + else if (crypto_native_aes_cbc_init_skx && clib_cpu_supports_avx512f ()) + error = crypto_native_aes_cbc_init_skx (vm); + else if (crypto_native_aes_cbc_init_hsw && clib_cpu_supports_avx2 ()) + error = crypto_native_aes_cbc_init_hsw (vm); + else if (crypto_native_aes_cbc_init_slm) + error = crypto_native_aes_cbc_init_slm (vm); +#endif +#if __aarch64__ + else if (crypto_native_aes_cbc_init_neon) + error = crypto_native_aes_cbc_init_neon (vm); +#endif else - error = crypto_native_aes_cbc_init_sse42 (vm); + error = clib_error_return (0, "No AES CBC implemenation available"); if (error) goto error; +#if __x86_64__ if (clib_cpu_supports_pclmulqdq ()) { - if (clib_cpu_supports_vaes ()) - error = crypto_native_aes_gcm_init_vaes (vm); - else if (clib_cpu_supports_avx512f ()) - error = crypto_native_aes_gcm_init_avx512 (vm); - else if (clib_cpu_supports_avx2 ()) - error = crypto_native_aes_gcm_init_avx2 (vm); + if (crypto_native_aes_gcm_init_icl && clib_cpu_supports_vaes ()) + error = crypto_native_aes_gcm_init_icl (vm); + else if (crypto_native_aes_gcm_init_skx && clib_cpu_supports_avx512f ()) + error = crypto_native_aes_gcm_init_skx (vm); + else if (crypto_native_aes_gcm_init_hsw && clib_cpu_supports_avx2 ()) + error = crypto_native_aes_gcm_init_hsw (vm); + else if (crypto_native_aes_gcm_init_slm) + error = crypto_native_aes_gcm_init_slm (vm); else - error = crypto_native_aes_gcm_init_sse42 (vm); + error = clib_error_return (0, "No AES GCM implemenation available"); if (error) goto error; } #endif #if __aarch64__ - if ((error = crypto_native_aes_cbc_init_neon (vm))) - goto error; + if (crypto_native_aes_gcm_init_neon) + error = crypto_native_aes_gcm_init_neon (vm); + else + error = clib_error_return (0, "No AES GCM implemenation available"); - if ((error = crypto_native_aes_gcm_init_neon (vm))) + if (error) goto error; #endif |