Skip to content

Commit 70b4231

Browse files
committed
polyval: add avx2 to runtime CPU feature check
The `cpufeatures::new!` macro in `avx2.rs` only checks for `pclmulqdq`, but the functions it guards (`expand_key`, `proc_block`, `proc_par_blocks`) are annotated with `#[target_feature(enable = "avx2", enable = "pclmulqdq")]`. On CPUs that support PCLMULQDQ but lack AVX2 (e.g. Intel Pentium Gold, Celeron, some Atom processors), the runtime check passes, VEX-encoded instructions are executed, and the process crashes with SIGILL. Adding `"avx2"` to the feature check ensures the intrinsics path is only used when both features are available. CPUs without AVX2 correctly fall back to the software implementation. Fixes #315
1 parent 929ee7a commit 70b4231

File tree

1 file changed

+1
-1
lines changed
  • polyval/src/backend/intrinsics

1 file changed

+1
-1
lines changed

polyval/src/backend/intrinsics/avx2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use core::arch::x86_64::*;
3131
/// P1 polynomial: x^63 + x^62 + x^57 = 0xC200000000000000
3232
const P1: u64 = 0xC200000000000000;
3333

34-
cpufeatures::new!(clmul, "pclmulqdq");
34+
cpufeatures::new!(clmul, "pclmulqdq", "avx2");
3535
pub(crate) use clmul::InitToken;
3636

3737
/// Byte array which is the inner type of `FieldElement`

0 commit comments

Comments
 (0)