Blame SOURCES/0001-os-detect-PMULL-support-before-enabling-accelerated-.patch

1803c1
From 3721c7fe276dbbc93e584359f87913e58f96626e Mon Sep 17 00:00:00 2001
1803c1
From: Sitsofe Wheeler <sitsofe@yahoo.com>
1803c1
Date: Mon, 6 Dec 2021 20:02:53 +0000
1803c1
Subject: [PATCH] os: detect PMULL support before enabling accelerated crc32c
1803c1
 on ARM
1803c1
1803c1
Issue #1239 shows a crash on a FUJITSU/A64FX ARM platform at the
1803c1
following line:
1803c1
1803c1
crc/crc32c-arm64.c:
1803c1
 64                 t1 = (uint64_t)vmull_p64(crc1, k2);
1803c1
1803c1
On armv8 PMULL crypto instructions like vmull_p64 are defined as
1803c1
optional (see
1803c1
https://github.com/google/crc32c/pull/6#issuecomment-328713398 and
1803c1
https://github.com/dotnet/runtime/issues/35143#issuecomment-617263508 ).
1803c1
1803c1
Avoid the crash by gating use of the hardware accelerated ARM crc32c
1803c1
path behind runtime detection of PMULL.
1803c1
1803c1
Fixes: https://github.com/axboe/fio/issues/1239
1803c1
1803c1
Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
1803c1
Tested-by: Yi Zhang <yi.zhang@redhat.com>
1803c1
Signed-off-by: Pavel Reichl <preichl@redhat.com>
1803c1
---
1803c1
 os/os-linux.h | 6 +++++-
1803c1
 1 file changed, 5 insertions(+), 1 deletion(-)
1803c1
1803c1
diff --git a/os/os-linux.h b/os/os-linux.h
1803c1
index 808f1d02..3001140c 100644
1803c1
--- a/os/os-linux.h
1803c1
+++ b/os/os-linux.h
1803c1
@@ -20,6 +20,9 @@
1803c1
 
1803c1
 #ifdef ARCH_HAVE_CRC_CRYPTO
1803c1
 #include <sys/auxv.h>
1803c1
+#ifndef HWCAP_PMULL
1803c1
+#define HWCAP_PMULL             (1 << 4)
1803c1
+#endif /* HWCAP_PMULL */
1803c1
 #ifndef HWCAP_CRC32
1803c1
 #define HWCAP_CRC32             (1 << 7)
1803c1
 #endif /* HWCAP_CRC32 */
1803c1
@@ -405,7 +408,8 @@ static inline bool os_cpu_has(cpu_features feature)
1803c1
 #ifdef ARCH_HAVE_CRC_CRYPTO
1803c1
 	case CPU_ARM64_CRC32C:
1803c1
 		hwcap = getauxval(AT_HWCAP);
1803c1
-		have_feature = (hwcap & HWCAP_CRC32) != 0;
1803c1
+		have_feature = (hwcap & (HWCAP_PMULL | HWCAP_CRC32)) ==
1803c1
+			       (HWCAP_PMULL | HWCAP_CRC32);
1803c1
 		break;
1803c1
 #endif
1803c1
 	default:
1803c1
-- 
1803c1
2.38.1
1803c1