git: cd61eb4f6681 - main - zfs: Wire sha512 offload to the build

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Thu, 02 Jul 2026 18:02:33 UTC
The branch main has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=cd61eb4f6681b13d98b6a7be252500ad30f05f74

commit cd61eb4f6681b13d98b6a7be252500ad30f05f74
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2026-07-02 17:58:12 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2026-07-02 17:58:12 +0000

    zfs: Wire sha512 offload to the build
    
    FreeBSD main just got the CPUID_STDEXT4_SHA512 define.
    
    OpenZFS PR #18732
---
 sys/conf/kern.pre.mk                                      |  3 +--
 sys/contrib/openzfs/include/os/freebsd/spl/sys/simd_x86.h | 14 ++++++++++++++
 sys/contrib/openzfs/module/Makefile.bsd                   |  2 +-
 sys/modules/zfs/Makefile                                  |  2 +-
 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk
index 19a7b45f4b6a..81108f29f0bb 100644
--- a/sys/conf/kern.pre.mk
+++ b/sys/conf/kern.pre.mk
@@ -212,8 +212,7 @@ ZFS_CFLAGS+=	-I$S/contrib/openzfs/module/icp/include \
 ZFS_CFLAGS+= -D__x86_64 -DHAVE_TOOLCHAIN_SSE2 -DHAVE_TOOLCHAIN_SSSE3 \
 	-DHAVE_TOOLCHAIN_SSE4_1 -DHAVE_TOOLCHAIN_AVX -DHAVE_TOOLCHAIN_AVX2 \
 	-DHAVE_TOOLCHAIN_AVX512F -DHAVE_TOOLCHAIN_AVX512VL \
-	-DHAVE_TOOLCHAIN_AVX512BW \
-	-DHAVE_TOOLCHAIN_VAES -DHAVE_TOOLCHAIN_VPCLMULQDQ
+	-DHAVE_TOOLCHAIN_AVX512BW -DHAVE_TOOLCHAIN_SHA512EXT
 .endif
 
 .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "powerpc" || \
diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/simd_x86.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/simd_x86.h
index c562fb0171d0..ced6ac1f9eab 100644
--- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/simd_x86.h
+++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/simd_x86.h
@@ -191,6 +191,20 @@ zfs_shani_available(void)
 	return (has_shani && __ymm_enabled());
 }
 
+/*
+ * Check if SHA-512 extension is available
+ */
+static inline boolean_t
+zfs_sha512ext_available(void)
+{
+#if defined(CPUID_STDEXT4_SHA512)
+	return ((cpu_stdext_feature4 & CPUID_STDEXT4_SHA512) != 0 &&
+	    __ymm_enabled());
+#else
+	return (B_FALSE);
+#endif
+}
+
 /*
  * AVX-512 family of instruction sets:
  *
diff --git a/sys/contrib/openzfs/module/Makefile.bsd b/sys/contrib/openzfs/module/Makefile.bsd
index a0ddbeb9ae68..436b090d9a00 100644
--- a/sys/contrib/openzfs/module/Makefile.bsd
+++ b/sys/contrib/openzfs/module/Makefile.bsd
@@ -50,7 +50,7 @@ CFLAGS+= -D__KERNEL__ -DFREEBSD_NAMECACHE -DBUILDING_ZFS -D__BSD_VISIBLE=1 \
 CFLAGS+= -D__x86_64 -DHAVE_TOOLCHAIN_SSE2 -DHAVE_TOOLCHAIN_SSSE3 \
 	-DHAVE_TOOLCHAIN_SSE4_1 -DHAVE_TOOLCHAIN_AVX -DHAVE_TOOLCHAIN_AVX2 \
 	-DHAVE_TOOLCHAIN_AVX512F -DHAVE_TOOLCHAIN_AVX512VL \
-	-DHAVE_TOOLCHAIN_AVX512BW
+	-DHAVE_TOOLCHAIN_AVX512BW -DHAVE_TOOLCHAIN_SHA512EXT
 .endif
 
 .if defined(WITH_DEBUG) && ${WITH_DEBUG} == "true"
diff --git a/sys/modules/zfs/Makefile b/sys/modules/zfs/Makefile
index 44a63977f288..32231d10a99a 100644
--- a/sys/modules/zfs/Makefile
+++ b/sys/modules/zfs/Makefile
@@ -42,7 +42,7 @@ CFLAGS+= -D__KERNEL__ -DFREEBSD_NAMECACHE -DBUILDING_ZFS -D__BSD_VISIBLE=1 \
 CFLAGS+= -D__x86_64 -DHAVE_TOOLCHAIN_SSE2 -DHAVE_TOOLCHAIN_SSSE3 \
 	-DHAVE_TOOLCHAIN_SSE4_1 -DHAVE_TOOLCHAIN_AVX -DHAVE_TOOLCHAIN_AVX2 \
 	-DHAVE_TOOLCHAIN_AVX512F -DHAVE_TOOLCHAIN_AVX512VL \
-	-DHAVE_TOOLCHAIN_AVX512BW
+	-DHAVE_TOOLCHAIN_AVX512BW -DHAVE_TOOLCHAIN_SHA512EXT
 .endif
 
 .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "powerpc" || \