I have an app that needs to run on machines that have AVX instruction support and those that do not. I would like to configure a VM such that it does not support AVX instructions so I can test this scenario on my dev machine that does support AVX.
I've tried monkeying with the vmx file, setting parameters like cpuid.1.eax and cpuid.1.ecx, but to no avail... if I have these lines in the vmx file, Workstation won't start the VM and complains about an absent cpuid.pcid feature. I've also tried adding cpuid.AVX = "FALSE" to the vmx file, but this had no effect.
Any tips?
You should at least look up the Wikipedia page of CPUID instruction if you don't want to go through the Intel Software Development Manual Volume 2 to get the right bits to mask off.
Add these to the vmx and it should mask off both AVX and AVX2 instructions. Tested on Ubuntu VM with Intel Coffee Lake CPU and effect seen (or rather unseen AVX and AVX2) in /proc/cpuinfo flags.
There are a bunch of other bits for AVX-512 but I don't have a CPU that has AVX512.
#bit 28 for AVX
cpuid.1.ecx = "---0:----:----:----:----:----:----:----"
#bit 5 for AVX2
cpuid.7.ebx = "----:----:----:----:----:----:---0:----"
While you can mask the CPUID features, that only affects what CPUID reports – it won't prevent the applications from (successfully) executing these instructions inside the VM, as long as the host CPU supports them. The only way to test this properly is on a CPU that doesn't support the instructions, or by using an emulator such as Bochs.
Thanks much. I didn't realize "pcid" was referring to one of the cpuid bits... thought it was referring to something in the vmx parameters.
Appreciate the help.
I just realised there was a mistake in the masking for avx2; since it is bit 5 it should be
#bit 5 for AVX2
cpuid.7.ebx = "----:----:----:----:----:----:--0-:----"
I don't know how true the statement that it will still execute despite being masked. Whether it is true/accurate or not, I don't think you would need to use an emulator.
As a developer, you should write into your application to check for the presence/absence of AVX/AVX2/AVX-512 features; or at least the developer who provided the library that makes the AVX/AVX2 calls should do the checking and return an error/information when the instruction set is not available. For performance reasons, it would be better to use AVX/AVX2/AVX-512 when it is available; on the other hand, it is dangerous to just execute AVX/AVX2 instructions without checking its availability in the CPU.
As an example, with Prime95, the Disable AVX2 and disable AVX are checked and greyed out automatically in the "Run a Torture test" dialog when the AVX/AVX2 bits are masked off.
