Is Hyper-V a "Type 1 Hypervisor"?

Yes.

hyperv


But I have no idea really. Microsoft say it's a type 1 hypervisor because it runs directly on the hardware (and no other code runs at the same or higher privilege levels on the CPU). But does this actually have a measurable effect?

I tried to find out.

Wikipedia describes the cpuid opcode of modern Intel CPUs that can apparently tell me if I am running in a virtual machine or not.

Calling cpuid returns values in the EBX, ECX and EDX registers, notably the maker of the CPU ("GenuineIntel" on all my qualifying computers) and a bitmap of CPU features in ECX and EDX.

The two features I found possibly useful are ECX bit 31 ("hypervisor", allegedly shows if a hypervisor is present) and ECX bit 5 ("vmx", allegedly shows whether the CPU supports the hyperprivileged mode hypervisors want to use).

I wrote a little test program which asks the CPU about its maker, its support for "Virtual Machine eXtensions", and whether a hypervisor (presumably meaning a program using those "Virtual Machine eXtensions") is currently in control of the machine. (Download compiled version of the test program.)

I tested on five configurations.

Configuration 1: VMware virtual machine

PS C:\> .\test.EXE
GenuineIntel
No Virtual Machine eXtensions detected
Hypervisor detected

Configuration 2: A little Intel stick in my television set

PS C:\> .\test.EXE
GenuineIntel
Virtual Machine eXtensions detected
No Hypervisor detected

Configuration 3: Surface Pro 2 running Hyper-V, parent VM

PS C:\> .\test.EXE
GenuineIntel
No Virtual Machine eXtensions detected
Hypervisor detected

Configuration 4: Surface Pro 2 running Hyper-V, guest VM

PS C:\> .\test.EXE
GenuineIntel
No Virtual Machine eXtensions detected
Hypervisor detected

Configuration 5: Surface Pro 2 not running Hyper-V

PS C:\> .\test.EXE
GenuineIntel
Virtual Machine eXtensions detected
No Hypervisor detected

Result

Configurations 1, 3, and 4 are VMs. A hypervisor is detected and the (virtual) CPU does not offer a hyperprivileged mode.

Configurations 2 and 5 are not VMs. No hypervisor is detected and the (therefor physical) CPU does support a hyperprivileged mode (since it is not in use by a hypervisor).

The so-called "parent VM" running on Hyper-V is definitely a VM and does not see the real CPU. Hyper-V does indeed run between all operating system instances and the hardware. So it must be a type 1 hypervisor.

I'll have to try this on KVM next.

 © Andrew Brehm 2016