Monday, May 14, 2018

Memory Virtualization

Virtual Memory

Virtual memory, implemented in both hardware and software, is a memory management technique that maps memory address called virtual address or logical address into physical memory in computer hardware.

The benefits of virtual memory includes freeing applications from managing shared memory, increased security due to memory isolation and the capability of using more memory than present by paging.

VM Memory Virtualization

The VMM/Hypervisor manages machine memory and assign part of it to virtual machines.  The guest OS continues to control the mapping from virtual address (VA) to guest physical address (PA), however it doesn't have access to underlying machine physical memory (MA). VMM is responsible for  PA-to-MA mapping.

Shadow Page Table

Shadow tables maps guest virtual memory (VA) to machine physical memory (MA). VMM manages a virtual PTBR and real PTBR - MMU virtualization. When guest OS modifies PTBR, it will intercepted by VMM for further emulation.  

Each process on guest OS consumes two page, one is on guest OS and the other is shadow page.  A page fault caused by guest OS lauches walking process that costs a lot of overhead.

Hardware-Assisted Memory Virtualization

Some CPUs introduce two-level page address translation: first level of page tables stores guest virtual-to-physical translations while second level stores guest physical-to-machine translation. HW-assisted memory virtualization eliminates the overhead for software memory virtualization and is preferable for applications that have a large mount of page table miss when executing.

References

1. https://www.d.umn.edu/~gshute/os/virtual-memory.xhtml
2. https://pubs.vmware.com/vsphere-51/index.jsp#com.vmware.vsphere.resmgmt.doc/GUID-69CDC049-8B42-4D26-8B47-94961B1777A4.html
3. http://www.cs.nthu.edu.tw/~ychung/slides/Virtualization/VM-Lecture-2-2-SystemVirtualizationMemory.pptx

No comments:

Post a Comment