06 Memvirt
06 Memvirt
Address = X
Code/data Address = Y’
Stack
Heap
(guest user Address = Y
process) Address = Z’
Special EPT
pointer register
MMU
• Page table walk by MMU: Start walking guest page table using GVA
• Guest PTE (for every level page table walk) gives GPA (cannot use GPA to access memory)
• Use GPA, walk host page table to find HPA, then access memory page, then next level access
• Every step in guest page table walk requires walking N-level host page table
• N-level page tables in guest/host result in page table walk of NXN memory accesses
Shadow page tables
Read only
Address = X
Address = Y’
Address = Y
• Guest OS may not assign a physical Address = Z’
frame to a page
• No entry in page table, page fault
Address = Z • VMM may not assign frames to all
• VM exit, VMM handles page fault,
guest “RAM” pages due to
injects fault into guest
memory pressure
• Guest assigns physical frame
• Page fault is handled by VMM
• Guest OS not aware of this fault
• “Hidden” page faults
Memory reclamation technqiues
• VMM reclaims memory from guest “RAM” under memory pressure
• Uncooperative swapping: VMM reclaims some guest “RAM” pages and swaps
them to disk
• Page fault and memory assigned when guest accesses the page
• May hurt performance, important pages may be swapped to disk
• Ballooning: VMM opens dummy device, requests pages from VM (“inflating
the balloon”), then swaps these pages out
• Since pages assigned to a device, pages not used by other processes in guest
• Cooperative, guest can assign free pages
• Lesser impact on performance, but reclamation takes time, requires guest changes
• Memory sharing: memory pages with identical content across VMs (OS
images, zero pages etc.) shared between VMs
• One physical frame mapped into page tables of multiple guests
• Scan pages periodically to compute and match hash-based similarity of pages
Summary
• Memory virtualization
• Extended page tables
• Shadow page tables
• Memory reclamation techniques
• Uncooperative swapping
• Ballooning
• Memory sharing