Virtual Machines: Versatile Platforms for Systems and Processes J. E. Smith University of Wisconsin-Madison Ravi Nair IBM Thomas J. Watson Research Center INTRODUCTION This material is based on the book, Virtual Machines: Versatile Platforms for Systems and Processes, Copyright 2005 by Elsevier Inc. All rights reserved. It has been used and/or modified with permission from Elsevier Inc. Course Objectives Study VM architectures and applications Study key implementation technologies Focus on architecture and microarchitecture aspects Cover significant case studies Introduction 3 Introduction Why are virtual machines interesting? They allow transcending of interfaces (which often seem to be an obstacle to innovation) They enable innovation in flexible, adaptive software & hardware, security, network computing (and others) They involve computer architecture in a pure sense Virtualization will be a key part of future computer systems A fourth major discipline? (with HW, System SW, Application SW) Introduction 4 Advantages of Standard Interfaces Major design tasks are decoupled • In space and time Different hardware and software development schedules Software can run on any machine supporting a compatible interface MacIntosh apps. MacOS PowerPC Introduction Windows apps. Windows x86 Linux apps Linux x86 5 There are also disadvantages… Software compiled for one ISA will not run on hardware with a different ISA • Even if ISAs are the same, OSes may differ • Apple Mac (PowerPC) binaries on an x86? 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? MacIntosh apps MacOS x86 Introduction Windows apps. Linux x86 6 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 Introduction 7 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) Introduction 8 Abstraction Software 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 Application Programs fileLibraries file Operating System abstraction Drivers Memory Manager Scheduler Execution Hardware System Interconnect (bus) Memory Translation Controllers Controllers I/O devices and Networking Main Memory Hardware Introduction 9 Virtualization An isomorphism from guest to host Map guest state to host state • Implement “equivalent” functions • e(Si ) Si Sj Guest V(Si ) V(Sj ) e'(Si') Si' Sj' Host Introduction 10 Virtualization Similar to abstraction Except • Details not necessarily hidden Construct Virtual Disks • • • virtualization file file As files on a larger disk Map state Implement functions VMs: do the same thing with the whole “machine” Introduction 11 The “Machine” Different perspectives on what the Machine is: OS developer Compiler developer Application programmer Application Programs Libraries Operating System Execution Hardware Instruction Set Architecture Application Program Binary Interface Interface •• • • ISA API ABI Major division User User ISA ISA ++ library OSbetween calls calls hardware and software Introduction System Interconnect (bus) I/O devices and Networking Memory Translation Main Memory 12 The “Machine” Different perspectives on what the Machine is: OS developer Application Programs Libraries Operating System Execution Hardware Instruction Set Architecture • • ISA Major division between hardware and software Introduction System Interconnect (bus) I/O devices and Networking Memory Translation Main Memory 13 The “Machine” Different perspectives on what the Machine is: Compiler developer Application Programs Libraries Operating System Execution Hardware Application Binary Interface • • ABI User ISA + OS calls System Interconnect (bus) I/O devices and Networking Introduction Memory Translation Main Memory 14 The “Machine” Different perspectives on what the Machine is: Application programmer Application Programs Libraries Operating System Execution Hardware Application Program Interface • • API User ISA + library calls Introduction System Interconnect (bus) I/O devices and Networking Memory Translation Main Memory 15 Virtual Machines add Virtualizing Software to a Host platform and support Guest process or system on a Virtual Machine (VM) Example: System Virtual Machine Applications Applications Guest OS VMM Virtualizing Software Host Hardware "Machine" Introduction OS Virtual Machine 16 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 Introduction 17 Taking a Unified View “The subjects of virtual machines and emulators have been treated as entirely separate. … they have much in common. Not only do the usual implementations have many shared characteristics, but this commonality extends to the theoretical concepts on which they are based” -- Efrem G. Wallach, 1973 Introduction 18 Major Program Interfaces ISA Interface -- supports all conventional software System Calls Application Software Operating System System ISA User ISA ISA Application Binary Interface (ABI) -- supports application software only Application Software System Calls Operating System System ISA Introduction User ISA ABI 19 System Virtual Machines Provide a system environment Constructed at ISA level Persistent Examples: IBM VM/360, VMware, Transmeta Crusoe guest guest process process guest process guest guest guest process process process Guest OS Guest OS2 VMM VMM HOST PLATFORM virtual network communication Introduction 20 System Virtual Machines Native VM System • • • Machine VMM VMM HostHost OS OS VMM User-mode Hosted VM • VMM privileged mode Guest OS user mode Example: classic IBM VMs Virtual Virtual Machine Machine Virtual VMM runs as user application Non-privileged modes Privileged Mode Hardware Hardware Hardware Dual-mode Hosted VM • • Parts of VMM privileged; parts non-privileged Example VMware Introduction 21 Process VMs Execute application binaries with an ISA different from hardware platform Couple at ABI level via Runtime System Examples: IA-32 EL, FX!32 Guest Application Process Virtualizing Software Runtime OS Host Application Process Virtual Machine Machine Hardware Introduction 22 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 Introduction guest process host process runtime guest process guest process runtime host process runtime create HOST OS file sharing Disk network communication 23 Same-ISA Dynamic Binary Optimizers Optimize Binary at Runtime An ABI level optimization A type of Process VM Example HP Dynamo • • Can optimize for dynamic properties of program Can optimize for a specific processor implementation Introduction HP Apps UNIX HP PA 24 HLL VMs Java and CLI are recent examples Binary class files are distributed “ISA” is part of binary class format OS interaction via APIs (part of VM platform) Java Binary Classes Java VM Architecture Introduction VM implementation VM implementation VM implementation Sparc Workstation x86 PC Apple Mac 25 High Level Language Virtual Machines Raise the level of abstraction • User higher level virtual ISA • OS abstracted as standard libraries Process VM (or API VM) HLL Program HLL Program Compiler front-end Intermediate Code Compiler Portable Code ( Virtual ISA ) Compiler back-end VM loader Object Code (ISA) Virt. Mem. Image VM Interpreter/Translator Loader Introduction Memory Image Host Instructions Traditional HLL VM 26 Co-Designed VMs Perform both translation and optimization VM provides interface between standard ISA software and implementation ISA Primary goal is performance or power efficiency Use proprietary implementation ISA Transmeta Crusoe and IBM Daisy best-known examples Introduction X86 Apps Windows VLIW 27 Composition apps 1 OS 1 apps 2 OS 1 ISA 2 Introduction 28 Composition: Example Java application JVM Linux x86 VMware Windows x86 Code Morphing Crusoe VLIW Introduction 29 Summary (Taxonomy) VM type (Process or System) Host/Guest ISA same or different Process VMs same ISA Multiprogrammed Systems HP Dynamo Introduction different ISA IA-32 EL FX!32 System VMs same ISA IBM VM/370 different ISA Virtual PC for Mac VMware Java VM MS CLI Transmeta Crusoe 30 Course Topics Introduction & VM Overview Emulation: Interpretation & Binary Translation Process VMs & Dynamic Translators Dynamic Binary Optimization Co-Designed VMs HLL VMs System VMs Emerging Applications Introduction 31 Case Studies Shade Sun WABI Compaq FX!32 HP Dynamo VMware Transmeta Crusoe IBM Daisy Intel VT-x …. and others Introduction 32