ML-DSA AVX512: Add new assembly - #11032
Conversation
|
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11032
Scan targets checked: wolfcrypt-bugs, wolfcrypt-rs-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src
Findings: 1
Medium (1)
mlkem_rej_uniform*_ins dispatch on AVX512F alone, not AVX512F+BW
File: wolfcrypt/src/wc_mlkem_poly.c:2327
Function: mlkem_rej_uniform_n_ins
Category: Logic errors
mlkem_rej_uniform_n_ins/mlkem_rej_uniform_ins gate the base AVX512 path with IS_INTEL_AVX512(cpuid_flags) instead of the USE_INTEL_AVX512 (F+BW) macro this PR introduced for exactly this purpose. The fallback mlkem_rej_uniform_n_avx512/mlkem_rej_uniform_avx512 routines execute vpshufb zmm..., an AVX512BW-only instruction, causing SIGILL on AVX512F-without-BW hardware. Every sibling dispatcher in this same file (mlkem_cbd_eta2_ins, mlkem_compress_10, etc.) correctly uses USE_INTEL_AVX512.
Recommendation: Change both if (IS_INTEL_AVX512(cpuid_flags)) guards to if (USE_INTEL_AVX512(cpuid_flags)) to match the rest of the file.
Referenced code: wolfcrypt/src/wc_mlkem_poly.c:2327-2331 (5 lines)
This review was generated automatically by Fenrir. Findings are non-blocking.
dgarske
left a comment
There was a problem hiding this comment.
Please resolve merge conflicts
dgarske
left a comment
There was a problem hiding this comment.
Results — PR #11032 (ML-DSA AVX512: Add new assembly)
Correctness — make check FAIL 0:
┌──────────────────────────────────┬────────────────────────┬─────────────────────────┐
│ Machine │ Path exercised │ Result │
├──────────────────────────────────┼────────────────────────┼─────────────────────────┤
│ tigerlake-come (AVX512F/BW/VBMI) │ ML-DSA AVX512 asm runs │ PASS (after + before) │
├──────────────────────────────────┼────────────────────────┼─────────────────────────┤
│ i9w680 (AVX2-only) │ CPUID fallback │ PASS (FAIL 0 / ERROR 0) │
└──────────────────────────────────┴────────────────────────┴─────────────────────────┘
Asm confirmed linked (tigerlake after): L_mldsa_avx512_perm20/21/31, permn0/1, zetas_1p, zetas_inv_1p, half_1p (796 avx512 symbols). Config: --enable-intelasm --enable-dilithium --enable-mlkem.
Speedup (tigerlake, core-pinned, 3-run avg, before -> after ops/s):
┌───────────┬───────────────────────┬───────────────────────┬───────────────────────┐
│ Level │ key gen │ sign │ verify │
├───────────┼───────────────────────┼───────────────────────┼───────────────────────┤
│ ML-DSA-44 │ 54.2k -> 81.8k (+51%) │ 17.8k -> 22.5k (+26%) │ 49.2k -> 67.1k (+36%) │
├───────────┼───────────────────────┼───────────────────────┼───────────────────────┤
│ ML-DSA-65 │ 32.5k -> 49.2k (+52%) │ 11.2k -> 16.4k (+46%) │ 31.1k -> 44.8k (+44%) │
├───────────┼───────────────────────┼───────────────────────┼───────────────────────┤
│ ML-DSA-87 │ 21.0k -> 33.5k (+60%) │ 9.6k -> 14.6k (+52%) │ 20.0k -> 29.9k (+50%) │
└───────────┴───────────────────────┴───────────────────────┴───────────────────────┘
Every ML-DSA operation at every security level improves — +26% to +60%. No regressions.
Add implementation of assembly code for AVX512F/BW and AVX512F/BW/VBMI. Improvements to AVX2 assembly. Check AVX512BW CPU id flag for base AVX512 assembly for ML-KEM.
Description
Add implementation of assembly code for AVX512F/BW and AVX512F/BW/VBMI.
Improvements to AVX2 assembly.
Check AVX512BW CPU id flag for base AVX512 assembly for ML-KEM.
Testing
Regression tested ML-DSA.