Lecture: memory virtualization
administrivia
overview
- read chapter 4 of the textbook
- review page tables
- %cr3, page walking, TLB
- x86 examples
- goal
- vmm needs to run multiple guests
- a guest shouldn’t be able to trash the memory of vmm/other guests
- addresses
- guest virtual/physical address
- host virtual/physical address
- example
- guests 1 & 2, each taking 1GB memory
- one possible layout
- vmm: host physical 0-1G
- guest 1: guest physical 0-1G to host physical 1-2G
- guest 2: guest physical 0-1G to host physical 2-3G
- shadow page tables
- recall from last lecture: performance issues w/o memory virtualization
- guest virtual → host physical
- two-dimensional page tables
- guest physical → host physical
- also known as
- second level address translation (SLAT)
- extended page tables (EPT)
- nested page tables (NPT)
shadow paging
- “A Comparison of Software and Hardware Techniques for x86 Virtualization”, ASPLOS 2006
- strawman
- allocate smaller memory regions for guests
- intercept %cr3 write
- scan & construct a separate, “shadow” page table
- what to ensure in the shadow page table?
- what if the guest constructs a page table that writes to the vmm or other guests?
- problems
- performance
- what if the guest modifies its own page table - is this okay
- what if the guest modifies the shadow page table
- ideas
- lazy construction
- start from empty shadow page table
- add entries during page faults
- cache shadow page tables
- make guest page-table pages read-only
- trap on writes page-table pages
- emulate
- TLB flush
- performance trade-offs
two-dimensional paging
- use EPT as an example
- vmm sets EPT root in VMCS
- vmm construct EPT
- two-dimensional page walking
- “Accelerating Two-Dimensional Page Walks for Virtualized Systems”, ASPLOS 2008, figure 1
- also figure 5.1 of the textbook
- consider n-level guest page table and m-level EPT
- quadratic lookup: (m + 1) * n + m
- 24 for n = 4 and m = 4
- performance trade-offs
- use 2M/1G pages
- when are shadow paga tables faster?