Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Nov 2021 19:00:02 GMT
From:      Allan Jude <allanjude@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 8ffcfb399b20 - releng/12.3 - openssl: Fix detection of ARMv7 and ARM64 CPU features
Message-ID:  <202111221900.1AMJ02MB054999@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch releng/12.3 has been updated by allanjude:

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

commit 8ffcfb399b20f027cb50afe41c7f83c52c008191
Author:     Allan Jude <allanjude@FreeBSD.org>
AuthorDate: 2021-11-19 15:14:30 +0000
Commit:     Allan Jude <allanjude@FreeBSD.org>
CommitDate: 2021-11-22 18:59:32 +0000

    openssl: Fix detection of ARMv7 and ARM64 CPU features
    
    OpenSSL assumes the same value for AT_HWCAP=16 (Linux)
    So it ends up calling elf_auxv_info() with AT_CANARY which
    returns ENOENT, and all acceleration features are disabled.
    
    With this, my ARM64 test machine runs the benchmark
    `openssl speed -evp aes-256-gcm` nearly 20x faster
    going from 100 MB/sec to 2000 MB/sec
    
    It also improves sha256 from 300 MB/sec to 1800 MB/sec
    
    This fix has been accepted but not yet merged upstream:
    https://github.com/openssl/openssl/pull/17082
    
    PR:             259937
    Reviewed by:    manu, imp
    Approved by:    re (gjb)
    Relnotes:       yes
    Fixes:          88e852c0b5c872b1a ("OpenSSL: Merge OpenSSL 1.1.1j")
    Sponsored by:   Ampere Computing LLC
    Sponsored by:   Klara Inc.
    Differential Revision:  https://reviews.freebsd.org/D33060
    
    (cherry picked from commit d9bb798725cfce9c72b80440659b48e8668eb10d)
    (cherry picked from commit 0ed191d116f511c1e67338f05386d87aad53076f)
---
 crypto/openssl/crypto/armcap.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/crypto/openssl/crypto/armcap.c b/crypto/openssl/crypto/armcap.c
index c5685bde5891..48c5d4d64e32 100644
--- a/crypto/openssl/crypto/armcap.c
+++ b/crypto/openssl/crypto/armcap.c
@@ -106,20 +106,23 @@ static unsigned long getauxval(unsigned long key)
  * ARM puts the feature bits for Crypto Extensions in AT_HWCAP2, whereas
  * AArch64 used AT_HWCAP.
  */
+# ifndef AT_HWCAP
+#  define AT_HWCAP               16
+# endif
+# ifndef AT_HWCAP2
+#  define AT_HWCAP2              26
+# endif
 # if defined(__arm__) || defined (__arm)
-#  define HWCAP                  16
-                                  /* AT_HWCAP */
+#  define HWCAP                  AT_HWCAP
 #  define HWCAP_NEON             (1 << 12)
 
-#  define HWCAP_CE               26
-                                  /* AT_HWCAP2 */
+#  define HWCAP_CE               AT_HWCAP2
 #  define HWCAP_CE_AES           (1 << 0)
 #  define HWCAP_CE_PMULL         (1 << 1)
 #  define HWCAP_CE_SHA1          (1 << 2)
 #  define HWCAP_CE_SHA256        (1 << 3)
 # elif defined(__aarch64__)
-#  define HWCAP                  16
-                                  /* AT_HWCAP */
+#  define HWCAP                  AT_HWCAP
 #  define HWCAP_NEON             (1 << 1)
 
 #  define HWCAP_CE               HWCAP



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202111221900.1AMJ02MB054999>