summaryrefslogtreecommitdiff
path: root/mysys/crc32
diff options
context:
space:
mode:
authorKrunal Bauskar <krunalbauskar@gmail.com>2020-07-29 23:27:25 +0800
committerMarko Mäkelä <marko.makela@mariadb.com>2020-07-30 15:44:54 +0300
commitc69520c9dfa6e4a26258842a1d3512c2b5d43d56 (patch)
treea3e5ddc790364cbf17efb0339010e3d0e95db980 /mysys/crc32
parentf99de8915e8f9109384d1f197ca69c747487cb48 (diff)
downloadmariadb-git-c69520c9dfa6e4a26258842a1d3512c2b5d43d56.tar.gz
MDEV-23030: ARM crash on Raspberry Pi 4
MariaDB adopted a hardware optimized crc32c approach on ARM64 starting 10.5. Said implementation of crc32c needs support from target hardware for crc32 and pmull instructions. Existing logic is checking only for crc32 support from target hardware through a runtime check and so if target hardware doesn't support pmull it would cause things to fail/crash. Expanded runtime check to ensure pmull support is also checked on the target hardware along with existing crc32. Thanks to Marko and Daniel for review.
Diffstat (limited to 'mysys/crc32')
-rw-r--r--mysys/crc32/crc32_arm64.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/mysys/crc32/crc32_arm64.c b/mysys/crc32/crc32_arm64.c
index 09ac7a12a66..aae6f769002 100644
--- a/mysys/crc32/crc32_arm64.c
+++ b/mysys/crc32/crc32_arm64.c
@@ -18,8 +18,21 @@ int crc32_aarch64_available(void)
unsigned long auxv= getauxval(AT_HWCAP);
return (auxv & HWCAP_CRC32) != 0;
}
+
+#if defined(HAVE_ARMV8_CRYPTO)
+
+#ifndef HWCAP_PMULL
+#define HWCAP_PMULL (1 << 4)
#endif
+/* Check if target ARM machine support crc32 + pmull for computing crc32c */
+int crc32c_aarch64_available(void)
+{
+ return !(~getauxval(AT_HWCAP) & (HWCAP_CRC32 | HWCAP_PMULL));
+}
+#endif /* HAVE_ARMV8_CRYPTO */
+#endif /* HAVE_ARMV8_CRC */
+
#ifndef HAVE_ARMV8_CRC_CRYPTO_INTRINSICS
/* Request crc extension capabilities from the assembler */