4.2.40 · D1Operating Systems

Foundations — Virtualization — type 1 and type 2 hypervisors

1,890 words9 min readBack to topic

Before you can judge where a hypervisor sits (that's the whole Type-1-vs-Type-2 question in Virtualization — type 1 and type 2 hypervisors), you must own a small pile of words the parent note quietly assumes. We build each from zero, in an order where every new idea only leans on ones already standing.


1. Hardware / "bare metal"

The picture: imagine a flat slab at the bottom of a tower. Everything we build in this topic stacks on top of this slab.

Why the topic needs it: the entire Type 1 vs Type 2 split is the single question "what software touches this slab directly?" If you don't have a mental slab, the question is meaningless.

Figure — Virtualization — type 1 and type 2 hypervisors

2. Instruction

The picture: a conveyor belt of little cards; the CPU picks up one card, does exactly what it says, and grabs the next.

Why the topic needs it: a hypervisor's job is to watch the conveyor belt and grab certain dangerous cards before the CPU does something the guest shouldn't be allowed to do.


3. Kernel mode vs user mode (CPU privilege rings)

Not all instruction-cards are equally dangerous. "Add 2 + 2" is harmless. "Reconfigure all of memory" or "talk directly to the disk" could crash the whole machine. So the CPU physically refuses to run the dangerous ones unless it is in a special trusted state.

The picture: two rings, one inside the other. The inner ring (kernel) can do anything; the outer ring (user) is fenced off from the dangerous controls. This is exactly the model in CPU Privilege Rings.

Figure — Virtualization — type 1 and type 2 hypervisors

Why the topic needs it: the hypervisor's trick is to run itself in the innermost ring and shove each guest OS out to a less powerful ring — even though the guest OS thinks it's still king. That demotion is the heart of "trap-and-emulate".


4. Privileged instruction & the "trap"

The picture: a tripwire. The guest walks along running instructions; the moment it steps on a privileged instruction while in the low-privilege ring, a wire trips and control is flung down to the hypervisor.

Why the topic needs it: "trap-and-emulate" is the parent note's core mechanism. Trap = the tripwire firing. Emulate = the hypervisor faking a believable result and handing control back. No trap concept, no understanding of how one machine safely pretends to be many.

Figure — Virtualization — type 1 and type 2 hypervisors

5. Sensitive instruction

The picture: on the conveyor belt, colour the cards. Grey cards are harmless. Red cards are sensitive — they touch shared machine state.

Why the topic needs it: the Popek & Goldberg rule (parent note) says a machine is cleanly virtualizable only if every red (sensitive) card is also a tripwire-card (privileged). If some red card is not a tripwire, it slips past the hypervisor unnoticed — and that is exactly the old-x86 POPF problem the parent describes. Symbols in words:


6. Operating system, host OS, guest OS

The picture: a Russian nesting doll. In Type 2, the outer doll is the host OS; inside it sits the hypervisor; inside that sits the guest OS. In Type 1 there is no outer host doll — the hypervisor is the outermost software itself.

Why the topic needs it: "host OS present or absent" is literally the Type 2 vs Type 1 distinction. These two words are the vocabulary the whole comparison table is written in.


7. Virtual machine (VM)

The picture: a sealed glass box. Inside, a guest OS runs happily believing the box is a real computer. The hypervisor is the glass — it lets the guest see a reflection of hardware, never the real thing directly. Contrast this heavy full-machine box with the lighter approach in Containers vs Virtual Machines.

Why the topic needs it: this is the product a hypervisor makes. Everything above is the machinery; the VM is the output.


8. Layer & "layers to silicon"

The picture: a relay race. Every extra runner (layer) who must receive and pass the baton adds delay before it reaches the finish line (the hardware).

Why the topic needs it: this counting is the entire quantitative argument for "Type 1 is faster", including Example 3 in the parent note.


The prerequisite map

Hardware / bare metal

Instructions on the CPU

Kernel mode vs user mode

Privileged instructions

Trap = involuntary jump to handler

Sensitive instructions

Popek Goldberg condition

Operating system

Host OS and Guest OS

Virtual machine

Layers to silicon

Type 1 vs Type 2 hypervisors

Read top to bottom: raw hardware gives us instructions; the danger of some instructions forces privilege modes; that gives us traps and sensitive instructions, whose relationship (Popek–Goldberg) makes safe virtualization possible; layered software then produces VMs, and how many layers is the Type 1 / Type 2 answer.


Equipment checklist

Cover the right side and test yourself. If any answer surprises you, re-read that section above.

What "bare metal" means
The raw physical hardware with no software layer added yet.
What one instruction is
A single tiny command the CPU executes; a program is a list of them.
The difference between kernel mode and user mode
Kernel mode = full power over hardware; user mode = restricted, dangerous instructions forbidden.
What a privileged instruction is
One the CPU will only run in kernel mode; attempting it in user mode causes a trap.
What a trap is
An involuntary hardware-forced jump from running code to a trusted handler.
What a sensitive instruction is
One that changes or depends on shared machine state.
The Popek–Goldberg condition in words
Every sensitive instruction must also be privileged (sensitive ⊆ privileged) for clean trap-and-emulate.
Guest OS vs host OS
Guest = OS fooled inside a VM; host = real OS owning the hardware and running a Type 2 hypervisor as an app.
What a virtual machine is
A software-built illusion of a whole computer, ultimately just files.
Why Type 1 is faster than Type 2 in one word
Fewer layer crossings (no host-OS hop).
Recall Feynman check: say it in one breath

The CPU has a lock (privilege rings). Dangerous instructions need the key. The hypervisor holds the only key and demotes each guest, so whenever a guest tries a dangerous move the hardware trips (traps) into the hypervisor, which fakes a nice answer. That's how one real computer safely pretends to be many.