scrypt-jane
scrypt-jane copied to clipboard
improper test for AVX runtime support, invalid opcode crash
In scrypt-jane-portable-x86.h, the line
if ((regs.ecx & (1 << 28)) && (xgetbv_flags & 0x6)) cpu_flags |= cpu_avx;
should instead be
if ((regs.ecx & (1 << 28)) && ((xgetbv_flags & 0x6) == 0x6)) cpu_flags |= cpu_avx;
because both bits (0x04 for YMM registers, and 0x02 for XMM registers) must be set to indicate OS support for AVX. Without this, systems that have AVX disabled by the OS (for example, Windows 7 RTM) will select the AVX implementation and crash on first run.
(Also, thanks for providing your simple-to-integrate implementations of various crypto primitives, they have proven to be immensely useful time and time again.)