Is the performance loss on Type-2 hypervisors considerable?
virtual-machine, virtualbox, virtualization
Solution
Virtualization is very complex. The hardware virtualization (VT-x from Intel and AMD-V from AMD) on nowadays machines greatly improves overall virtualization performance, but it only helps with some parts of the virtualization. Most of the code is executed directly on the hardware. But there are still cases when it's necessary to emulate the code in software. There are a lot of tricks and techniques which improve the performance and security and workarounds of hardware limitations because x86 platform was never designed to be virtualized.
I advise you to check Virtualbox's manual where a lot of technical details is described, particularly the Hardware vs. software virtualization and subsequent chapters. There is a lot of interesting reading if you are interested in these things.
Also benchmarking of the virtualization performance is not easy because it significantly depends on what's that benchmark doing. If it will entirely run in the ring 3 only (user space), it's possible that it will be running directly on hardware without the hypervisor interception. That means it'll have the similar performance as if it would be running on real hardware. On the other extreme, if it will be running almost all the time in the ring 0 (the most privileged, kernel space), that means it will be doing a lot of system calls, the hypervisor will have a lot of work and virtualization could slow down significantly. Actually, guest system calls will not be running in the ring 0, because then the hypervisor would lose overall control over the system). Instead, hypervisors use the ring 1, which is not used ordinary at all. See Protection rings on Wikipedia for details.
Problem
During my OS classes some time ago I remember the teacher saying something like A Type 1 hypervisor runs directly on the hardware; a Type 2 hypervisor runs on another operating system, such as Linux This suggests that VMs under a type 2 hypervisor have lower performance. I was doing some simple benchmarks, such as iterating over a for loop or writing characters to a text file, using VirtualBox (which is a Type 2 hypervisor) and found minimal performance impacts though. Investigating a little more, it appears that on my computer VirtualBox can do hardware virtualization using VT-x, even though it runs under my Windows OS. So the question that arises is, do type 2 hypervisors really suffer a loss in performance nowadays, especially considering that they can achieve hardware virtualization? If the answer is negative, then why does the distinction between type 1 and type 2 hypervisors still exist?