introduction to virtual machines

Post on 25-Feb-2016

92 Views

Category:

Documents

5 Downloads

Preview:

Click to see full reader

DESCRIPTION

Introduction to Virtual Machines. Scott Devine Principal Engineer, Co-Founder VMware, Inc. Outline. What is virtualization? How-to virtualize CPU Memory I/O. What is Virtualization. Linux. Linux (devel). XP. Vista. MacOS. Virtual Machine Monitor. Hardware. Isomorphism. - PowerPoint PPT Presentation

TRANSCRIPT

Introduction to Virtual Machines

Scott DevinePrincipal Engineer, Co-Founder

VMware, Inc.

Outline

• What is virtualization?• How-to virtualize– CPU – Memory– I/O

What is Virtualization

Hardware

Virtual Machine Monitor

Linux Linux (devel) XP Vista MacOS

Isomorphism

Formally, virtualization involves the construction of an isomorphism from guest state to host state.

GuestSi Sj

HostSi’ Sj’

e(Si)

e’(Si’)

V(Si) V(Sj)

Virtualization Properties

• Isolation• Encapsulation• Interposition

Types of Virtualization

• Process Virtualization– Language construction– Cross-ISA emulation• Apple’s 68000-PowerPC-Intel Transition

• Device Virtualization– RAID

• System Virtualization– VMware– Xen– Microsoft’s Hyper-V

System Virtualization Applications

• Server Consolidation• Data Center Management– VMotion

• High Availability– Automatic Restart

• Disaster Recovery• Fault Tolerance• Test and Development• Application Flexibility

CPU Virtualization

• Trap and Emulate• Binary Translation

Privileged State

State of the processor is privileged if• access to that state breaks the virtual

machine’s isolation boundaries• if it is needed by the monitor to implement

virtualization

Trap and Emulate

Guest OS + Applications

Virtual Machine Monitor

PageFault

UndefInstr

vIRQ

MMUEmulation

CPUEmulation

I/OEmulation

Unp

rivile

ged

Priv

ilege

d

“Strictly Virtualizable”

A processor or mode of a processor is strictly virtualizable if, when executed in a lesser privileged mode:

• all instructions that access privileged state trap

• all instructions either trap or execute identically

• …

Issues with Trap and Emulate

• Not all architectures support it• Trap costs may be high• Monitor uses a privilege level– Need to virtualize the protection levels

Binary Translation

vEPC mov ebx, eax

cli

and ebx, ~0xfff

mov ebx, cr3

sti

ret

mov ebx, eax

mov [VIF], 0

and ebx, ~0xfff

mov [CO_ARG], ebx

call HANDLE_CR3

mov [VIF], 1

test [INT_PEND], 1

jne

call HANDLE_INTS

jmp HANDLE_RET

start

Guest Code Translation Cache

Controlling Control Flow

vEPC test eax, 1

jeq

add ebx, 18

mov ecx, [ebx]

mov [ecx], eax

test eax, 1

jeq

call END_BB

vEPC

call END_BB

vEPC

start

Guest Code Translation Cache

ret

Controlling Control Flow

vEPC

test eax, 1

jeq

add ebx, 18

mov ecx, [ebx]

mov [ecx], eax

test eax, 1

jeq

call END_BB

vEPC

call END_BB

vEPC

Guest Code Translation Cache

ret

add ebx, 18

mov ecx, [ebx]

mov [ecx], eax

call HANDLE_RETeax == 0

findnext

Controlling Control Flow

vEPC

test eax, 1

jeq

add ebx, 18

mov ecx, [ebx]

mov [ecx], eax

test eax, 1

jeq

jmp

call END_BB

vEPC

Guest Code Translation Cache

ret

add ebx, 18

mov ecx, [ebx]

mov [ecx], eax

call HANDLE_RETeax == 0

Controlling Control Flow

vEPC

test eax, 1

jeq

add ebx, 18

mov ecx, [ebx]

mov [ecx], eax

test eax, 1

jeq

jmp

call END_BB

vEPC

Guest Code Translation Cache

ret

add ebx, 18

mov ecx, [ebx]

mov [ecx], eax

call HANDLE_RETeax == 1

findnext

mov [ecx], eax

call HANDLE_RET

Controlling Control Flow

vEPC

test eax, 1

jeq

add ebx, 18

mov ecx, [ebx]

mov [ecx], eax

test eax, 1

jeq

jmp

jmp

Guest Code Translation Cache

ret

add ebx, 18

mov ecx, [ebx]

mov [ecx], eax

call HANDLE_RETeax == 1 mov [ecx], eax

call HANDLE_RET

Issues with Binary Translation

• Translation cache index data structure• PC Synchronization on interrupts• Self-modifying code– Notified on writes to translated guest code

Other Uses for Binary Translation

• Cross ISA translators– Digital FX!32

• Optimizing translators– H.P. Dynamo

• High level language byte code translators– Java– .NET/CLI

New Hardware Support for CPU Virtualization

• New guest mode• Guest control block– Specifies guest state

• New operations– VM enter– VM exit

Memory Virtualization

• Shadow Page Tables• Nested Page Tables

Traditional Address Spaces

Virtual Address Space

0 4GB

Physical Address Space

0 4GB

Traditional Address Translation

Virtual Address Physical Address

ProcessPage Table

1 2

2

3

4 5

TLB

Operating System’s Page Fault Handler

Virtualized Address Spaces

Virtual Address Space

0 4GB

Physical Address Space

0

Machine Address Space

0

Guest Page Table

VMM PhysMap

4GB

4GB

Virtualized Address Spacesw/ Shadow Page Tables

Virtual Address Space

0 4GB

Physical Address Space

0

Machine Address Space

0

Guest Page Table

VMM PhysMap

4GB

4GB

Shad

owPa

ge T

able

Virtualized Address Translationw/ Shadow Page Tables

Virtual Address Machine Address

ShadowPage Table

GuestPage Table PMap

1 2

2

3

45

3

6

TLB

A

Issues with Shadow Page Tables

• Guest page table consistency– Rely on Guest’s need to invalidate TLB

• Performance considerations– Aggressive shadow page table caching necessary– Need to trace writes to cached page tables

Virtualized Address Spacesw/ Nested Page Tables

Virtual Address Space

0 4GB

Physical Address Space

0

Machine Address Space

0

Guest Page Table

VMM PhysMap

4GB

4GB

Virtualized Address Translationw/ Nested Page Tables

Virtual Address Machine Address

GuestPage Table

PhysMapBy VMM

1

2

TLB

3

2

3

Issues with Nested Page Tables

• Positives– Simplifies monitor design– No need for page protection calculus

• Negatives– Guest page table is in physical address space– Need to walk PhysMap multiple times

• Need physical to machine mapping to walk guest page table• Need physical to machine mapping for original virtual address

• Other Memory Virtualization Hardware Assists– Monitor Mode has its own address space

• No need to hide the monitor

VM1

Interposition with Memory VirtualizationPage Sharing

Virtual

Physical

Machine

Read-OnlyCopy-on-wrte

VM2

Virtual

Physical

I/O Virtualization

Hardware

Guest

H.W. Device Driver H.W. Device Driver

Virtual Device Driver

Virtual Device Model

Abstract Device ModelDevice Interposition

Compression Bandwidth Control Record / ReplayOvershadowPage Sharing Copy-on-Write DisksEncryption Intrusion Detection Attestation

Device Back-endsRemote Access Cross-device Emulation Disconnected Operation

MultiplexingDevice Sharing Scheduling Resource Management

Virtual Device Driver

Virtual Device Model

Virtual Device Driver

Virtual Device Model

Issues with I/O Virtualization

• Need physical memory address translation– need to copy– need translation– need IO MMU

• Need way to dispatch incoming requests

top related