Enable SHA-256 ARM NEON acceleration on aarch64 Linux

Abierto
#1,478 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
cpp, linux

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
C++
Estrellas
979
Forks
340
Merge medio
12 h 16 min
PR fusionados (30 d)
25

Preparar el entorno

  • Incluye un Dockerfile o un archivo de Docker Compose
  • Sin plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de ipsilon/evmone

Todos los issues de ipsilon/evmone

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.