BLAKE2 / libb2

C library providing BLAKE2b, BLAKE2s, BLAKE2bp, BLAKE2sp
Creative Commons Zero v1.0 Universal
132 stars 47 forks source link

avx xor illegal instruction #13

Closed LocutusOfBorg closed 6 years ago

LocutusOfBorg commented 6 years ago

Hello, seems that we are getting illegal instructions on Xen CPUs, when libb2 is built with fat mode on. this is how libb2 is built [1] and this is the assembly strace

│0x7ffff39b900a <blake2b_init_avx+10> vpxor %xmm0,%xmm0,%xmm0 │ │0x7ffff39b900e <blake2b_init_avx+14> sub $0x48,%rsp │ │0x7ffff39b9012 <blake2b_init_avx+18> mov $0x101,%eax │ │0x7ffff39b9017 <blake2b_init_avx+23> vmovaps %xmm0,(%rsp) │

AVX XOR is not available there

see the complete bug report here [2]. Do you have any clue?

[1] https://buildd.debian.org/status/fetch.php?pkg=libb2&arch=amd64&ver=0.97-4&stamp=1507640440&raw=0

[2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=884958

sneves commented 6 years ago

The CPU clearly reports being capable of AVX, so the most likely culprit is that the kernel itself does not support saving and restoring the entire AVX context.

I already do this check for WIndows, but incorrectly assumed that Linux would always do the right thing.

sneves commented 6 years ago

Commit 60ea749837362c226e8501718f505ab138e5c19d should have fixed this, but I have currently no way of testing this.

LocutusOfBorg commented 6 years ago

I pushed the fix on debian/experimental, and requested for feedbacks.

I packaged the latest git master to avoid the three patches I was bringing :)

LocutusOfBorg commented 6 years ago

builds ongoing there, https://buildd.debian.org/status/package.php?p=libb2&suite=experimental

thanks a lot for the quick "fix" :)

sneves commented 6 years ago

I'm going to assume this resolved the issue.

LocutusOfBorg commented 6 years ago

yes, it is now building correctly everywhere