What is a hypervisor, and what is the difference between type 1 and type 2?
Short answer: A hypervisor (virtual machine monitor) creates and runs virtual machines, sharing the physical CPU, memory and devices between them while keeping them isolated. A type 1 (bare-metal) hypervisor runs directly on the hardware (Xen, VMware ESXi, QNX Hypervisor, many automotive hypervisors). A type 2 (hosted) hypervisor runs as a program on a normal OS (VirtualBox, QEMU with TCG). KVM turns Linux itself into a hypervisor, so it is usually described as type 1, with QEMU as its user-space helper.
What a hypervisor must provide
- CPU virtualization: each VM has virtual CPUs; privileged operations by the guest kernel are trapped and handled.
- Memory virtualization: each VM sees its own "physical" memory, mapped by the hypervisor to real RAM (stage-2 / EPT page tables).
- Device and interrupt virtualization: emulated devices, paravirtual devices (virtio) or real devices passed through (VFIO with an IOMMU/SMMU).
- Isolation: a crash or attack in one VM must not affect the others.
Where KVM fits
+-------------------+ +-------------------+
| Guest OS (EL1) | | Guest OS (EL1) |
| QEMU process | | QEMU process | <- user space on the host
+-------------------+---+-------------------+
| Linux kernel + KVM (EL2 with VHE) | <- host OS *is* the hypervisor
+-------------------------------------------+
| Hardware |
+-------------------------------------------+
Embedded and automotive angle: a single SoC runs a safety-relevant instrument cluster (an RTOS or Linux) next to the infotainment system (Android) under a type-1 hypervisor. The hypervisor guarantees that an Android crash cannot take the cluster down. Examples: QNX Hypervisor, Xen (with the Arm safety work), PikeOS, ACRN (x86), and KVM-based solutions.
Related terms: paravirtualization (the guest knows it is virtualized and calls the hypervisor directly, e.g. virtio, Xen PV), full virtualization (an unmodified guest), and containers, which share one kernel and are not virtual machines.