From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id C5DC9AC1071 for ; Fri, 10 Nov 2023 10:48:25 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=cnE0bSOQdegRK3Jy4EccgE7rS9/a5QWWA9jmIxV4/xE=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1699613304; v=1; b=V2GUHLpWk03wcOPyZbilivsf4VtUQk2zyrn+3e7Sjkyyr2w4RMVUn1P20Km1CUfD+rRrTqTH hWsgKC6q9hKWIG7ATBCWldGUxzoYlijlHTA6u6lSqkxZOn5FXYABp2Pe9alVNFHYQDJb/zAEqpW bb4xI0KBd18EPVEQ2k1OnuRI= X-Received: by 127.0.0.2 with SMTP id N5CcYY7687511xFvUpfTrhVP; Fri, 10 Nov 2023 02:48:24 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.24739.1699613303458989549 for ; Fri, 10 Nov 2023 02:48:23 -0800 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 92BFA106F; Fri, 10 Nov 2023 02:49:07 -0800 (PST) X-Received: from e126645.arm.com (unknown [10.57.82.190]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 174B33F7C5; Fri, 10 Nov 2023 02:48:20 -0800 (PST) From: "PierreGondois" To: devel@edk2.groups.io Cc: Jiewen Yao , Yi Li , Xiaoyu Lu , Guomin Jiang , Leif Lindholm , Ard Biesheuvel , Sami Mujawar , Gerd Hoffmann Subject: [edk2-devel] [PATCH v3 0/6] CryptoPkg: Enable Openssl native instruction support for AARCH64 Date: Fri, 10 Nov 2023 11:48:04 +0100 Message-Id: <20231110104810.2038376-1-pierre.gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: S73D4Sq09nlUrfvo3b88ogBMx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=V2GUHLpW; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io v3: - Use ArmPkg's function to access register: - Dropped: - [PATCH v2 1/7] MdePkg/BaseLib: AARCH64: Add ArmReadCntPctReg() - [PATCH v2 2/7] MdePkg/BaseLib: AARCH64: Add ArmReadIdAA64Isar0Reg() - [PATCH v2 3/7] MdePkg/BaseRngLib: Prefer ArmReadIdAA64Isar0Reg() ov= er ArmReadIdIsar0() - Added: - [PATCH v3 1/6] ArmPkg/ArmLib: Move ArmReadIdAA64Isar0() to ArmLib - Allow dependency of CryptoPkg over ArmPkg in CI: - Added: - [PATCH v3 2/6] CryptoPkg/CryptoPkg.ci.yaml: Allow dependency upon v2: - [PATCH v2 2/7] MdePkg/BaseLib: AARCH64: Add ArmReadIdAA64Isar0Reg() - Correct bad mask values in MdePkg/Include/Library/BaseLib.h - [PATCH v2 4/7] CryptoPkg/OpensslLib: Add native instruction support: - Add armcap.c to configure.py:sources_filter_fn() instead of manually commenting the file in .inf files Various OpensslLib implementations are available in edk2. The OpensslLibAccel.inf and OpensslLibFullAccel.inf ones use architecture specific instructions, e.g. AESE, PMULL, SHA256H, ..., allowing to improve speed. Enable support for Aarch64's native instructions: - Add ArmReadCntPctReg() and ArmReadIdAA64Isar0Reg() to Aarch64's BaseLib. - Generate Aarch64's specific Openssl functions. - Add a OpensslStub/AArch64Cap.c file to allow Openssl to probe Aarch64 native instruction support. This patch-set only enable support for GCC for now (MSFT support not added). ---- Testing ---- The tests run are based on the TestBaseCryptLibShell module. Each test is run 100 times, then the first 5 values (considered as warmup) are removed. The NoAccel column relies on the OpensslLibFull implementation, the Accel column relies on the OpensslLibFullAccel implementation. The 'Improvement' column is computed as: 100 * ('Accel (ns)' - 'NoAccel (ns)') / 'NoAccel (ns)' The std deviation of the TestVerifyDhGenerateKey is big. It is due to [1] being called with the 'safe' parameter set, leading to the prime number taking more time to generate. It requires ~10 iterations when safe=3Dfalse, ~1000 iterations when safe=3Dtrue. The test was run on a Juno-r2. The native Openssl implementation makes use of the following features (cf. [2]): - ARMV7_NEON - ARMV8_AES - ARMV8_SHA1 - ARMV8_PMULL - ARMV8_SHA256 and misses: - ARMV8_SHA512 | TestName | NoAccel (ns) | NoAccel std | A= ccel (ns) | Accel std | Improvement | |:---------------------------------|---------------:|--------------:|----= ---------:|------------:|--------------:| | mPkcs7EkuTest | 14757511 | 14370 | = 14947276 | 35677 | 1.28589 | | mAeadAesGcmTest | 129667 | 2012 | = 113897 | 1366 | -12.1619 | | mBlockCipherTest | 7325 | 102 | = 6487 | 81 | -11.4403 | | mAuthenticodeTest | 72852444 | 3097832 | = 67593102 | 3123627 | -7.21917 | | mBnTest | 771921 | 57966 | = 737656 | 61354 | -4.43893 | | mDhTest | 4082083501 | 3340300622 | 3= 502629757 | 3444890110 | -14.195 | | mEcTest | 24666075 | 191971 | = 23250301 | 178985 | -5.73976 | | mHkdfTest | 848440 | 4295 | = 797966 | 4320 | -5.94904 | | mHmacTest | 235527 | 36284 | = 204823 | 37936 | -13.0363 | | mImageTimestampTest | 12801070 | 18327 | = 12190046 | 23138 | -4.77323 | | mOaepTest | 20032245 | 46525 | = 18671388 | 36399 | -6.79333 | | mPkcs5Test | 178624 | 1962 | = 114852 | 1376 | -35.7018 | | mPkcs7Test | 28464572 | 70683 | = 25282753 | 82616 | -11.1782 | | mPrngTest | 727013 | 3637 | = 460076 | 2668 | -36.717 | | mRsaCertTest | 39109865 | 90380 | = 36452412 | 220712 | -6.79484 | | mRsaTest | 22451367 | 60643 | = 16672060 | 53643 | -25.7414 | | mRsaPssTest | 142051533 | 122172 | = 98638975 | 99131 | -30.5611 | | mHashTest | 22033 | 6308 | = 17650 | 6622 | -19.8929 | | mX509Test | 53796289 | 123676 | = 51280121 | 187588 | -4.67721 | Pierre Gondois (6): ArmPkg/ArmLib: Move ArmReadIdAA64Isar0() to ArmLib CryptoPkg/CryptoPkg.ci.yaml: Allow dependency upon ArmPkg CryptoPkg/OpensslLib: Add native instruction support for AARCH64 CryptoPkg/OpensslLib: Generate files for AARCH64 native support CryptoPkg/OpensslLib: Add AArch64Cap for arch specific hooks CryptoPkg: Enable Openssl Accel builds for AARCH64 ArmPkg/Include/Library/ArmLib.h | 68 + ArmPkg/Library/ArmLib/AArch64/AArch64Lib.h | 6 - CryptoPkg/CryptoPkg.ci.yaml | 1 + CryptoPkg/CryptoPkg.dsc | 23 +- .../AARCH64-GCC/crypto/aes/aesv8-armx.S | 3180 ++++++++ .../AARCH64-GCC/crypto/aes/vpaes-armv8.S | 1196 +++ .../AARCH64-GCC/crypto/arm64cpuid.S | 129 + .../AARCH64-GCC/crypto/bn/armv8-mont.S | 2124 ++++++ .../crypto/ec/ecp_nistz256-armv8.S | 4242 +++++++++++ .../crypto/modes/aes-gcm-armv8_64.S | 6389 +++++++++++++++++ .../AARCH64-GCC/crypto/modes/ghashv8-armx.S | 552 ++ .../AARCH64-GCC/crypto/sha/keccak1600-armv8.S | 1009 +++ .../AARCH64-GCC/crypto/sha/sha1-armv8.S | 1211 ++++ .../AARCH64-GCC/crypto/sha/sha256-armv8.S | 2051 ++++++ .../AARCH64-GCC/crypto/sha/sha512-armv8.S | 1606 +++++ .../Library/OpensslLib/OpensslLibAccel.inf | 647 +- .../OpensslLib/OpensslLibFullAccel.inf | 696 +- .../OpensslLib/OpensslStub/AArch64Cap.c | 107 + CryptoPkg/Library/OpensslLib/UefiAsm.conf | 6 + CryptoPkg/Library/OpensslLib/configure.py | 6 +- CryptoPkg/Readme.md | 14 +- 21 files changed, 25236 insertions(+), 27 deletions(-) create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/c= rypto/aes/aesv8-armx.S create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/c= rypto/aes/vpaes-armv8.S create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/c= rypto/arm64cpuid.S create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/c= rypto/bn/armv8-mont.S create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/c= rypto/ec/ecp_nistz256-armv8.S create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/c= rypto/modes/aes-gcm-armv8_64.S create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/c= rypto/modes/ghashv8-armx.S create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/c= rypto/sha/keccak1600-armv8.S create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/c= rypto/sha/sha1-armv8.S create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/c= rypto/sha/sha256-armv8.S create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/c= rypto/sha/sha512-armv8.S create mode 100644 CryptoPkg/Library/OpensslLib/OpensslStub/AArch64Cap.c --=20 2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111028): https://edk2.groups.io/g/devel/message/111028 Mute This Topic: https://groups.io/mt/102504417/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-