From 2dcc65fedcffc26e20871b67fb3cbb05a579f48f Mon Sep 17 00:00:00 2001 From: Adam Kupczyk Date: Wed, 23 May 2018 15:06:19 +0200 Subject: [PATCH] common/crc/aarch64: Added cpu feature pmull and make aarch64 specific crc function to depend on it. Signed-off-by: Adam Kupczyk (cherry picked from commit 90b1c1f1c4a57a59f598cd93dc9ce8a1532db238) --- src/arch/arm.c | 4 ++-- src/arch/arm.h | 1 + src/common/crc32c_aarch64.c | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/arch/arm.c b/src/arch/arm.c index a8562f5967416..c017b5d4d928a 100644 --- a/src/arch/arm.c +++ b/src/arch/arm.c @@ -4,6 +4,7 @@ /* flags we export */ int ceph_arch_neon = 0; int ceph_arch_aarch64_crc32 = 0; +int ceph_arch_aarch64_pmull = 0; #include @@ -46,9 +47,8 @@ int ceph_arch_arm_probe(void) ceph_arch_neon = (get_hwcap() & HWCAP_NEON) == HWCAP_NEON; #elif __aarch64__ && __linux__ ceph_arch_neon = (get_hwcap() & HWCAP_ASIMD) == HWCAP_ASIMD; -# if defined(HAVE_ARMV8_CRC) && defined(HWCAP_CRC32) ceph_arch_aarch64_crc32 = (get_hwcap() & HWCAP_CRC32) == HWCAP_CRC32; -# endif + ceph_arch_aarch64_pmull = (get_hwcap() & HWCAP_PMULL) == HWCAP_PMULL; #else if (0) get_hwcap(); // make compiler shut up diff --git a/src/arch/arm.h b/src/arch/arm.h index 1659b2e94dec4..dacc450b18f07 100644 --- a/src/arch/arm.h +++ b/src/arch/arm.h @@ -7,6 +7,7 @@ extern "C" { extern int ceph_arch_neon; /* true if we have ARM NEON or ASIMD abilities */ extern int ceph_arch_aarch64_crc32; /* true if we have AArch64 CRC32/CRC32C abilities */ +extern int ceph_arch_aarch64_pmull; /* true if we have AArch64 PMULL abilities */ extern int ceph_arch_arm_probe(void); diff --git a/src/common/crc32c_aarch64.c b/src/common/crc32c_aarch64.c index e4fbf23a7602a..d15736a0cd9d0 100644 --- a/src/common/crc32c_aarch64.c +++ b/src/common/crc32c_aarch64.c @@ -1,6 +1,7 @@ #include "acconfig.h" #include "include/int_types.h" #include "common/crc32c_aarch64.h" +#include "arch/arm.h" #ifndef HAVE_ARMV8_CRC_CRYPTO_INTRINSICS /* Request crc extension capabilities from the assembler */ @@ -96,6 +97,7 @@ uint32_t ceph_crc32c_aarch64(uint32_t crc, unsigned char const *buffer, unsigned if (buffer) { #ifdef HAVE_ARMV8_CRYPTO + if (ceph_arch_aarch64_pmull) { #ifdef HAVE_ARMV8_CRC_CRYPTO_INTRINSICS /* Calculate reflected crc with PMULL Instruction */ const poly64_t k1 = 0xe417f38a, k2 = 0x8f158014; @@ -183,7 +185,7 @@ uint32_t ceph_crc32c_aarch64(uint32_t crc, unsigned char const *buffer, unsigned if(!(length += 1024)) return crc; - + } #endif /* HAVE_ARMV8_CRYPTO */ while ((length -= sizeof(uint64_t)) >= 0) { CRC32CX(crc, *(uint64_t *)buffer); @@ -203,6 +205,7 @@ uint32_t ceph_crc32c_aarch64(uint32_t crc, unsigned char const *buffer, unsigned CRC32CB(crc, *buffer); } else { #ifdef HAVE_ARMV8_CRYPTO + if (ceph_arch_aarch64_pmull) { #ifdef HAVE_ARMV8_CRC_CRYPTO_INTRINSICS const poly64_t k1 = 0xe417f38a; uint64_t t0; @@ -250,7 +253,7 @@ uint32_t ceph_crc32c_aarch64(uint32_t crc, unsigned char const *buffer, unsigned if(!(length += 1024)) return crc; - + } #endif /* HAVE_ARMV8_CRYPTO */ while ((length -= sizeof(uint64_t)) >= 0) CRC32CX(crc, 0); -- 2.39.5