Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

icp: Clean up AES-GCM AVX/AVX2 implementation selection #17061

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

lowjoel
Copy link

@lowjoel lowjoel commented Feb 16, 2025

Cleans up the implementation selection proposed in #17058. Depends on #17058 being merged (this branch shares common ancestry)

Motivation and Context

#17058 added the AVX2 implementation of AES-GCM from BoringSSL but subtly broke the cycle implementation and would not compile on older assemblers which did not understand the AVX2 instructions.

Description

Combine the use_avx/use_avx2 flags into an enum, allowing toggling of the different implementations that are available. Also, define different values of CAN_USE_GCM_ASM to indicate various levels of compiler support.

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@lowjoel lowjoel marked this pull request as draft February 16, 2025 23:17
@github-actions github-actions bot added the Status: Work in Progress Not yet ready for general review label Feb 16, 2025
@lowjoel lowjoel force-pushed the aes-gcm-impl-cleanup branch from 96abcf5 to c4b49c1 Compare February 16, 2025 23:25
@lowjoel lowjoel force-pushed the aes-gcm-impl-cleanup branch 2 times, most recently from bdc63f6 to 06eefea Compare February 17, 2025 00:15
This uses the AVX2 versions of the AESENC and PCLMULQDQ instructions; on
Zen 3 this provides an up to 80% performance improvement.

Original source:
https://github.com/google/boringssl/blob/13840dd094f9e9c1b00a7368aa25e656554221f1/gen/bcm/aes-gcm-avx2-x86_64-linux.S

See the original BoringSSL commit at
google/boringssl@3b6e1be.

Signed-off-by: Joel Low <[email protected]>
 - Accept GCM H variable in network endianness (ICP convention)
 - Fix round count offset in AES_KEY struct (ICP convention)
 - Use RET macro for kernel code

Signed-off-by: Joel Low <[email protected]>
@lowjoel lowjoel force-pushed the aes-gcm-impl-cleanup branch from 06eefea to d0dba00 Compare February 21, 2025 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Work in Progress Not yet ready for general review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant