Blame SOURCES/0001-fio-os-detect-pmull-suooprt-on-arm.patch

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