Virtualization & Containers

hardware-assisted virtualization

Hardware-assisted virtualization is the modern answer to the old x86 problem, solved this time by changing the CPU itself rather than by tricks in software. Recall the headache: the old x86 could not be cleanly virtualized by trap-and-emulate, so people resorted to binary translation or paravirtualization. The cleaner fix was for chip makers to add a brand-new execution mode designed for guests. Intel calls its version VT-x and AMD calls its AMD-V, and together they turned the problematic x86 into one that virtualizes properly in hardware.

The mechanism adds a distinct guest mode that sits beneath the normal privileged mode, plus a host mode for the hypervisor. The guest's kernel can now run in this guest mode at full privilege from its own point of view, executing even sensitive instructions directly — and the CPU is configured so that exactly the operations the hypervisor cares about cause a clean, controlled exit (a VM exit) back into host mode. The hypervisor handles the event, then resumes the guest with a VM entry. A control structure in memory lets the hypervisor specify precisely which guest events should trap. This makes every sensitive instruction trappable by design, which is exactly the property the old x86 lacked.

The payoff is that the hypervisor can run an unmodified guest OS at near-native CPU speed with far less software trickery — no binary translation needed for the CPU. The remaining cost is the VM exits themselves: each transition between guest and host is not free, so the art moved to making exits rare (helped further by nested page tables for memory and paravirtual virtio drivers for I/O). Hardware-assisted virtualization is what makes today's dense, fast clouds practical.

An unmodified copy of Windows runs as a guest. Its kernel disables interrupts and reloads control registers freely in guest mode — no binary translation, no source changes. Only when it does something the hypervisor must oversee does the CPU perform a VM exit, hand control to the hypervisor for a moment, and then resume.

A dedicated guest CPU mode lets an unmodified OS run fast, trapping only when the hypervisor must step in.

Hardware-assisted virtualization removes the need for binary translation on the CPU, but it does not make virtualization free: frequent VM exits are costly, which is why nested page tables and paravirtual I/O drivers are still used to cut the number of exits.

Also called
HVMIntel VT-xAMD-V硬體虛擬化