How to change the CPU instruction set which VirtualBox emulated for guest OS, like disabling SSE4.2 instruction set?

4.2k Views Asked by At

What I want to achieve is disabling SSE4.2 instruction set for CPU which VirtualBox emulated for my Linux guest OS for debugging purpose, even though the real CPU support SSE4.2 instruction set on which VirtualBox is based. I referred to the VirtualBox manual page, there are several commands that might be related to this issue:

VBoxManage setextradata "VM name" VBoxInternal/CPUM/SSE4.2 0

The above command didn't work.

VBoxManage list hostcpuids

The above command can be used to dumps the CPUID parameters for the host CPUs. This can be used for a more fine grained analyis of the host's virtualization capabilities. The output is:

Host CPUIDs:

Leaf no.  EAX      EBX      ECX      EDX
00000000  00000016 756e6547 6c65746e 49656e69
00000001  000906e9 02100800 7ffafbff bfebfbff
00000002  76036301 00f0b6ff 00000000 00c30000
00000003  00000000 00000000 00000000 00000000
00000004  1c004121 01c0003f 0000003f 00000000
00000005  00000040 00000040 00000003 00142120
00000006  000027f7 00000002 00000001 00000000
00000007  00000000 029c6fbf 00000000 00000000
00000008  00000000 00000000 00000000 00000000
00000009  00000000 00000000 00000000 00000000
0000000a  07300804 00000000 00000000 00000603
0000000b  00000001 00000001 00000100 00000004
0000000c  00000000 00000000 00000000 00000000
0000000d  0000001f 00000440 00000440 00000000
0000000e  00000000 00000000 00000000 00000000
0000000f  00000000 00000000 00000000 00000000
00000010  00000000 00000000 00000000 00000000
00000011  00000000 00000000 00000000 00000000
00000012  00000000 00000000 00000000 00000000
00000013  00000000 00000000 00000000 00000000
00000014  00000001 0000000f 00000007 00000000
00000015  00000002 0000011c 00000000 00000000
00000016  00000d48 00000ed8 00000064 00000000
00000017  00000d48 00000ed8 00000064 00000000
80000000  80000008 00000000 00000000 00000000
80000001  00000000 00000000 00000121 2c100800
80000002  65746e49 2952286c 726f4320 4d542865
80000003  35692029 3035372d 50432030 20402055
80000004  30342e33 007a4847 00000000 00000000
80000005  00000000 00000000 00000000 00000000
80000006  00000000 00000000 01006040 00000000
80000007  00000000 00000000 00000000 00000100
80000008  00003027 00000000 00000000 00000000
80000009  00000d48 00000ed8 00000064 00000000

I know the output might be closely related to CPUID X86 instruction, but I still can't figure out what these Leaf no. EAX EBX ECX EDX lines meas. What's the relationship between these lines and the output of CPUID instruction? I think that only by knowing the relationship between these lines and the output of CPUID instruction can we use the following command correctly:

VBoxManage modifyvm --cpuid <leaf> <eax> <ebx> <ecx> <edx>

The above command is the only way I known that might achieve my goal, so, what's the relationship between the output of VBoxManage list hostcpuids, content followed by Leaf no. EAX EBX ECX EDX, and the output of CPUID instruction? How to disable SSE4.2 instruction set for CPU which VirtualBox emulated for my Linux guest OS even though the real CPU support SSE4.2 instruction set on which VirtualBox is based? Will VBoxManage modifyvm --cpuid <leaf> <eax> <ebx> <ecx> <edx> achieve my goal? And If you got any other way to achieve this, please tell me.

1

There are 1 best solutions below

3
Johnye On

I know it has been almost 4 years since the question was posted, but I came across the same problem and eventually found the correct solution:

https://docs.oracle.com/en/virtualization/virtualbox/6.0/admin/sse412passthrough.html

To provide SSE 4.1/SSE 4.2 support to guests, the host CPU has to implement these instruction sets. The instruction sets are exposed to guests by default, but it is possible to disable the instructions for certain guests by using the following commands:

VBoxManage setextradata VM-name VBoxInternal/CPUM/IsaExts/SSE4.1 0

VBoxManage setextradata VM-name VBoxInternal/CPUM/IsaExts/SSE4.2 0

The second line seems to be the answer to your problem. I tested it in my Guest and CPU-Z no longer shows SSE4.2 within the Guest after running the command above in a Host with SSE4.2. The command in the first post is missing "IsaExts".