How to disable the sse4.2 instruction set for guest os of VirtualBox even if my cpu supports sse4.2?

This is for discussing general topics about how to use VirtualBox.
Post Reply
liucongvg
Posts: 3
Joined: 10. Sep 2018, 08:29

How to disable the sse4.2 instruction set for guest os of VirtualBox even if my cpu supports sse4.2?

Post by liucongvg »

I encountered a situation as described below:
There is an application which using crc32 instruction, which belongs to sse4.2 instruction set, runs on Linux os which is the guest of VirtualBox. By the way, my host os is Win10 and my cpu supports sse4.2 instruction set, so, the application runs on Linux which is the guest of VirtualBox runs correctly. But if the real cpu doesn't support sse4.2 instruction set, the application will crash because of SIGILL. So, in order to reproduce this SIGILL error, I must disable sse4.2 instruction set for guest os of VirtualBox for debugging purpose, I don't want to find a new computer which doesn't support sse4.2 instruction set to reproduce this issue.
andyp73
Volunteer
Posts: 1631
Joined: 25. May 2010, 23:48
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Assorted Linux, Windows Server 2012, DOS, Windows 10, BIOS/UEFI emulation

Re: How to disable the sse4.2 instruction set for guest os of VirtualBox even if my cpu supports sse

Post by andyp73 »

You may be able to achieve this using the VBoxManage modifyvm <vmname> --cpuid-set command line but you will need to work out what values to pass to it to remove the SSE4.2 flag.

-Andy.
My crystal ball is currently broken. If you want assistance you are going to have to give me all of the necessary information.
Please don't ask me to do your homework for you, I have more than enough of my own things to do.
liucongvg
Posts: 3
Joined: 10. Sep 2018, 08:29

Re: How to disable the sse4.2 instruction set for guest os of VirtualBox even if my cpu supports sse

Post by liucongvg »

andyp73 wrote:You may be able to achieve this using the VBoxManage modifyvm <vmname> --cpuid-set command line but you will need to work out what values to pass to it to remove the SSE4.2 flag.

-Andy.
Yes, of course I have noticed that command, but in order to use that command correctly, I must know the result of VBoxManage list hostcpuids, in my computer, the result is:
Host CPUIDs:

Leaf no. EAX EBX ECX EDX
00000000 00000016 756e6547 6c65746e 49656e69
00000001 000906e9 04100800 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 result is closely related to CPUID x86 instruction(https://en.wikipedia.org/wiki/CPUID), so please tell me the meaning of these lines bellow the "Leaf no. EAX EBX ECX EDX" and what's the relationship between them and the outpu of CPUID x86 instruction.
andyp73
Volunteer
Posts: 1631
Joined: 25. May 2010, 23:48
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Assorted Linux, Windows Server 2012, DOS, Windows 10, BIOS/UEFI emulation

Re: How to disable the sse4.2 instruction set for guest os of VirtualBox even if my cpu supports sse

Post by andyp73 »

It has been a while since I did any work with the CPUID instruction but from memory...

The leaf is the value you would put into the EAX register and the sub-leaf the value for the ECX register prior to calling the CPUID instruction. The EAX, EBX, ECX, EDX columns are the values returned in each of those registers by the call to CPUID.

The line you need to use is the Leaf 00000001 and the SSE4.2 bit is in register ECX. Intel produce some application notes and guides that you should be able to search for to find all of the detail.

-Andy.
My crystal ball is currently broken. If you want assistance you are going to have to give me all of the necessary information.
Please don't ask me to do your homework for you, I have more than enough of my own things to do.
liucongvg
Posts: 3
Joined: 10. Sep 2018, 08:29

Re: How to disable the sse4.2 instruction set for guest os of VirtualBox even if my cpu supports sse

Post by liucongvg »

I have "successfully" disabled sse4.2 instruction set by run the following command:

VBoxManage modifyvm "myandrovm_vbox86" --cpuidset 00000001 000906e9 00100800 7feafbff bfebfbff

the output of /proc/cpuinfo is :

Code: Select all

root@x86:/ # cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 158
model name      : Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
stepping        : 9
cpu MHz         : 3408.008
cache size      : 6144 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 2
apicid          : 0
initial apicid  : 0
fdiv_bug        : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 22
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc xtopology nonstop_tsc pni pclmulqdq ssse3 cx16 sse4_1 movbe popcnt aes xsave avx rdrand hypervisor lahf_lm abm 3dnowprefetch rdseed clflushopt
bugs            :
bogomips        : 6816.01
clflush size    : 64
cache_alignment : 64
address sizes   : 39 bits physical, 48 bits virtual
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 158
model name      : Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
stepping        : 9
cpu MHz         : 3408.008
cache size      : 6144 KB
physical id     : 0
siblings        : 2
core id         : 1
cpu cores       : 2
apicid          : 1
initial apicid  : 1
fdiv_bug        : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 22
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc xtopology nonstop_tsc pni pclmulqdq ssse3 cx16 sse4_1 movbe popcnt aes xsave avx rdrand hypervisor lahf_lm abm 3dnowprefetch rdseed clflushopt
bugs            :
bogomips        : 6816.01
clflush size    : 64
cache_alignment : 64
address sizes   : 39 bits physical, 48 bits virtual
power management:
As you can see, the, sse4_2 is not included in the flags, but, when I wrote a application which using crc32 instruction, the SIGILL exception is not generated, do you know why?(I have asked a question in stackoverflow: https://stackoverflow.com/questions/522 ... 8_52250249 , from the comment, maybe there is no way to achieve this.)
Last edited by socratis on 17. Sep 2018, 15:25, edited 1 time in total.
Reason: Enclosed the information in [code] tag for better readability
Johnye
Posts: 4
Joined: 17. Sep 2015, 19:03

Re: How to disable the sse4.2 instruction set for guest os of VirtualBox even if my cpu supports sse

Post by Johnye »

I'm a little late to the party (almost 4 years) but I came across the same problem and eventually found the correct solution:

https://docs.oracle.com/en/virtualizati ... rough.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.
Post Reply