The diff below should enable aarch64 hardware crypto support in
security/gnutls.

The regression test results are the same before and after on my
OverDrive 1000 (cpu0: CRC32,SHA2,SHA1,AES+PMULL,ASID16).
(3 failures, 2 of which are due to unportable diff(1) options...)

ok?

Index: Makefile
===================================================================
RCS file: /cvs/ports/security/gnutls/Makefile,v
retrieving revision 1.173
diff -u -p -r1.173 Makefile
--- Makefile    18 Mar 2022 23:22:23 -0000      1.173
+++ Makefile    2 Apr 2022 23:56:35 -0000
@@ -2,6 +2,7 @@ COMMENT=                GNU Transport Layer Security l
 
 V=                     3.7.4
 DISTNAME=              gnutls-${V}
+REVISION=              0
 EXTRACT_SUFX=          .tar.xz
 
 CATEGORIES=            security
Index: patches/patch-lib_accelerated_aarch64_aarch64-common_c
===================================================================
RCS file: patches/patch-lib_accelerated_aarch64_aarch64-common_c
diff -N patches/patch-lib_accelerated_aarch64_aarch64-common_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-lib_accelerated_aarch64_aarch64-common_c      2 Apr 2022 
23:56:35 -0000
@@ -0,0 +1,42 @@
+Index: lib/accelerated/aarch64/aarch64-common.c
+
+Enable aarch64 hardware crypto support.
+
+--- lib/accelerated/aarch64/aarch64-common.c.orig
++++ lib/accelerated/aarch64/aarch64-common.c
+@@ -41,6 +41,10 @@
+ # ifdef AT_HWCAP
+ #  define USE_AUXVAL
+ # endif
++#elif defined(__OpenBSD__)
++# include <sys/sysctl.h>
++# include <machine/cpu.h>
++# include <machine/armreg.h>
+ #endif
+ 
+ #if defined(__GNUC__)
+@@ -93,6 +97,24 @@ static void discover_caps(unsigned int *caps)
+       if (c & HWCAP_SHA2)
+               *caps |= ARMV8_SHA256;
+       if (c & HWCAP_SHA512)
++              *caps |= ARMV8_SHA512;
++#elif defined(__OpenBSD__)
++      const int isar0_mib[] = { CTL_MACHDEP, CPU_ID_AA64ISAR0 };
++      uint64_t isar0;
++      size_t len = sizeof(isar0);
++
++      *caps |= ARMV7_NEON;
++      if (sysctl(isar0_mib, 2, &isar0, &len, NULL, 0) < 0)
++              return;
++      if (ID_AA64ISAR0_AES(isar0) >= ID_AA64ISAR0_AES_BASE)
++              *caps |= ARMV8_AES;
++      if (ID_AA64ISAR0_AES(isar0) >= ID_AA64ISAR0_AES_PMULL)
++              *caps |= ARMV8_PMULL;
++      if (ID_AA64ISAR0_SHA1(isar0) >= ID_AA64ISAR0_SHA1_BASE)
++              *caps |= ARMV8_SHA1;
++      if (ID_AA64ISAR0_SHA2(isar0) >= ID_AA64ISAR0_SHA2_BASE)
++              *caps |= ARMV8_SHA256;
++      if (ID_AA64ISAR0_SHA2(isar0) >= ID_AA64ISAR0_SHA2_512)
+               *caps |= ARMV8_SHA512;
+ #endif
+ }
-- 
Christian "naddy" Weisgerber                          na...@mips.inka.de

Reply via email to