projg2 / cpuid2cpuflags

Tool to generate CPU_FLAGS_* for your CPU
GNU General Public License v2.0
108 stars 20 forks source link

Wrong AVX series flags in some VMs #28

Closed bekcpear closed 2 months ago

bekcpear commented 2 months ago

Similar to https://github.com/projg2/cpuid2cpuflags/issues/27, I'm having problems with incorrect FLAGS.

My VM's CPU is Intel(R) Xeon(R) Gold 6266C CPU @ 3.00GHz, it supports AVX series extensions, however, because of the configuration of my cloud hosting provider, the AVX series extension is not supported in practice.

But it looks like cpuid2cpuflags incorrectly gets the most direct information from the physical cores?

As a comparison, ruapu is much more precise in determining whether an extension is supported by executing some corresponding instructions.

cpuid2cpuflags shows:

cpuid2cpuflags --version
cpuid2cpuflags 14
cpuid2cpuflags
CPU_FLAGS_X86: aes avx avx2 avx512_vnni avx512bw avx512cd avx512dq avx512f avx512vl f16c fma3 mmx mmxext pclmul popcnt rdrand sse sse2 sse3 sse4_1 sse4_2 ssse3

while:

lscpu | grep -C10 Flags
Model name:                           Intel(R) Xeon(R) Gold 6266C CPU @ 3.00GHz
BIOS Model name:                      pc-i440fx-2.8  CPU @ 2.0GHz
BIOS CPU family:                      1
CPU family:                           6
Model:                                85
Thread(s) per core:                   2
Core(s) per socket:                   1
Socket(s):                            1
Stepping:                             7
BogoMIPS:                             6002.00
Flags:                                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 hle smep bmi2 erms invpcid rtm rdseed adx smap clflushopt clwb arat md_clear flush_l1d arch_capabilities
Hypervisor vendor:                    KVM
Virtualization type:                  full
L1d cache:                            32 KiB (1 instance)
L1i cache:                            32 KiB (1 instance)
L2 cache:                             1 MiB (1 instance)
L3 cache:                             30.3 MiB (1 instance)
NUMA node(s):                         1
NUMA node0 CPU(s):                    0,1
Vulnerability Gather data sampling:   Unknown: Dependent on hypervisor status
Vulnerability Itlb multihit:          KVM: Mitigation: VMX unsupported

and

gcc -v -E -x c /dev/null -o /dev/null -march=native 2>&1 | grep /cc1

 /usr/libexec/gcc/x86_64-pc-linux-gnu/13/cc1 -E -quiet -v /dev/null -o /dev/null -march=skylake-avx512 -mmmx -mpopcnt -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mno-avx -mno-avx2 -mno-sse4a -mno-fma4 -mno-xop -mno-fma -mno-avx512f -mbmi -mbmi2 -maes -mpclmul -mno-avx512vl -mno-avx512bw -mno-avx512dq -mno-avx512cd -mno-avx512er -mno-avx512pf -mno-avx512vbmi -mno-avx512ifma -mno-avx5124vnniw -mno-avx5124fmaps -mno-avx512vpopcntdq -mno-avx512vbmi2 -mno-gfni -mno-vpclmulqdq -mno-avx512vnni -mno-avx512bitalg -mno-avx512bf16 -mno-avx512vp2intersect -mno-3dnow -madx -mabm -mno-cldemote -mclflushopt -mclwb -mno-clzero -mcx16 -mno-enqcmd -mno-f16c -mfsgsbase -mfxsr -mhle -msahf -mno-lwp -mlzcnt -mmovbe -mno-movdir64b -mno-movdiri -mno-mwaitx -mno-pconfig -mno-pku -mno-prefetchwt1 -mprfchw -mno-ptwrite -mno-rdpid -mrdrnd -mrdseed -mrtm -mno-serialize -mno-sgx -mno-sha -mno-shstk -mno-tbm -mno-tsxldtrk -mno-vaes -mno-waitpkg -mno-wbnoinvd -mxsave -mxsavec -mxsaveopt -mno-xsaves -mno-amx-tile -mno-amx-int8 -mno-amx-bf16 -mno-uintr -mno-hreset -mno-kl -mno-widekl -mno-avxvnni -mno-avx512fp16 -mno-avxifma -mno-avxvnniint8 -mno-avxneconvert -mno-cmpccxadd -mno-amx-fp16 -mno-prefetchi -mno-raoint -mno-amx-complex --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=30976 -mtune=skylake-avx512 -fcf-protection -dumpbase null

I'm not sure how my cloud hosting provider is configured, all I know is that this CPU is exclusive and corresponds to a separate physical core, so it's possible that the cpuid directly gets the information provided by the physical core?

Updated:

I was told that the KVM version was too low and the higher kernel versions were incompatible, resulting in unsupported AVX series extension, this is probably something that cpuid2cpuflags doesn't currently take into account.

mgorny commented 2 months ago

This is a simple tool. I'm not really interested in adding a lot of complexity to detect and workaround misconfigured systems.