Reaves.dev

v0.1.0

built using

Phoenix v1.7.12

Memory Virtualization

Stephen M. Reaves

::

2024-01-25

Notes about Lecture 3b for CS-6210

Summary

Memory Hierarchy

Thorny issue

Memory Subsystem Recall

Each application in its own protection domain

OS maintains pagetable on behalf of each process

Memory Management and Hypervisor

In each application on each OS on the hypervisor, we have separate protection domains.

Each guest OS’s protection domains are distinct from every other guest OS’s.

Memory Manager Zoomed Out

Each guest OS thinks it has contiguous memory, but, just like user processes, it’s actually mapped non-contiguously

Zooming Back In

Virtual Page Number (VPN) in process gets mapped to Physical Page Number (PPN) in OS.

PPN in OS gets mapped to Machine Page Number (MPN) in hardware.

In paravirtualization, guest OS maintains S-PT

Shadow Page Table

In many architectures, CPU uses page table for address translation.

Hardware page table is really S-PT

Efficient Mapping (Full Virtualization)

Updating PageTable is a privileged operation, which results in a trap

This means hypervisor can translate VPN to MPN directly

Efficient Mapping (Para Virtualization)

Shift burden to Guest OS

OS makes hypercalls to hypervisor to create page table, move page table, etc., then maintains its own mapping from VPN to this page table.

Dynamically Increasing Memory

You can rob one guest of memory to provide memory for others if its bursty

Install special device driver in every guest OS

Sharing Memory Access Across Virtual Machines

Can we share memory in a safe way acros VMs?

Deduplication of code loaded into memory is potentially huge

This can be done by marking memory pages as Copy On Write (COW) so changes are not overwritten.

VM Oblivious Page Sharing

An alternative is to hash page frame contents

Memory Allocation Policies