1 of 25

CSE 451: Operating Systems�Spring 2026Virtual Machines

Rohan Kadekodi

Slides by: Jonathan Trinh

2 of 25

Importance of Virtualization

  • Most compute and storage-intensive work happens in the cloud
  • Example: starting an IT company
    • No virtualization
    • First leap: on-prem VMs
    • Second leap: Cloud�
  • For providers:
    • High utilization of resources

2

3 of 25

Agenda

  • Overview of Virtual Machines
  • General Mechanisms of Virtual Machines
    • System Calls
    • Memory Management
    • I/O

3

4/7/26

4 of 25

Motivation

  • Isolation & Security
    • Developing Operating Systems
      • Isolate system bugs and protect hardware
    • Running and testing dangerous software (“Sandboxing”)
  • Legacy Support for Applications
    • Simulate environments to run legacy programs on modern hardware
  • Data Centers and Cloud Computing
    • Cloud Providers own massive data centers with unbelievable amounts of hardware and server racks
    • Providers run many Virtual Machines on top of their hardware to distribute services to their clients

4

5 of 25

Virtualization

A virtual X is an efficient, isolated duplicate of the real X

X = {processor, memory, disk, machine, network, datacenter}

Virtualization: no changes to code running in the virtual X Paravirtualization: (small) code changes ok

6 of 25

What is a Virtual Machine

  • General Definition: A complete compute environment with its own isolated processing capabilities, memory, and communication channels

6

4/7/26

7 of 25

VM Terminology

  • Host OS: The primary operating system running directly on the physical hardware
  • Guest OS: The operating system running within the Virtual Machine using the virtualized hardware

  • Hypervisor: Software that creates and runs Virtual Machines with main purpose of virtualizing hardware
    • Type-1 (Bare Metal):
      • Ex: Microsoft Hyper-V, VMware, Xen
    • Type-2 (Hosted):
      • Ex: VirtualBox, VMware Workstation, KVM
  • Similarly
    • Host physical memory, guest physical memory, guest virtual memory

7

4/7/26

8 of 25

Standard Kernel Structure

8

4/7/26

Hardware

(Host) OS

App

App

App

Kernel Mode

User Mode

9 of 25

9

4/7/26

Hardware

Hypervisor

Type-1 Hypervisor

Type-2 Hypervisor

VM

Guest

OS

Guest

App

VM

Guest

OS

Guest

App

Hardware

Host OS

VM

Guest

OS

Guest

App

VM

Guest

OS

Guest

App

Hypervisor

Kernel Mode

User Mode

User Mode

10 of 25

Virtual Machine Advantages

  • Encapsulate the application runtime environment
    • Eg, OS version, system call API, machine resource limits
    • Independent of anything else running on the same physical machine
  • Server consolidation
    • Resource sharing for applications that need less than a whole server
    • Allows sharing of hardware between latency and throughput sensitive applications
    • And CPU-intensive and memory-intensive and disk-intensive apps
  • Transparent checkpoint and restart
    • Fault tolerance, server software/hardware upgrades
    • Transparent virtual machine migration
  • Disk storage disaggregation
    • Redirect I/O from virtual machine to a shared service
  • OS kernel debugging

11 of 25

Virtual Machine Challenges

  • What happens when the guest application does a system call?
    • Traps to the host kernel, not the guest kernel; what then?
  • How do we emulate guest kernel mode?
    • Can’t run guest OS in kernel mode (not trusted)
    • What happens when guest OS tries to execute a privileged instruction, such as to

change the page table or initiate I/O?

  • How do we emulate application virtual memory?
    • Host OS page tables: where guest physical memory is in host physical mem
    • Guest OS page tables: where app virtual memory is in guest physical mem
  • How do we emulate I/O devices?
    • Guest OS thinks it has access to physical devices

12 of 25

System-Level Virtual Machines

  • Owns Virtualized Hardware
  • Runs an Operating System of its choice
    • Guest OS runs in user mode*
      • How does Guest OS run privileged instructions?

12

4/7/26

Hardware

Windows + Virtual Box

VM

Linux

Guest App

13 of 25

Virtualized System Calls

    • Trap & Emulate: The Guest OS traps into the hypervisor to handle emulating that instruction
    • Binary Translation: Hypervisor scans and swaps out dangerous instructions
    • Paravirtualization: The Guest OS gets “enlightened” and starts using Hypercalls
    • Hardware-Assisted Virtualization: Modern chips (Intel VT-x or AMD SVM) introduce a Non-Root Mode

13

4/7/26

14 of 25

Scenario: Migration!

  • A finance firm is migrating its infrastructure to a virtualized environment. They have two distinct workloads:
    • Workload A: A proprietary, closed-source risk assessment engine running on an archaic version of Windows. There's no source code available, and the OS is no longer supported by Microsoft. 
    • Workload B: A high-performance, Linux based trading platform built in-house. The engineering team has full access to the kernel and can modify the OS image as needed.�
  • What is the optimal approach for each workload?
    • What's possible? What isn't, given the constraints of each workload?

14

4/7/26

15 of 25

15

16 of 25

Memory Virtualization

16

4/7/26

Guest App

mov rax, addr

OS

PT pointer

Page Table

Memory

data

Virtual Address

Physical

Address (HPA)

TLB

Virtual

addresses

Physical

addresses

17 of 25

Memory Virtualization

17

4/7/26

Guest App

mov rax, addr

Guest OS

Guest PT pointer

Guest Page Table

Memory

data

Virtual Address

TLB

Virtual

addresses

Physical

addresses

Hypervisor

Hardware PT

Pointer

Guest

physical

Address (GPA)

Physical

Address (HPA)

Guest memory map (GPA -> HPA)

18 of 25

Memory Virtualization

18

4/7/26

  • Guest OS has its own page tables
    • Map guest virtual addresses to guest physical memory
  • Host OS has its own page tables
    • Map guest physical memory to host physical memory
  • What happens on a TLB cache miss?
    • Need map from guest virtual address to host physical memory

19 of 25

Shadow Page Table

19

4/7/26

Guest App

mov rax, addr

Guest OS

Virtual PT

Pointer

Guest Page Table

Read Only

Hypervisor

Hardware PT

Pointer

Shadow Page Table

Memory

data

Guest

physical

Address (GPA)

Physical

Address (HPA)

Guest Virtual Address

Guest memory map (GPA -> HPA)

TLB

Virtual

Addresses (GVA)

Physical

Addresses (HPA)

20 of 25

Pros & Cons

  • Pros
    • Portable for both the OS and Hardware
    • Very fast once the Shadow PT is populated

  • Cons
    • Lots of overhead
      • Trap and Emulate
      • All the Page Tables
    • TLB flushes very often

20

4/7/26

21 of 25

Paravirtualization

21

4/7/26

Guest App

mov rax, addr

Guest OS

Virtual PT

Hypervisor

Hardware PT

Pointer

Guest PT

Hypervisor’s PT

Memory

data

Physical

address

Hypercall

Guest VA

22 of 25

I/O Virtualization

  • Full virtualization (Emulation)
    • The Guest OS Traps to Hypervisor
    • Hypervisor performs I/O on its behalf
    • Guest OS is interrupt to start its handler
    • Guest OS after fulfilling I/O Traps to Hypervisor
    • Two Traps per I/O (very slow)
  • VirtIO (Paravirtualization)
    • Use a Virtual Queue to Minimize Traps
    • Guest and Hypervisor agree on a region in Ram for this
    • Requests are batched asynchronously into the hypervisor
    • When done Hyper-V interrupts Guest OS to receive its result

22

4/7/26

23 of 25

VirtIO’s Virtual Queue

23

4/7/26

Tail

RAM

Head

I/O #1

24 of 25

Extra: Containers vs Virtual Machines

  • Containers
    • Uses the Host OS to spin up the container
    • The Host OS handles isolating the Container which acts as a process with its own name space and resources (cgroups)
  • Virtual Machines
    • Uses the Hypervisor to virtualize the hardware
    • Allows the Virtual Machine to run its own Guest OS separate from the Host OS
  • Trade-offs
    • Security:
      • VMs are much more secure since they isolate at a higher level
    • Cost:
      • Containers are more scalable and make better use of hardware resources

24

4/7/26

25 of 25

References

  • Operating Systems Principles and Practice 2nd Ed.
  • Hardware and Software Support for Virtualization
  • Compiler Design: Virtual Machines
  • VMScape
    • Blog on breaking the isolation of Virtual Machines to steal information

25