OPENSSL_cpuid_setup FreeBSD arm update.
authorDavid Carlier <devnexen@gmail.com>
Wed, 9 Dec 2020 20:23:32 +0000 (20:23 +0000)
committerMatt Caswell <matt@openssl.org>
Thu, 14 Jan 2021 08:34:38 +0000 (08:34 +0000)
when possible using the getauxval equivalent which has similar ids as Linux, instead of bad instructions catch approach.

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13650)

crypto/armcap.c

index 7bd82f8ebc48a042412ec0c8266d58f1be26dd6c..6c0acda24459bd08e96e921e5e5323954f56a02d 100644 (file)
@@ -71,6 +71,23 @@ void OPENSSL_cpuid_setup(void) __attribute__ ((constructor));
 #   define OSSL_IMPLEMENT_GETAUXVAL
 #  endif
 # endif
+# if defined(__FreeBSD__)
+#  include <sys/param.h>
+#  if __FreeBSD_version >= 1200000
+#   include <sys/auxv.h>
+#   define OSSL_IMPLEMENT_GETAUXVAL
+
+static unsigned long getauxval(unsigned long key)
+{
+  unsigned long val = 0ul;
+
+  if (elf_aux_info((int)key, &val, sizeof(val)) != 0)
+    return 0ul;
+
+  return val;
+}
+#  endif
+# endif
 
 /*
  * ARM puts the feature bits for Crypto Extensions in AT_HWCAP2, whereas