GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — CryptoPkg: Enable Openssl native instruction support for AARCH64 by pierregondois · Pull Request #5977 · tianocore/edk2

Conversation

@pierregondois

@pierregondois pierregondois commented Jul 25, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Description

CryptoPkg: Enable Openssl native instruction support for AARCH64

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).

  • Breaking change?
    • Breaking change - Does this PR cause a break in build or boot behavior?
    • Examples: Does it add a new library class or move a module to a different repo.
  • Impacts security?
    • Security - Does this PR have a direct security impact?
    • Examples: Crypto algorithm change or buffer overflow fix.
  • Includes tests?
    • Tests - Does this PR include any explicit test code?
    • Examples: Unit tests or integration tests.

How This Was Tested

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

Note that in order to run the test without exiting too early and actually
see an improvement in the running time, the UT_ASSERT_* macros were bypassed.

See the attached file for the result.
openssl_native_aarch64.txt

Integration Instructions

N/A

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pierregondois
pierregondois force-pushed the pg/openssl_native_aarch64 branch from 80c5874 to 411e874 Compare July 26, 2024 08:53
@pierregondois pierregondois changed the title dummy -- Pg/openssl native aarch64 CryptoPkg: Enable Openssl native instruction support for AARCH64 Jul 26, 2024
@github-actions github-actions Bot added the impact:security This change has a direct security impact such as changing a crypto algorithm. label Jul 26, 2024
@pierregondois
pierregondois requested review from ardbiesheuvel, jyao1, kraxel, leiflindholm, liyi77, mdkinney and samimujawar July 26, 2024 14:00
ardbiesheuvel
ardbiesheuvel approved these changes Jul 29, 2024
View reviewed changes
liyi77
liyi77 approved these changes Jul 29, 2024
View reviewed changes

@liyi77 liyi77 left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CryptoPkg part looks good to me.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ardbiesheuvel ardbiesheuvel mentioned this pull request Jul 29, 2024
ArmPkg: ArmGicLib: Improve ARM GIC interfaces #5739
Closed
3 tasks
ardbiesheuvel
ardbiesheuvel requested changes Jul 30, 2024
View reviewed changes
Comment thread MdePkg/Library/BaseRngLib/AArch64/Rndr.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

pierregondois added 2 commits July 30, 2024 12:36
@pierregondois
MdePkg/BaseLib: AARCH64: Add ArmReadCntPctReg()
5c54869
To enable AARCH64 native instruction support for Openssl,
some interfaces must be implemented. OPENSSL_rdtsc() requests
an access to a counter to get some non-trusted entropy.

Add ArmReadCntPctReg() to read system count.
A similar ArmReadCntPct() function is available in the ArmPkg,
but the CryptoPkg where OPENSSL_rdtsc will reside cannot rely
on the ArmPkg.

Signed-off-by: Pierre Gondois <[email protected]>
@pierregondois
MdePkg/BaseLib: AARCH64: Add ArmReadIdAA64Isar0Reg()
0a2b49f
To enable AARCH64 native instruction support for Openssl,
some interfaces must be implemented. OPENSSL_cpuid_setup()
allows to probe the supported features of the platform.

Add ArmReadIdAA64Isar0Reg() to read the AA64Isar0, containing
Arm64 instruction capabilities.
A similar ArmReadIdAA64Isar0() function is available in the ArmPkg,
but the CryptoPkg where OPENSSL_cpuid_setup will reside cannot rely
on the ArmPkg.

Signed-off-by: Pierre Gondois <[email protected]>
@pierregondois
pierregondois force-pushed the pg/openssl_native_aarch64 branch from 411e874 to e3ef20d Compare July 30, 2024 10:38
@github-actions
github-actions Bot requested review from LiuZhiguang001, Wenxing-hou, ardbiesheuvel, lgao4 and liyi77 July 30, 2024 10:38
ardbiesheuvel
ardbiesheuvel requested changes Jul 30, 2024
View reviewed changes
Comment thread MdePkg/Library/BaseRngLib/AArch64/Rndr.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@pierregondois
MdePkg/BaseRngLib: Prefer ArmReadIdAA64Isar0Reg() over ArmReadIdIsar0()
3f44d27
A ArmReadIdAA64Isar0Reg() function was recently added
to BaseLib. Use it instead of its ArmReadIdIsar0() equivalent,
which was private to the BaseRngLib library.

This also allows to avoid the confusion between the following
registers:
- ID_ISAR0_EL1: allows to probe for Divide instructions, Debug
  instructions, ...
- ID_AA64ISAR0_EL1: AARCH64 specific register allowing to probe
  for AESE, RNDR, ... instructions

Signed-off-by: Pierre Gondois <[email protected]>
@pierregondois
pierregondois force-pushed the pg/openssl_native_aarch64 branch from e3ef20d to 941cb37 Compare July 30, 2024 12:11
@github-actions
github-actions Bot requested a review from ardbiesheuvel July 30, 2024 12:12
Wenxing-hou
Wenxing-hou reviewed Jul 30, 2024
View reviewed changes
Comment thread CryptoPkg/CryptoPkg.dsc Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread CryptoPkg/Library/OpensslLib/OpensslLibAccel.inf Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread CryptoPkg/Library/OpensslLib/OpensslLibFullAccel.inf Resolved

Uh oh!

There was an error while loading. Please reload this page.

pierregondois added 3 commits July 30, 2024 17:44
@pierregondois
CryptoPkg/OpensslLib: Add native instruction support for AARCH64
3e46b54
Add native instruction support for AARCH64.

Signed-off-by: Pierre Gondois <[email protected]>
@pierregondois
CryptoPkg/OpensslLib: Generate files for AARCH64 native support
458ab30
Generate AARCH64 related files and update .inf files,
running:
  python CryptoPkg/Library/OpensslLib/configure.py

Signed-off-by: Pierre Gondois <[email protected]>
@pierregondois
CryptoPkg/OpensslLib: Add AArch64Cap for arch specific hooks
41492ca
Add AARCH64 specific implementations of:
- OPENSSL_cpuid_setup(), probing hardware capabilitie
  (presence of FEAT_AES, etc.)
- OPENSSL_rdtsc(), returning non-trusted entropy by accessing
  system counter.

Signed-off-by: Pierre Gondois <[email protected]>
@pierregondois
CryptoPkg: Enable Openssl Accel builds for AARCH64
90d8aa8
Enable the following modules builds for AARCH64:
- OpensslLibAccel.inf
- OpensslLibFullAccel.inf

Signed-off-by: Pierre Gondois <[email protected]>
@pierregondois
pierregondois force-pushed the pg/openssl_native_aarch64 branch from 941cb37 to 90d8aa8 Compare July 30, 2024 15:46
@github-actions
github-actions Bot requested a review from Wenxing-hou July 30, 2024 15:47
ardbiesheuvel
ardbiesheuvel approved these changes Jul 30, 2024
View reviewed changes
Wenxing-hou
Wenxing-hou approved these changes Aug 1, 2024
View reviewed changes

@Wenxing-hou Wenxing-hou left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ardbiesheuvel ardbiesheuvel added the push Auto push patch series in PR if all checks pass label Aug 1, 2024
@mergify
Merge branch 'master' into pg/openssl_native_aarch64
b3c9f6b
@github-actions
github-actions Bot requested review from Wenxing-hou and ardbiesheuvel August 1, 2024 11:10
@mergify
mergify Bot merged commit a679cec into tianocore:master Aug 1, 2024
@DorLevi95 DorLevi95 mentioned this pull request Mar 11, 2025
Crypto migration to Openssl 3.0.15 microsoft/mu_crypto_release#99
Merged
1 of 5 tasks
@pierregondois
pierregondois deleted the pg/openssl_native_aarch64 branch April 29, 2025 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jyao1 jyao1 Awaiting requested review from jyao1
@kraxel kraxel Awaiting requested review from kraxel
@mdkinney mdkinney Awaiting requested review from mdkinney
@leiflindholm leiflindholm Awaiting requested review from leiflindholm
@samimujawar samimujawar Awaiting requested review from samimujawar
@lgao4 lgao4 Awaiting requested review from lgao4
@LiuZhiguang001 LiuZhiguang001 Awaiting requested review from LiuZhiguang001
@liyi77 liyi77 Awaiting requested review from liyi77
@ardbiesheuvel ardbiesheuvel Awaiting requested review from ardbiesheuvel
@Wenxing-hou Wenxing-hou Awaiting requested review from Wenxing-hou

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

impact:security This change has a direct security impact such as changing a crypto algorithm. push Auto push patch series in PR if all checks pass

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@pierregondois @ardbiesheuvel @liyi77 @Wenxing-hou
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.