NLnetLabs / simdzone

Fast and standards compliant DNS zone parser
BSD 3-Clause "New" or "Revised" License
68 stars 13 forks source link

Fix detection of AVX2 #222

Closed k0ekk0ek closed 3 months ago

k0ekk0ek commented 3 months ago

@wekers trying out NSD 4.10.0 on FreeBSD reported nsd-checkzone crashing with "Illegal instruction (core dumped)" (see NLnetLabs/nsd#361). @wekers was kind enough to help out with debugging and it seems there's a bug in ISA detection. The ebx for CPUID with eax=0x7 has bit 5 set (AVX2). However, basing the decision on whether AVX2 is actually available on the system requires bit 28 (AVX instructions supported) being set in ecx with eax=0x1. Apart from that, we must also check if the operating system properly supports it.

Peter Cordes (as always) provides excellent explanations (1, 2) on Stack Overflow.

See Félix Cloutier's pages on CPUID and XGETBV for detailed information on the aforementioned instructions.