CSE Roadmap

Core tier · about 3 hours · 6 parts

Part 1 of 6 · 1 min read

Why this page comes first

In this module you will

  • Define a virtual machine and a hypervisor, and tell a type 1 hypervisor from a type 2 one.
  • Explain trap-and-emulate and say why a guest kernel cannot be allowed to run privileged instructions directly.
  • Name the three ways to run a guest: full emulation, paravirtualisation and hardware-assisted virtualisation.
  • Read the signs of a virtual machine on a Linux system (hypervisor flag, lscpu, systemd-detect-virt).
  • Measure the cost of one trapped instruction against one that is not trapped.

Levels 0 to 10 treated the kernel as the one program that owns the machine. This page covers the case where it does not: the kernel itself runs as a guest of another program. It reuses the privilege levels of Level 0, the interrupts of Level 8 and the protection ideas of Level 10. Pages 2 and 3 then show how a hypervisor shares the processor, memory and devices. Pages 4 to 6 turn to containers, which share one kernel and so need none of this.

About this example About this example

Real: All commands and the C program were run on a Linux test machine (kernel 6.18, 2 processors, 8 GiB). It is itself a virtual machine: lscpu reports Hypervisor vendor: KVM, and systemd-detect-virt answers docker for the container layer and kvm for the machine layer.

Scripted: The cost comparison between a trapped and an untrapped instruction is real. The remark about what a laptop or a data-centre server would show is not measured here.

Not real: The test machine hides the hardware virtualisation flags (vmx, svm) and has no /dev/kvm, so it cannot start guests of its own, and the numbers include one more layer of virtualisation than a plain server would show.