The ggml_backend_cpu_x86_score() function contained a FIXME comment
admitting it did not check for OS support. All AVX/AVX2/AVX-512/AMX
feature checks were raw CPUID bit reads with no OSXSAVE or XGETBV
validation.
On CPUs where CPUID reports AVX2 support but the OS has not enabled
YMM register save/restore (e.g. certain hypervisors, containers with
restricted XSAVE, or Windows builds with disabled AVX context), ggml
would select an AVX2/AVX-512 backend that immediately faults with
SIGILL on the first vector instruction.
Fix: add xgetbv() (MSVC _xgetbv / GCC-Clang inline asm), then three
predicates that are now called by the affected feature methods:
os_saves_ymm() — CPUID.1:ECX[27] (OSXSAVE) + XCR0[2:1] == 0b11
gates: AVX, AVX2, FMA, F16C, AVX_VNNI
os_saves_zmm() — os_saves_ymm() + XCR0[7:5] == 0b111
gates: AVX512F/DQ/PF/ER/CD/BW/VL, AVX512_VBMI/VNNI/FP16/BF16
os_saves_amx() — os_saves_zmm() + XCR0[18:17] == 0b11
gates: AMX_TILE, AMX_INT8, AMX_FP16, AMX_BF16
No interface changes — all call sites continue to use is.AVX2() etc.
The fix is self-contained within cpuid_x86.
Resolves the FIXME in ggml_backend_cpu_x86_score().
Designed and implemented by Matthew Busel.