Enable SHA-256 ARM NEON acceleration on aarch64 Linux

Aperta
#1,478 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
cpp, linux

Direzione di ricerca

Start with sha256.cpp:22 and read through sha_256_arm_v8() and the Linux runtime detection at lines 683–684. Check how the compiler handles the SHA2 intrinsics and target attribute for aarch64 Linux, then run the existing SHA-256 tests. Done means Linux aarch64 builds can use the accelerated implementation when SHA2 is detected, without calling it on unsupported hardware.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

The hardware-accelerated SHA-256 implementation (sha_256_arm_v8 using ARM SHA2 crypto extensions) is currently restricted to Apple platforms by the preprocessor guard at sha256.cpp:22:

#elif defined(__aarch64__) && defined(__APPLE__)

The Linux runtime detection code (getauxval(AT_HWCAP) & HWCAP_SHA2 at line 683) already exists inside this block but is dead code since the outer guard requires __APPLE__.

Why Apple-only

All Apple Silicon chips guarantee SHA2 extensions, so compiling the intrinsics is always safe. On Linux aarch64, older cores (e.g., Cortex-A53) may lack SHA2 support, and compiling the intrinsics without -march=armv8-a+crypto could fail.

Proposed fix
  1. Widen the outer guard to #elif defined(__aarch64__)
  2. Add __attribute__((target("sha2"))) (or +sha2 target) to sha_256_arm_v8() so the compiler emits SHA instructions only for that function, regardless of the global -march
  3. The existing getauxval runtime detection at line 683-684 already correctly gates whether sha_256_arm_v8 is actually called at runtime

This would enable hardware SHA-256 acceleration on Linux ARM servers (AWS Graviton, Ampere Altra, etc.).

Found during security audit of cryptographic precompile code.

Lingua principale
C++
Stelle
979
Fork
340
Merge medio
12h 16m
PR unite (30g)
25

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ipsilon/evmone

Tutte le issue di ipsilon/evmone

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.