CSE Roadmap

Core tier · about 3 hours · 6 parts

Part 3 of 6 · 2 min read

Memory addresses

Think of a hotel guest who gives a friend the address "room 12, floor 3". The hotel has its own street address, and the front desk maps the room number to a real room that may change from night to night. The analogy stops in one place: a hotel room has one number only, and a VM page has two translations that both cost time.

In plain words: In an ordinary system a program uses virtual addresses, and the page table maps them to physical addresses (Level 6). In a VM there are three. A guest program uses a guest virtual address (GVA). The guest kernel's page table maps it to a guest physical address (GPA), which the guest believes is real memory. The hypervisor maps the GPA to a host physical address (HPA), the real byte in the real chip. The guest controls the first mapping and the hypervisor controls the second. The guest cannot be allowed to write the real page table, because it could map any real memory, including another guest's.

A worked example. A guest process reads GVA 0x7f000. The guest page table says that page maps to GPA page 0x40. The hypervisor's table says that GPA page 0x40 of this guest is HPA page 0x9A3. The real access goes to HPA page 0x9A3. If the hypervisor later moves the guest's page 0x40 to HPA page 0x211 (for example, to compact memory or to swap it), only the second table changes, and the guest never knows.

The key lines. Two translations must be combined for every access. How the hardware combines them is the next section.

Guest physical address

A guest physical address (GPA) is an address in the memory that a guest believes is real. The hypervisor maps each GPA to a host physical address (HPA) in real memory, and may change that mapping without the guest knowing.

Example: GPA page 0x40 of one guest sits in real page 0x9A3.

Check yourself: 1. Name the three kinds of address in a VM. 2. Which mapping does the guest control, and which the hypervisor? 3. Why can the guest not write the real page table?