DaGenix / rust-crypto

A (mostly) pure-Rust implementation of various cryptographic algorithms.
Apache License 2.0
1.4k stars 298 forks source link

rust_crypto_aesni_setup_working_key_128 "illegal instruction" #391

Open yd021976 opened 8 years ago

yd021976 commented 8 years ago

I all,

when compiling and running "librespot" that is using rust-crypto i get a crash with "illegal instruction". Compiled and ran on ubuntu 16.04 x64 on an intel 651 with SSE.

The detail of error is :

Thread 2 "librespot" received signal SIGILL, Illegal instruction. 0x0000555555a82d1c in rust_crypto_aesni_setup_working_key_128 (key=0x555555a82cb2 <rust_crypto_aesni_setup_working_key_128+43> "f\017:\337\321\002\350Z", round_key=0x7ffff49f4ea9 "\260\220\335`\247\230dw\223\352;^\u0475", <incomplete sequence \334>) at src/aesni_helpers.c:33 33 asm volatile(

The disassembly code that raised "illegal instruction" is :

0000555555a82d1c: vpslldq $0x4,%xmm1,%xmm3

The used registers values are : xmm1 : 0 xmm3 : 0

Can you help me understand what is happening and is wrong ?

Thank you

yd021976 commented 8 years ago

Hi again,

I think my problem is that my processor is not compatible with AVX instruction set, and so i get "illegal instruction" when your code call vpslldq $0x4,%xmm1,%xmm3. Because "VPSLLDQ" require processor with AVX flag, not mine.

To be compatible, i think the code should call the "PSLLDQ" with does not require AVX flag.

Problem : I don't know how to convert "VPSLLDQ" to "PSLLDQ" as they don't take same parameters.

Someone could help me ?

Thank you

yd021976 commented 8 years ago

Proposed a patch in #390 . Would you change the code in github to make rust-crypto more CPU compatible ?

Thank you