november 2004 j. e. smith

Download November 2004 J. E. Smith

If you can't read please download the document

Post on 24-Feb-2016

22 views

Category:

Documents

0 download

Embed Size (px)

DESCRIPTION

Virtual Machines: An Architecture Perspective. November 2004 J. E. Smith. Introduction. Why are virtual machines interesting? They involve computer architecture in a pure sense They allow transcending of interfaces (which often seem to be an obstacle to innovation) - PowerPoint PPT Presentation

TRANSCRIPT

  • November 2004J. E. Smith Virtual Machines: An Architecture Perspective

    VMs (c) 2004, J. E. Smith

  • IntroductionWhy are virtual machines interesting?

    They involve computer architecture in a pure sense

    They allow transcending of interfaces (which often seem to be an obstacle to innovation)

    They enable innovation in flexible, adaptive hardware, security, fault-tolerance, support for network computing (and others)

    VMs (c) 2004, J. E. Smith

  • Performance Isnt EverythingThe BIG ideas are all at least 20 years old and they have been very thoroughly exploredFocus research on other important areasPower efficiencyPerformance efficiencySecurityEase of designSoftware compatibility / interoperabilityVirtual Machines can be important enablers for all the above

    VMs (c) 2004, J. E. Smith

  • OutlineVirtualizationThe Family of Virtual MachinesProcess VMs and Code CachingHigh Level Language VMsCo-Designed VMsResearch in Co-Designed VMs

    VMs (c) 2004, J. E. Smith

  • AbstractionComputer systems are built on levels of abstractionInstruction Set Architecture Major division between hardware and software

    I/O devicesandNetworkingControllersSystem Interconnect(bus)ControllersMemoryTranslationExecution HardwareDriversMemoryManagerSchedulerOperating SystemLibrariesApplicationProgramsMainMemory1233456778888910101111121314SoftwareHardwareApplication Binary InterfaceObserved by user processesUser ISA + OS callsHigher level of abstraction hide details at lower levelsExample: files are an abstraction of a disk

    VMs (c) 2004, J. E. Smith

  • VirtualizationAn isomorphism from guest to host Map guest state to host state Implement equivalent functionsSiSSi'Sj'GuestHostV(Si)V( S j )e(Si)e'(Si')j

    VMs (c) 2004, J. E. Smith

  • VirtualizationSimilar to abstractionExceptDetails not necessarily hiddenConstruct Virtual DisksAs files on a larger diskMap stateImplement functionsNow do the same thing with the whole machine

    VMs (c) 2004, J. E. Smith

  • The Family of Virtual MachinesLots of things are called virtual machines IBM VM/370JavaVMware

    Some things not called virtual machines, are virtual machines IA-32 EL Dynamo Transmeta Crusoe

    VMs (c) 2004, J. E. Smith

  • System Virtual MachinesProvide a system environmentConstructed at ISA levelPersistentExamples: IBM VM/360, VMware, Transmeta CrusoeguestprocessHOST PLATFORMvirtualnetwork communicationGuest OSVMMguestprocessguestprocessguestprocessGuest OS2VMMguestprocessguestprocess

    VMs (c) 2004, J. E. Smith

  • System Virtual MachinesNative VM SystemVMM privileged modeGuest OS user modeExample: classic IBM VMsUser-mode Hosted VMVMM runs as user applicationDual-mode Hosted VMParts of VMM privileged, parts non-privilegedExample VMwareNon-privilegedmodesPrivilegedMode

    VMs (c) 2004, J. E. Smith

  • Process Virtual MachinesConstructed at ABI levelRuntime manages guest processGuest processes may intermingle with host processesNot persistentAs a practical matter, guest and host OSes are often the sameDynamic optimizers are a special caseExamples: IA-32 EL, FX!32, Dynamo HOST OSDiskfile sharingnetwork communicationguestprocesscreatehostprocessguestprocessruntimeruntimeguestprocessruntimehostprocess

    VMs (c) 2004, J. E. Smith

  • The Virtual Machine SpaceMultiprogrammedSystemsHLL VMsCo-DesignedVMssame ISAdifferentISAProcess VMsSystem VMsWholeSystem VMsdifferentISAsame ISAClassicOS VMsDynamicBinaryOptimizersDynamicTranslatorsHostedVMs

    VMs (c) 2004, J. E. Smith

  • Architecture Issues: System VMsWhy System VMs are of interest todaySecurity & Fault Tolerance (isolation)Platform ConsolidationApplication/Environment portabilityEfficiently Virtualizable Instruction SetsGoldberg and Popek (1974) should still be required reading(An architecture paper with theorems and proofs!)Virtual Machine AssistsCompensate for inefficiencies due to privilege level compressionFast emulation of system functionsMany developed for IBM mainframe VMs

    VMs (c) 2004, J. E. Smith

  • System VirtualizationTraps and interrupts (& sys calls)Transfer to VMMVMM determines appropriate Guest OSVMM transfers to Guest OSGuest performs privileged operationTrap to VMMVMM reads/modifies guest stateMay modify shadow stateReturns to GuestGuest OS return to user app.Transfer to VMMVMM bounces return back to Guest app.privileged operationnext instructioncheck privilegesperform operationreturnsystem call/trapvector location:virtual vector location:ApplicationGuest OSVMM

    VMs (c) 2004, J. E. Smith

  • Popek and Goldberg (in brief)Control Sensitive instructionsAll instructions that change hardware resource allocation (or mapping)Example: write TLBBehavior Sensitive instructionsAll instructions whose outcome depends on hardware resource allocationExample: read processor modeTheorem (paraphrase)Efficiently virtualizable if all sensitive instructions trap in user mode

    VMs (c) 2004, J. E. Smith

  • System VM ResearchArchitecture Challenge: Make IA-32 efficiently virtualizableVirtual Machine AssistsCompensate for inefficiencies due to privilege level compressionFast emulation of system functionsMany developed for IBM mainframe VMsApplications to Chip MultiprocessorsTechnology changes often require innovation and re-invention

    VMs (c) 2004, J. E. Smith

  • The Virtual Machine SpaceMultiprogrammedSystemsHLL VMsCo-DesignedVMssame ISAdifferentISAProcess VMsSystem VMsWholeSystem VMsdifferentISAsame ISAClassicOS VMsDynamicBinaryOptimizersDynamicTranslatorsHostedVMs

    VMs (c) 2004, J. E. Smith

  • Architecture Issues: Process VMsGenerally to allow application migrationOr to run popular software on a less popular platformGoal is generally to minimize performance lossSame-ISA dynamic optimizers are special caseHP DynamoArchitecture problemsEfficient code-cachingIndirect jump problemProtecting runtime from guest process

    VMs (c) 2004, J. E. Smith

  • Staged Emulation with Code CachingAn important part of many VM implementationsTranslate, optimize & cache frequent code sequencesBinary MemoryImageCode CacheProfile DataInterpreterTranslator/Optimizer runtimeStart interpretingProfile to find hot code regions

    VMs (c) 2004, J. E. Smith

  • SuperblocksBased on hot pathsOne entry multiple exitsMay contain redundant blocks (tail duplication)15BDCGAEF15BDCGAEFGG

    VMs (c) 2004, J. E. Smith

  • Binary Translation Example

    VMs (c) 2004, J. E. Smith

  • Code CachesContainBasic blocksSuperblocks (one entrance, multiple exits)Optimized SuperblocksA base technology for many VMsDynamic binary translators: Intel IA-32 EL, Compaq FX!32Dynamic binary optimizers: Dynamo familyCo-designed virtual machines: Transmeta, IBM DAISYHigh performance Java virtual machinesSystem VMs with inefficiently virtualizable ISAsSandboxing secure VMs (x86 DynamoRIO)

    VMs (c) 2004, J. E. Smith

  • Indirect JumpsTranslated code cache PC (TPC) differs from Source binary PC (SPC)Need branch/jump target address translation(Direct) branches are easier; target address is fixed Chaining can be usedSuperblockDispatch table lookup codeSuperblockSuperblockWithout chaining

    VMs (c) 2004, J. E. Smith

  • The Indirect Jump ProblemTarget addresses (SPCs) can changeSPC needs to be translated at run-time, not translation timeConventional solution: superblock construction-time software prediction (aka inline caching)If Rx == #addr_1 goto #target_1Else if Rx == #addr_2 goto #target_2Else dispatch_table_lookup(Rx); do it the slow way

    The biggest overhead in code cachesCompare-and-branch: 6 instructionsHash table lookup: 15 instructions in Dynamo x86

    VMs (c) 2004, J. E. Smith

  • Protecting the RuntimeThe runtime shares process memory space with applicationMust protect runtime from applicationExpensive memory protection changes on switches between runtime and code cacheIf guest registers are mapped to host memoryHow are memory mapped registers protected?Guest CodeGuest DataRuntimeDataRuntimeCodeNR/WCode CacheExR/WNR/WR/WGuest CodeGuest DataRuntimeDataRuntimeCodeNNCode CacheNExNR/WRRuntime modeEmulation mode

    VMs (c) 2004, J. E. Smith

  • Process VM ResearchSame-ISA dynamic binary optimizers are probably not a winning propositionIndirect jumps lead to performance losses on modern processors (optimizers with patching are better)Complete (intrinsic) compatibility is extremely difficultMay have to rely on extrinsic assurancesTopic of architecture research similar to Goldberg and PopekFor general process VMs some primitive support in ISA will be useful / necessaryIndirect jumps (more later)Code cachingProtection

    VMs (c) 2004, J. E. Smith

  • Computer Architecture InnovationHLL VMs software people invent ISA to solve SW problems

    Co-Designed VMs hardware people invent ISA to solve HW problems

    These two are the most interesting VMs from an architecture perspective and provide the biggest opportunities.

    VMs (c) 2004, J. E. Smith

  • The Virtual Machine SpaceMultiprogrammedSystemsHLL VMsCo-DesignedVMssame ISAdifferentISAProcess VMsSystem VMsWholeSystem VMsdifferentISAsame ISAClassicOS VMsDynamicBinaryOptimizersDynamicTranslatorsHostedVMs

    VMs (c) 2004, J. E. Smith

  • High Level Language Virtual MachinesRaise the ABI level of abstractionUser higher level virtual ISAOS abstracted as standard librariesA form of process VM

    VMs (c) 2004, J. E. Smith

  • Architecture Issues: High Level VMsExamples:Sun JavaMicrosoft .NET Framework and MSILWhy are HLL VMs important?Microsoft says so.Its a good idea.Combines object oriented programming and network computing