lecture 1: so … what is a virtual machine? · unix hp apps. process vm: high level language...

42
Virtual Machines: Concepts & Applications Mohamed Zahran (aka Z) [email protected] http://www.mzahran.com CSCI-GA.3033-015 Lecture 1: So … What Is A Virtual Machine? Disclaimer: Many slides of this lecture are based on the slides of authors of the textbook from Elsevier. All copyrights reserved.

Upload: others

Post on 24-Jun-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Virtual Machines: Concepts & Applications

Mohamed Zahran (aka Z)

[email protected]

http://www.mzahran.com

CSCI-GA.3033-015

Lecture 1: So … What Is A Virtual Machine?

Disclaimer: Many slides of this lecture are based on the slides of authors of the textbook from Elsevier. All copyrights reserved.

Page 2: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Who Am I?

• Mohamed Zahran (aka Z) • http://www.mzahran.com • Research interest:

– computer architecture – hardware/software interaction – Biologically-inspired machines

• Office hours: Tue 1-3 pm – or by appointment

• Room: WWH 320

Page 3: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Formal Goals of The Course • Understand VM architectures and

applications

• Study key implementation technologies

• Focus on architecture and microarchitecture aspects; as well as software aspects

• Cover significant case studies

Page 4: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Informal Goals of This Course

• Be an expert in how programming languages, compilers, OS, and computer architecture interact together!

• Be able to use the technology learned in this course in many different situations

• Build a vision about technology and its future

•Enjoy the course

Page 5: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

The Textbook

Page 6: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Grades

• You have 3 sources of study information: – Slides

– Notes you take in class

– Reading material from the textbook

• Exam is open book/notes

• Grade distribution: – Homework assignments 30%

– Project 30%

– Final exam 40%

Page 7: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

We Have to Admit that …

• Computers are very complicated structures!

• In order to manage/design them, we need to be able to manage extreme complexity!

• The best way to do that is through: levels of abstraction with well defined interfaces

Page 8: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Abstraction

• Computer systems are built on levels of abstraction

Higher level of abstraction hide

details at lower levels

Example: files are an abstraction of a disk

file file

abstraction

I/O devices

and

Networking

Controllers

System Interconnect

(bus)

Controllers

Memory

Translation

Execution Hardware

DriversMemory

ManagerScheduler

Operating System

Libraries

Application

Programs

Main

Memory

Software

Hardware

Page 9: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Abstraction provides: Simplified interface to underlying resources.

Page 10: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

High Level Language

Assembly Language

Machine Language

Microarchitecture

Logic Level

Problem Algorithm Development Programmer

Compiler (translator)

Assembler (translator)

Control Unit (Interpreter)

Microsequencer (Interpreter)

Device Level Semiconductors Quantum

Page 11: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Advantages of Well-defined Interfaces • Major design tasks are decoupled • Different hardware and software development schedules

• Example of interfaces: – Instruction set architecture (ISA) – OS interface (system calls)

• Software can run on any machine supporting a compatible interface

PowerPC or x86

MacOS

MacIntosh apps.

x86

Linux

Linux apps

x86

Windows

Windows apps.

Page 12: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

12

Major Program Interfaces • ISA Interface -- supports all conventional

software System Calls

User ISA System ISA ISA

Application Software

Operating System

System Calls

User ISA System ISA ABI

Application Software

Operating System

Application Binary Interface (ABI) -- supports application software only

Page 13: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

There are also disadvantages… • Software compiled for one ISA will not run on

hardware with a different ISA – Apple Mac (PowerPC) binaries on an x86?

• Even if ISAs are the same, OSes may differ – Windows NT applications on a Solaris x86?

• Binary may not be optimized for the specific hardware platform it runs on – Intel Pentium 4 binaries on an AMD Athlon?

MacOS

MacIntosh apps

ARM x86

Windows apps.

Linux

Page 14: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Disadvantages (contd.) • Innovation may be inhibited by fixed ISA

– Hard to add new instructions • OR remove obsolete ones

– What was the most recent (successful) new ISA? Or new OS?

• Difficult for software to interact directly with implementation – Performance features – Power management – Fault tolerance – Software is supposed to be implementation independent

Page 15: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Diversity in instruction sets, OSes, and programming languages

Encourages innovations Discourages stagnation

BUT In practice, diversity leads to reduced interoperability.

How to deal with this in our world of networked computers, where it is advantageous To move software as freely as data??

Page 16: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

A Look at Hardware Resources • Conventional system software manages

hardware resources directly – An OS manages the physical memory of a

specific size – I/O devices are managed as physical entities

• Difficult to share resources except through OS – All users of hardware must use the same OS – All users are vulnerable to attack from other

users sharing the resource (via security holes in OS)

Can we do better?

Page 17: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Virtualization is the answer! • Real system is transformed so that it appears

to be different!

• An isomorphism from guest to host – Map guest state to host state

– Implement “equivalent” functions

S i S

S i ' S j '

Guest

Host

V( S i ) V( S j )

e (S i )

e '(S i ')

j

Page 18: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Virtualization

• Similar to abstraction Except

– Details not necessarily hidden

• Construct Virtual Disks – As files on a larger disk

– Map state

– Implement functions

file file

virtualization

abstraction

Page 19: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

The “Machine”

• Different perspectives on what the Machine is: – OS developer – Compiler developer – Application programmer

I/O devices and

Networking

System Interconnect (bus)

Memory Translation

Execution Hardware

Application Programs

Main Memory

Operating System

Libraries

Page 20: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform
Page 21: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Hardware "Machine"

OS

Applications

Virtualizing Software

Virtual Machine

OS

Applications

Guest

VMM

Host

Virtual Machines

add Virtualizing Software to a Host platform and support Guest process or system on a Virtual Machine (VM) Example: System Virtual Machine

Page 22: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Example of VM Usages

• A virtualizing software installed on an Apple Macintosh can provide a Windows/IA-32 VM capable of running PC application programs.

• Multiple, replicated VMs can be implemented on a single hardware platform to provide groups/individuals with their own OS environments

Page 23: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Example of VM Usages

• A large multiprocessor server can be divided into smaller virtual servers.

• VM can provide dynamic, on-the-fly optimization of program binaries.

• …

Page 24: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

The Family of Virtual Machines • Lots of things are called “virtual machines”

IBM VM/370

Java

VMware

Some things not called “virtual machines”, are virtual machines

IA-32 EL

Dynamo

Transmeta Crusoe

Page 25: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Virtual Machines

Process Virtual Machines System Virtual Machines

The process of virtualization involves two steps: 1. Mapping of virtual resources or state to real resources of the underlying machine. 2. Using real machine instructions and/or system calls to carry out the actions specified by the VM instructions.

Page 26: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Process VMs • Execute application binaries with an ISA different from

hardware platform • Provide user application with a virtual ABI environment • Can provide: replication, emulation, and optimization • Examples: IA-32 EL, FX!32

Virtualizing Software

Application Process

Machine

OS

Hardware

Guest

Runtime

Host

Application Process

Virtual Machine

Page 27: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Process Virtual Machines

• Constructed at ABI level

• Runtime manages guest process

• Not persistent

• Guest processes may intermingle with host processes

• As a practical matter, guest and host OSes are often the same

• Dynamic optimizers are a special case

• Examples: IA-32 EL, FX!32, Dynamo

HOST OS

Disk

file sharing

network communication

guest process

create

host process

guest process

runtime runtime

guest process

runtime

host process

Page 28: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Example of Process VM: FX!32

Application compiled for source ISA (in this example IA-32)

Executed on a machine with target ISA (in this example Dec Alpha)

Page 29: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Process VM: Replication

• OS providing the illusion of multiprogramming

• Each user process thinks it has the complete machine to itself

Page 30: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Process VM: Emulation

• Supports program binaries compiled for a different instruction set than the host hardware emulates one instruction set on hardware designed for another instruction set

• Interpretation Vs Translation

Page 31: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Process VM: Optimization Same-ISA Dynamic Binary Optimizers

• Optimize Binary at Runtime

• Instruction sets for host and guest are the same

• Example HP Dynamo – Can optimize for dynamic

properties of program

– Can optimize for a specific processor implementation

HP PA

UNIX

HP Apps

Page 32: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Process VM: High Level Language Virtual Machines

• VM environment does not directly correspond to any real platform • VM environment designed for:

– ease of portability – to match features of HLL used for program development.

HLL Program

Intermediate Code

Memory Image

Object Code ( ISA )

Compiler front-end

Compiler back-end

Loader

HLL Program

Portable Code ( Virtual ISA )

Host Instructions

Virt. Mem. Image

Compiler

VM loader

VM Interpreter/Translator

Traditional HLL VM

Page 33: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

HLL VM: Example JVM

Sparc Workstation

Java Binary Classes

x86 PC

Apple Mac

VM implementation

VM implementation

VM implementation

Java VM Architecture

Page 34: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

System Virtual Machines

• Provide a complete system environment

• Constructed at ISA level

• Persistent

• Examples: IBM VM/360, VMware, Transmeta Crusoe

guest process

HOST PLATFORM

Guest OS

VMM

guest process

guest process

guest process

Guest OS2

VMM

guest process

guest process

A single host hardware platform can support multiple guest OS environments simultaneously.

Page 35: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

System Virtual Machines

• Native VM System – VMM privileged mode

– Guest OS user mode

– Example: classic IBM VMs

• User-mode Hosted VM – VMM runs as user

application

• Dual-mode Hosted VM – Parts of VMM

privileged; parts non-privileged

– Example VMware

Non-privileged modes

Privileged

Mode

Virtual

Machine

VMM

Hardware

Virtual

Machine

Host OS

Hardware

VMM

Virtual

Machine

Host OS

Hardware

VMM

Page 36: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Examples

Page 37: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Examples

Page 38: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Co-Designed VMs

Different objective:

Enable innovative ISA and/or hardware implementation for improved performance and/or power.

Page 39: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Co-Designed VMs

VLIW

Windows

X86 Apps

Perform both translation and optimization

VM provides interface between standard ISA software and implementation ISA

Transmeta Crusoe and IBM Daisy best-known examples

Page 40: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Composition: Example

Java application

Linux x86

JVM

Windows x86

VMware

Crusoe VLIW

Binary Translation

A computer user has a Java application running on laptop PC

The user has Linux installed on Windows PC via Vmware.

The IA-32 hardware is in fact a Transmeta Crusoe implementing VLIW ISA.

Page 41: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Taxonomy

Multiprogrammed Systems

Java VM MS CLI

Transmeta Crusoe

same ISA different

ISA

Process VMs System VMs

Virtual PC for Mac

different ISA

same ISA

IBM VM/370 VMware

HP Dynamo

IA-32 EL FX!32

Page 42: Lecture 1: So … What Is A Virtual Machine? · UNIX HP Apps. Process VM: High Level Language Virtual Machines • VM environment does not directly correspond to any real platform

Conclusions • Virtualization will be a key part of future

computer systems. • A fourth major discipline? (with HW,

System SW, Application SW) • VMs have been investigated and built by

OS developers, language designers, compiler developers, and hardware designers!

• In this course, we will study the underlying concepts and technologies that are common across the whole spectrum.