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 E897AAC0DA2 for ; Tue, 21 Nov 2023 08:48:50 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=LfkLIMVG0QyTT2k/sye85nxqyGEg+A+nIrnpyMwHXeY=; 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=1700556529; v=1; b=PDEjdCpJA8ZgCyUVLGu2L4nZYVwOsdsYz5mGGDd56driEg3Ipy4othYwrCCB7ZCz55ZstnJ3 +zA91Ya2Aj1dwlGuZigf6oSafTv/A2tpIFNCVUvHGMQtG92umBktmNkxnZYOuos/tsvCkM/3YvF GTeK7p99ue+X3f4YOnXa1PF8= X-Received: by 127.0.0.2 with SMTP id BReIYY7687511xPdAg0q8S8t; Tue, 21 Nov 2023 00:48:49 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.33792.1700556528467348085 for ; Tue, 21 Nov 2023 00:48:48 -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 2F1FFFEC; Tue, 21 Nov 2023 00:49:34 -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 333803F73F; Tue, 21 Nov 2023 00:48:46 -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 v5 0/6] CryptoPkg: Enable Openssl native instruction support for AARCH64 Date: Tue, 21 Nov 2023 09:47:09 +0100 Message-Id: <20231121084715.1393672-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: I9xykEKvNxo131Vl7YPvuoEPx7686176AA= 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=PDEjdCpJ; 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 v5: - [PATCH v5 1/6] ArmPkg/ArmLib: Add macros/helper functions around AA64Is= ar0 register - Remove unused ArmReadIdAA64Isar0() declaration - [PATCH v4 5/6] CryptoPkg/OpensslLib: Add AArch64Cap for arch specific h= ooks - Removed unused GET_BITFIELD() macro - Indentation v4: - Added Acked-by from Gerd - Created bugzilla at: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4601 - Replaced: - [PATCH v3 1/6] ArmPkg/ArmLib: Move ArmReadIdAA64Isar0() to ArmLib by: - [PATCH v4 1/6] ArmPkg/ArmLib: Add macros/helper functions around AA64= Isar0 register and: - Moved ARM_ID_AA64ISAR0_EL1_* macros to ArmPkg/Include/Chipset/AArch64= .h - Added macros to get capabilities described in AA64ISAR0 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: Add macros/helper functions around AA64Isar0 register 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/Chipset/AArch64.h | 60 +- ArmPkg/Include/Library/ArmLib.h | 218 +- ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c | 367 + 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 | 66 + CryptoPkg/Library/OpensslLib/UefiAsm.conf | 6 + CryptoPkg/Library/OpensslLib/configure.py | 6 +- CryptoPkg/Readme.md | 14 +- 22 files changed, 25770 insertions(+), 23 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 (#111533): https://edk2.groups.io/g/devel/message/111533 Mute This Topic: https://groups.io/mt/102725176/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-