From the Beginning — A Brief Overview of Virtual Machines
“But, how does a hypervisor actually work?”
I’ve asked this question time and time again but I’ve never really gotten the answer I want. I’ve seen the graphs — I understand how the layers work and what order they go in. But how do these layers talk to each other, what kind of secrets lie between them?
Mom, where do hypervisors come from?
Check out: https://www.vm.ibm.com/vm40hist.pdf
The 1960s were a wild time. I wasn’t alive — but I’ve heard stories. During this time is when IBM’s Cambridge Scientific Center developed CP-40, CP standing for Control Program. CP-40 was the original hypervisor and established virtual machine architecture.
In 1972 IBM announced that the System/370, released two years prior in 1970, would include virtual storage. IBM also announced the release of VM/360, the first official release of their virtual storage operating systems. Over the next decade IBM released even more hardware support.
In 1999 VMWare introduces VMWare Virtual Platform, and then a few year later in 2005 offers some virtualization technology for free!
What’s the different between a Type One and a Type Two?
A type one hypervisors (also known as full virtualization, or bare metal) sits on top of the actual hardware. On top of the hypervisor sits the virtual machines, or guest operating systems.
In a type two hypervisor, the hypervisor sits on top of the operating system, and creates the virtual machines on top of it from there.
Examples of Type One Hypervisors: KVM, Xen, Hyper-V
Examples of Type Two Hypervisors: VirtualBox, VMWare Fusion
Control Flow Graph: A graph that represents all paths that must be traversed through a program during its execution.
Basic Block: A straight-line sequence of code, the only branch in is the entry and the only branch out is the exit
User Mode: CPU mode where executing code does not direct access to the underlying hardware. Code running in user mode must use system APIs to access hardware.
Kernel Mode: CPU Mode where code has unrestricted access to the underlying hardware.
How does a Type One Hypervisor work?
As stated above a Type One Hypervisor sits on the hardware itself. The guest operating system believes it is running in kernel mode, but is actually running in user mode. When the hypervisor receives an instruction it inspects it to see if it was from the guest operating system or a user program in the virtual machine.
If it comes from the guest operating system then it arranges for the instruction to be carried out. If the instruction comes from a user program in the virtual machine then it emulates what the real hardware would do when confronted with a sensitive instruction — it either ignores it or it traps to the guest operating system.
How does a Type Two Hypervisor work?
A type two hypervisor sits on top of the operating system — running as an ordinary user program. Say we put a CD-ROM into our disk drive, when that operating system starts all basic blocks with sensitive instructions get changed into procedures that the type two hypervisor handles. Blocks are cached and then executed, which helps speed things up. Sensitive instructions given by the guest operating system are never executed by the true hardware.
What about Paravirtualization?
With paravirtualization all sensitive instructions are hypervisor calls, which makes the guest operating system act like a program, and the hypervisor acts like an operating system.
This means the hypervisor must define a set of procedures the guest system can use, effectively creating an API for the guest operating system to talk to the hypervisor.
Basic Blocks / Control Flow: https://www2.cs.arizona.edu/~collberg/Teaching/453/2009/Handouts/Handout-15.pdf
User Mode/ Kernel Mode:
Most operating systems have some method of displaying CPU utilization. In Windows, this is Task Manager. CPU usage is…blog.codinghorror.com