Skip to content

icp: Add AES-GCM acceleration for ARMv8 on Apple Silicon#33

Open
lundman wants to merge 2 commits intomacOS_20250602from
macOS_20250602_ghashv8
Open

icp: Add AES-GCM acceleration for ARMv8 on Apple Silicon#33
lundman wants to merge 2 commits intomacOS_20250602from
macOS_20250602_ghashv8

Conversation

@lundman
Copy link

@lundman lundman commented Jun 2, 2025

This adds a new GHASH backend leveraging the PMULL instruction available on ARMv8 (Apple Silicon). Combined with the existing aesv8 encryption path, this enables full AES-GCM acceleration in both userland and kernel.

Key changes:

  • Implemented gcm_ghash_v8() and gcm_ghash_v8_4x() using ARM NEON + PMULL
  • Added gcm_init_htab_v8() (and optional gcm_init_v8() assembly variant) to precompute GHASH tables
  • Extended gcm_impl_ops_t to support .ghash, .ghash_4x, .ghash_init, and .needs_htable
  • Registered new backend as ghashv8, selected automatically when AES and PMULL are available
  • Updated gcm_init() to initialize Htable when required
  • Replaced use of .mul with .ghash calls in GHASH macro for modern paths

Motivation and Context

More speed. More! Speed! MOAR!

Description

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)
  • Quality assurance (non-breaking change which makes the code more robust against bugs)
  • 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:

lundman added 2 commits June 2, 2025 15:16
This adds a new GHASH backend leveraging the PMULL instruction
available on ARMv8 (Apple Silicon). Combined with the existing aesv8
encryption path, this enables full AES-GCM acceleration in both
userland and kernel.

Key changes:

- Added `gcm_ghash_v8()` and `gcm_ghash_v8_4x()` from OpenSSL
- Added `gcm_init_htab()` (and optional `gcm_init_v8()` v8 variant)
- Extended `gcm_impl_ops_t` with `.ghash`, `.ghash_init`, and `.needs_htable`
- Registered new backend as `ghashv8`, selected automatically when
  AES and PMULL are available. (Always true on Apple hardware)
- Updated `gcm_init()` to initialize `Htable` when required
- Replaced use of `.mul` with `.ghash` calls in GHASH macro for modern paths

The implementation maintains compatibility with existing
infrastructure and does not affect platforms without ARMv8 crypto
extensions.

Tested:
- Userland via `crypto_test` with `aesv8+ghashv8`
- Confirmed fallback to generic if PMULL unavailable

Signed-off-by: Jorgen Lundman <lundman@lundman.net>
Add ARMv8 cipher options for testing.

Stop core when NULL is passed to strcmp().

Signed-off-by: Jorgen Lundman <lundman@lundman.net>
@lundman lundman force-pushed the macOS_20250602_ghashv8 branch from 81e7091 to c027ddb Compare June 2, 2025 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant