The Intel 8086 arrived in 1978. The 80286 added protected mode in 1982. The 80386 added 32-bit addressing and the four privilege rings in 1985. By the mid-1990s, x86 was the most widely deployed instruction set on earth — and, according to the prevailing theory, one of the least virtualizable. The obstacle was not raw speed. It was a set of instructions that did the wrong thing quietly.
Rings, and the kernel's assumption
x86 protected mode divides execution into privilege levels called rings. Ring 0 is
the most privileged and is where the operating system kernel expects to run. Ring 3
is where user applications run. The CPU checks the current privilege level (CPL) on
privileged operations: if a ring-3 program executes CLI to disable
interrupts, it gets a general protection fault.
A hypervisor needs ring 0 for itself, because it must control interrupts, page tables and devices. That leaves the guest kernel with nowhere privileged to run. The standard solution is ring deprivileging: move the guest kernel from ring 0 to ring 1 (or ring 3), keep applications in ring 3, and let the hypervisor occupy ring 0. This is sometimes called ring compression, because four rings are squeezed into three effective levels.
The instructions that do not trap
On a well-behaved architecture, every operation that reveals or changes privileged state is itself privileged. x86 was not well behaved. Several instructions execute in ring 3 without faulting, yet their behavior depends on privileged state or is supposed to change it. The guest cannot tell that the hypervisor intervened because there was no intervention to detect.
| Instruction | What the guest expects | What actually happens in ring 1/3 |
|---|---|---|
POPF |
Load flags, including the interrupt flag (IF). | IF is silently left unchanged. The guest believes interrupts are disabled while they remain enabled. |
PUSHF |
Push the guest's flags. | Some bits reflect the real CPU, leaking host state into the guest. |
SGDT / SIDT |
Read the guest's descriptor table registers. | Returns the hypervisor's real table addresses. No fault, direct information leak. |
STR |
Read the task register selector. | Returns a host selector value. |
SMSW |
Read machine status word. | Exposes host-level status bits. |
CALL far / JMP far |
Transfer control through a guest descriptor. | Descriptor caches and validation can behave differently under compression. |
The Popek–Goldberg condition fails here. These instructions are sensitive — they
read or affect privileged state — but they are not privileged. The hypervisor cannot
trap them, so it cannot emulate them, so equivalence breaks. A guest kernel that
disables interrupts with POPF and then waits for a timer tick may hang
forever, or worse, run with interrupts enabled while believing they are off.
On x86, sensitive does not imply privileged. That single sentence explains why the architecture was considered unvirtualizable and why every pre-hardware solution — emulation, translation, paravirtualization — was an elaborate workaround for it.
The address-space problem
CPU instructions were only half the difficulty. A guest kernel expects to control its own page tables and to see a contiguous physical address space starting at zero. The hypervisor must translate guest-physical addresses to real host addresses, and must keep its own memory invisible. On x86, without a second level of address translation, the hypervisor had to either:
- maintain shadow page tables — a host page table that mirrors the guest's, updated whenever the guest changes its own, which is expensive;
- reserve part of the guest's address space for the hypervisor, which changes the machine the guest sees;
- rely on segmentation tricks that break down for 32-bit guests with large address spaces.
Shadow page tables work, and VMware shipped them for years, but every guest page-table update can trigger a trap and a resynchronization. Memory-intensive workloads pay for it. EPT and NPT, covered in Chapter 6, eventually removed this tax.
I/O: the other half of the machine
A guest also expects disks, network cards, timers and a console. On real hardware, devices use memory-mapped I/O (MMIO), port I/O and DMA. MMIO and port accesses can be trapped and emulated, but DMA does not go through the CPU: a device can write anywhere in physical memory unless an IOMMU restricts it. Before IOMMU support, a passthrough device owned by one guest could corrupt another guest's memory, or the hypervisor's.
The safe default was therefore emulated devices: the hypervisor implements a pretend NIC or disk controller in software. It is safe and portable, but every I/O operation costs a VM exit, a context switch and a software device model. High-performance I/O had to wait for paravirtualized drivers (virtio) and hardware IOMMUs.
The three workarounds
Before Intel and AMD added virtualization extensions, three strategies competed:
- Full emulation. Interpret or translate every guest instruction in software. Tools such as Bochs and SoftPC could run an unmodified OS on a different architecture, but the overhead was orders of magnitude. Fine for compatibility, useless for production servers.
- Paravirtualization. Modify the guest kernel so it never executes the problematic instructions; instead it calls the hypervisor explicitly. Xen took this route in 2003. It is fast, but requires a modified guest OS and a hypervisor- aware driver stack.
- Binary translation. Scan guest kernel code before execution, replace sensitive instructions with safe sequences or hypervisor calls, and run everything else directly. VMware built a company on this approach in 1998–1999.
Each workaround is a different answer to the same question: how do you keep the guest from noticing the machine it is running on? Chapter 4 follows the translation route; Chapter 5 follows the cooperation route; Chapter 6 describes the point at which the CPU stopped making everyone choose.
Why the delay mattered
The x86 problem was not just a technical curiosity. It shaped the server market. Because x86 servers were cheap and single-purpose, they were chronically underutilized — typically 5–15% CPU busy. Consolidating many of them onto one virtualized host was an obvious economic win, but only if the overhead was tolerable. Once binary translation made that possible, virtualization moved from mainframes to the commodity data center, and the modern cloud became economically imaginable.
You can still see the legacy of this era in the CPUID hypervisor bit and in
/sys/hypervisor/type. Modern guests are usually told they are
virtualized, because hiding it is no longer worth the effort — but the mechanisms
that made hiding possible are what built the industry.
Sources & further reading
- VMware, Understanding full virtualization, paravirtualization, and hardware assist (PDF, 2007).
- G. J. Popek and R. P. Goldberg, Formal requirements for virtualizable third generation architectures, 1974.
- University of Illinois CS 423, Virtualization lecture notes (PDF).
- Intel, Intel Virtualization Technology documentation.