public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH v5 0/6] CryptoPkg: Enable Openssl native instruction support for AARCH64
@ 2023-11-21  8:47 PierreGondois
  2023-11-21  8:47 ` [edk2-devel] [PATCH v5 1/6] ArmPkg/ArmLib: Add macros/helper functions around AA64Isar0 register PierreGondois
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: PierreGondois @ 2023-11-21  8:47 UTC (permalink / raw)
  To: devel
  Cc: Jiewen Yao, Yi Li, Xiaoyu Lu, Guomin Jiang, Leif Lindholm,
	Ard Biesheuvel, Sami Mujawar, Gerd Hoffmann

v5:
- [PATCH v5 1/6] ArmPkg/ArmLib: Add macros/helper functions around AA64Isar0 register
  - Remove unused ArmReadIdAA64Isar0() declaration
- [PATCH v4 5/6] CryptoPkg/OpensslLib: Add AArch64Cap for arch specific hooks
  - Removed unused GET_BITFIELD() macro
  - Indentation

v4:
- Added Acked-by from Gerd
- Created bugzilla at:
  https://bugzilla.tianocore.org/show_bug.cgi?id=4601
- Replaced:
  - [PATCH v3 1/6] ArmPkg/ArmLib: Move ArmReadIdAA64Isar0() to ArmLib
  by:
  - [PATCH v4 1/6] ArmPkg/ArmLib: Add macros/helper functions around AA64Isar0 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() over 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=false, ~1000 iterations when safe=true.

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 |   Accel (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 |   3502629757 |  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/crypto/aes/aesv8-armx.S
 create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/crypto/aes/vpaes-armv8.S
 create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/crypto/arm64cpuid.S
 create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/crypto/bn/armv8-mont.S
 create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/crypto/ec/ecp_nistz256-armv8.S
 create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/crypto/modes/aes-gcm-armv8_64.S
 create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/crypto/modes/ghashv8-armx.S
 create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/crypto/sha/keccak1600-armv8.S
 create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/crypto/sha/sha1-armv8.S
 create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/crypto/sha/sha256-armv8.S
 create mode 100644 CryptoPkg/Library/OpensslLib/OpensslGen/AARCH64-GCC/crypto/sha/sha512-armv8.S
 create mode 100644 CryptoPkg/Library/OpensslLib/OpensslStub/AArch64Cap.c

-- 
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]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-11-21 16:26 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-21  8:47 [edk2-devel] [PATCH v5 0/6] CryptoPkg: Enable Openssl native instruction support for AARCH64 PierreGondois
2023-11-21  8:47 ` [edk2-devel] [PATCH v5 1/6] ArmPkg/ArmLib: Add macros/helper functions around AA64Isar0 register PierreGondois
2023-11-21  8:47 ` [edk2-devel] [PATCH v5 2/6] CryptoPkg/CryptoPkg.ci.yaml: Allow dependency upon ArmPkg PierreGondois
2023-11-21 11:27   ` Yao, Jiewen
2023-11-21 12:59     ` PierreGondois
2023-11-21 13:41       ` Yao, Jiewen
2023-11-21 14:26         ` Leif Lindholm
2023-11-21 14:46           ` Yao, Jiewen
2023-11-21 15:55             ` Leif Lindholm
2023-11-21 16:02               ` Ard Biesheuvel
2023-11-21 16:26                 ` Yao, Jiewen
2023-11-21  8:47 ` [edk2-devel] [PATCH v5 3/6] CryptoPkg/OpensslLib: Add native instruction support for AARCH64 PierreGondois
2023-11-21  8:47 ` [edk2-devel] [PATCH v5 4/6] CryptoPkg/OpensslLib: Generate files for AARCH64 native support PierreGondois
2023-11-21  8:47 ` [edk2-devel] [PATCH v5 5/6] CryptoPkg/OpensslLib: Add AArch64Cap for arch specific hooks PierreGondois
2023-11-21  8:47 ` [edk2-devel] [PATCH v5 6/6] CryptoPkg: Enable Openssl Accel builds for AARCH64 PierreGondois
2023-11-21 16:22 ` [edk2-devel] [PATCH v5 0/6] CryptoPkg: Enable Openssl native instruction support " Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox