Skip to content

Commit cbe1bf0

Browse files
committed
Fix default values for AVX and AVX512 OS state enabled flags
AVX and AVX512 strictly require the OS to enable OXSAVE otherwise we can face "illegal instruction" depending on the context state
1 parent f5e485e commit cbe1bf0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

include/xsimd/config/xsimd_cpuid.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,11 @@ namespace xsimd
197197
// https://docs.kernel.org/admin-guide/hw-vuln/gather_data_sampling.html
198198

199199
unsigned sse_state_os_enabled = 1;
200-
unsigned avx_state_os_enabled = 1;
201-
unsigned avx512_state_os_enabled = 1;
200+
// AVX and AVX512 strictly require OSXSAVE to be enabled by the OS.
201+
// If OSXSAVE is disabled (e.g., via bcdedit /set xsavedisable 1),
202+
// AVX state won't be preserved across context switches, so AVX cannot be used.
203+
unsigned avx_state_os_enabled = 0;
204+
unsigned avx512_state_os_enabled = 0;
202205

203206
// OSXSAVE: A value of 1 indicates that the OS has set CR4.OSXSAVE[bit
204207
// 18] to enable XSETBV/XGETBV instructions to access XCR0 and

0 commit comments

Comments
 (0)