CPU flags not correctly registered.

Discussions related to using VirtualBox on Windows hosts.
Post Reply
ljetibo
Posts: 4
Joined: 9. Aug 2017, 09:16

CPU flags not correctly registered.

Post by ljetibo »

As I've described in detail in this github issue: github dot com /numpy/numpy/issues/9532 I have problems with migrating a virtual machine.

I created an Ubuntu 16.04 guest machine on a Windows 10 host using the VirtualBox GUI. I used the export functionality to export the virtual machine and then imported it on another PC. It worked.
However, when I tried it with a third one it didn't.

The problem lies in the fact the VM does not register CPU capabilities correctly which makes other installed software that expects that capability to crash. For example when you look at the cpuinfo data of the pc in question you see there are no avx or avx2 flags present:

Code: Select all

processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 61
model name	: Intel(R) Core(TM) i3-5005U CPU @ 2.00GHz
stepping	: 4
cpu MHz		: 1995.379
cache size	: 3072 KB
physical id	: 0
siblings	: 1
core id		: 0
cpu cores	: 1
apicid		: 0
initial apicid	: 0
fdiv_bug	: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 20
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 rdtscp constant_tsc xtopology nonstop_tsc eagerfpu pni monitor ssse3 sse4_1 sse4_2 x2apic hypervisor lahf_lm
bugs		:
bogomips	: 3990.75
clflush size	: 64
cache_alignment	: 64
address sizes	: 39 bits physical, 48 bits virtual
power management:

but if you check the CPU flags on the host system (I used CPU-Z for that) then this is listed:

Code: Select all

MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, EM64T, VT-x, AES, AVX, AVX2, FMA3
Naturally this causes the library I need to crash whenever it expects that avx or avx2 is present. Can I get any help on how to fix this situation? What can I do to get the VM to register the cpu flags correctly?
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: CPU flags not correctly registered.

Post by mpack »

VirtualBox has to save and restore features when it swaps between host and guest. It can only do this for features it understands. Features it does not understand are hidden from the VM. This is intended behaviour. If you like you can raise a ticket asking for CPU feature X support to be added.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: CPU flags not correctly registered.

Post by socratis »

ljetibo wrote:What can I do to get the VM to register the cpu flags correctly?
Not all CPU flags are passed on to the guest. I don't know if that's a specific problem with your specific CPU. For example, compare my setup (OSX 10.11.6, Intel Core i7-4870HQ @ 2.50GHz) with a virtual machine running the exact same OSX version.

Host:

Code: Select all

$ sysctl machdep.cpu.features
machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX SMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C
Guest:

Code: Select all

$ sysctl machdep.cpu.features
machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH MMX FXSR SSE SSE2 HTT SSE3 PCLMULQDQ SSSE3 CX16 SSE4.1 SSE4.2 MOVBE POPCNT AES VMM XSAVE OSXSAVE AVX1.0 RDRAND
and just to make it easier, here are the flags that don't get through to the guest:

Code: Select all

ACPI DS DSCPL DTES64 EST F16C FMA MON PBE PCID PDCM RDRAND SEGLIM64 SMX SS TM TM2 TPR TSCTMR VMX x2APIC
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
ljetibo
Posts: 4
Joined: 9. Aug 2017, 09:16

Re: CPU flags not correctly registered.

Post by ljetibo »

Thanks for the quick reply guys!

The flags in question (AVX or AVX2) are supported as is visible from @socratis answer (i.e. AVX1.0). On my PC where the VM was created both AVX and AVX2 is supported in host and naturally AVX shows as a cpu flag in the host Ubuntu VM.

Code: Select all

flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 nx rdtscp constant_tsc xtopology nonstop_tsc pni pclmulqdq monitor ssse3 cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx rdrand hypervisor lahf_lm abm 3dnowprefetch rdseed
The PC that has this issue supports both AVX and AVX2 and in the host those flags show up. Unfortunately for some reason they disappear in the guest. So it works in one case (well, at least three actually) but not in the other. If I'm missing something - pls point it out, but from my point of view this doesn't look like unsupported flag option.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: CPU flags not correctly registered.

Post by scottgus1 »

Exporting changes the guest. The Export function puts the guest into the OVF format (google it), which is compatible with other hypervisors' Import functions. There are some Virtualbox features that can't be transferred through Export/Import. Maybe these flags are part of the incompatibilities? Maybe not, I wouldn't know.

But if both host PCs will be running Virtualbox, try Moving a VM. If your guest folder is arranged in the 4.0 format (all guest files in one folder, including the .vbox guest recipe file, the virtual hard drive file, and a Snapshots folder containing all the guest snapshots, if you took any) you should even be able to take the guest from Windows to Linux or vice versa.
ljetibo
Posts: 4
Joined: 9. Aug 2017, 09:16

Re: CPU flags not correctly registered.

Post by ljetibo »

Yes, the thought occurred to me as well and I'll test this out in a day or day and a half when I get close enough to the target PC to copy paste the folder.

If that fails I'll try creating a new VM from scratch on that PC and seeing if the flags appear or not.

If not I'm afraid the host OS on that PC is somehow compromised and that there's no fix to the issue, that is unless someone knows how to force the use of the AVX flag perhaps?
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: CPU flags not correctly registered.

Post by scottgus1 »

I have a vague recollection of something relating to cpu flags in the manual. However I slightly less-vaguely recall that the command was for limiting what the guest CPU sees to ensure compatibility for teleporting. And I seriously doubt that any command will turn on in the guest what the host OS doesn't pass on.

Edit: less vague now; see section 8.8.6, command:

Vboxmanage modifyvm <vmname> --cpuidset <leaf> <eax> <ebx> <ecx> <edx>

but it only restricts.
ljetibo
Posts: 4
Joined: 9. Aug 2017, 09:16

Re: CPU flags not correctly registered.

Post by ljetibo »

So I just wanted to do a closure for the thread and report back the results:

On all the PC's that used VM none had the issue when the VM was installed with the migration method. Some of them complained if the import method was used.

The only PC that had an issue was the one we tested with (of course.....) and the only conclusion I can come to is that the host OS is "broken" somehow. The issue was not encountered in any other PC, most of which used Intel processors (i3, i5, i7's).

Thanks for the help!
Post Reply