VM with a specific CPU

from–https://superuser.com/questions/1300153/vm-with-a-specific-cpu

 

Asked 
Viewed 5k times

4

Is it possible to create a VM with a specific CPU that supports only specific instruction set.

For example, I want to try something on a Machine that has a CPU that does not support AVX or SSE instruction, is it possible to create a VM with a CPU that has no AVX or SSE support?

  • Is this for programs for which you don’t have the source code (and thus can’t can’t exclude the use of those feature during the build)?

    – RonJohn

    Mar 3, 2018 at 22:59

2 Answers

6

Sort-of. VMware and VirtualBox do not support emulation, only virtualization. So that means you cannot add features. However, removing features shouldn’t pose a problem.

This article has some details on how to fake the CPUID as reported to the guest. Keep in mind that this doesn’t really disable any features.

Instructions for VMware products (quote):

Use editor (e.g. notepad) open virtual machine configure file (.vmx)
Adding following lines:

cpuid.1.eax = "00000000000000110100011010101001"
cpuid.1.edx = "10111111111010111111101111111011"

If CPUID is still not change or invalid, try adding:

cpuid.1.ebx = "00000000000000110100011010101001"
cpuid.1.ecx = "10111111111010111111101111111011"

Save configure file and start your Virtual Machine.

Instructions for VirtualBox (quote):

Open Command Prompt and switch to VirtualBox working directory.
Run following command to change CPUID.

vboxmanage modifyvm  --cpuidset 1 000306a9 00100800 3d9ae3bf bfebfbff

Start your Virtual Machine.

How you get those CPUID values is up to you, you’ll probably need to consult your CPU vendor’s Instruction Set Architecture manual.

If you want to emulate features, you’ll need to use an emulator. QEMU can do both virtualization and full emulation. It also supports many CPU architectures other than x86/x64.

  • 1
    This is good for well behaved software that tests for the presence of a feature before using it, but I assume that for badly behaved software the “missing” features will continue to work as normal.

    – Mokubai

    Mar 3, 2018 at 18:20

3

VMware documentation mentions a “CPUID Mask”, but I don’t know how configurable that is.

If you’re willing to experiment with other VMMs, QEMU can enable and disable CPUID flags at the command line. For example, qemu-system-i386 -cpu n270,fpu=off leads to a virtual CPU with the features of an n270 but with the fpu flag disabled. There’s a full list of supported CPU models and CPUID flags at qemu-system-i386 -cpu help.

上一篇
下一篇