Do virtual machines not allow all host CPU extensions?

0

For convenience's sake I'm trying to run an otherwise "regular" installation of Gentoo Linux as a guest inside VirtualBox on a Windows 7 host. I bootstrapped the installation by using VirtualBox, even. But now, after about a year of inevitably rebuilding all the packages on Portage with -march=native in my compiler flags, I've found that all non-trivial programs (trivial = ls, cd, cat, nontrivial = vim, man, basically anything linked to the c++ standard library) are killed almost immediately on startup. The kernel log indicates it trapped illegal instructions, as if the program was compiled with CPU extensions that the host CPU didn't support. But it does! My understanding of hypervisors like VirtualBox is that the programs should still be running basically on bare-metal, it's biggest role is keeping the guest OS and its userland and the host OS and its userland's virtual memory separate.

My question is, what gives? Are VMs only allowed to use some of the instructions available on the host CPU? Or is this an entirely different problem?

Spijdar

Posted 2015-05-03T21:49:52.520

Reputation: 11

2do you have virtualization extensions available and enabled on your host BIOS? if your CPU/Mobo do not support the Intel or AMD virtualization extensions, many of the host CPU features will be unavailable. Type 2 hypervisors like Virtualbox have a very thick layer of abstraction between virtual and physical hardware. if this is a concern for your usecase, consider a type1 hypervisor implementation like ZenServer or esxi – Frank Thomas – 2015-05-03T21:56:23.510

@FrankThomas is right. I use Hyper-V, a type-1 hypervisor, and have no such issues on my Haswell-based laptop. -march=native or -march=haswell produce working executables in a Gentoo guest. – bwDraco – 2015-05-03T22:27:54.427

Good to know! Yes, Intel VT-x extensions are enabled. Which leaves me confused, just judging by what I've read when using VT-x the hypervisor runs in its own mode on the CPU and the guest's CPU instructions are run without any interference, only privileged OS instructions are trapped and modified. Which doesn't explain why certain extensions are apparently illegal under them. But type-1 hypervisors do sound like good solution, albeit another thing to learn. – Spijdar – 2015-05-03T23:03:13.050

No answers