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 DEC8774004E for ; Thu, 9 Nov 2023 09:23:54 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=KUgn4UbIKciHQSsI41ZNTTyjoC9cNpo0KHhV3alU/cs=; 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=1699521833; v=1; b=P9T/yQUz9jtRkHt6l7kLVluqqJPyDGh/+rvcMAEm5kVpb8O5c6+zmH1fS14c1FwAWrz0qLLQ IXWVuPbIV/RtzxU8o0InPhMIRocZ/RQo9Hg36fNnilkiQ+bTjtP0wR2hRHYGzZ8wIMrSLFf333k ILrkITi6HIAfYbhdY8+k3UHE= X-Received: by 127.0.0.2 with SMTP id iWRBYY7687511xhInNVNE3K4; Thu, 09 Nov 2023 01:23:53 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.117370.1699521832693016004 for ; Thu, 09 Nov 2023 01:23:52 -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 1DBB012FC; Thu, 9 Nov 2023 01:24:36 -0800 (PST) X-Received: from cam-smtp0.cambridge.arm.com (e126645.nice.arm.com [10.34.100.114]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 086593F703; Thu, 9 Nov 2023 01:23:49 -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 , Michael D Kinney , Liming Gao Subject: [edk2-devel] [PATCH v2 0/7] CryptoPkg: Enable Openssl native instruction support for AARCH64 Date: Thu, 9 Nov 2023 10:23:00 +0100 Message-Id: <20231109092307.1770332-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: Z1b4qDbMErEcriXSg9yVCRnax7686176AA= 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="P9T/yQUz"; 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 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 (7): MdePkg/BaseLib: AARCH64: Add ArmReadCntPctReg() MdePkg/BaseLib: AARCH64: Add ArmReadIdAA64Isar0Reg() MdePkg/BaseRngLib: Prefer ArmReadIdAA64Isar0Reg() over ArmReadIdIsar0() 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 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 | 641 +- .../OpensslLib/OpensslLibFullAccel.inf | 690 +- .../OpensslLib/OpensslStub/AArch64Cap.c | 107 + CryptoPkg/Library/OpensslLib/UefiAsm.conf | 6 + CryptoPkg/Library/OpensslLib/configure.py | 6 +- CryptoPkg/Readme.md | 14 +- MdePkg/Include/Library/BaseLib.h | 86 + .../BaseLib/AArch64/ArmReadCntPctReg.S | 30 + .../BaseLib/AArch64/ArmReadCntPctReg.asm | 30 + .../AArch64/ArmReadIdAA64Isar0Reg.S} | 10 +- .../AArch64/ArmReadIdAA64Isar0Reg.asm} | 10 +- MdePkg/Library/BaseLib/BaseLib.inf | 6 +- MdePkg/Library/BaseRngLib/AArch64/ArmRng.h | 12 - MdePkg/Library/BaseRngLib/AArch64/Rndr.c | 14 +- MdePkg/Library/BaseRngLib/BaseRngLib.inf | 2 - 27 files changed, 25319 insertions(+), 57 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 create mode 100644 MdePkg/Library/BaseLib/AArch64/ArmReadCntPctReg.S create mode 100644 MdePkg/Library/BaseLib/AArch64/ArmReadCntPctReg.asm rename MdePkg/Library/{BaseRngLib/AArch64/ArmReadIdIsar0.S =3D> BaseLib/= AArch64/ArmReadIdAA64Isar0Reg.S} (70%) rename MdePkg/Library/{BaseRngLib/AArch64/ArmReadIdIsar0.asm =3D> BaseLi= b/AArch64/ArmReadIdAA64Isar0Reg.asm} (72%) --=20 2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110953): https://edk2.groups.io/g/devel/message/110953 Mute This Topic: https://groups.io/mt/102482398/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-