CSE 120 Principles of Operating Systems Spring 2009 Lecture 16 Virtual Machine Monitors Geoffrey M Voelker Virtual Machine Monitors Virtual Machine Monitors VMMs are a hot topic in industry and academia Industry commitment Software VMware Xen Microsoft Virtual PC Hardware Intel VT AMD V If Intel and AMD add it to their chips you know it s serious Academia lots of VMM based projects and papers An old idea actually developed by IBM in 60s and 70s Today June 1 2009 What is it what problems have to be solved how to solve them Survey some virtualization systems Briefly outline cool things you can do with virtualization CSE 120 Lecture 16 Virtual Machine Monitors 2 What is a VMM We have seen that an OS already virtualizes Syscalls processes virtual memory file system sockets etc Applications program to this interface A VMM virtualizes an entire physical machine Interface supported is the hardware OS defines a higher level interface VMM provides the illusion that software has full control over the hardware of course VMM is in control VMM applications run in virtual machines c f OS processes Implications You can boot an operating system in a virtual machine Run multiple instances of an OS on same physical machine Run different OSes simultaneously on the same machine Linux on Windows Windows on Mac etc June 1 2009 CSE 120 Lecture 16 Virtual Machine Monitors 3 Why in tarnation would you do such a crazy thing Resource utilization Machines today are powerful want to multiplex their hardware e g ISP hosting can divvy up a physical machine to customers Can migrate VMs from one machine to another without shutdown Software use and development Can run multiple OSes simultaneously No need to dual boot Many other cool applications Can do system e g OS development at user level Debugging emulation security speculation fault tolerance Common theme is manipulating applications services at the granularity of a machine Specific version of OS libraries applications etc as package June 1 2009 CSE 120 Lecture 16 Virtual Machine Monitors 4 VMM Requirements Fidelity OSes and applications work the same without modification although we may modify the OS a bit Isolation VMM protects resources and VMs from each other Performance VMM is another layer of software and therefore overhead As with OS want to minimize this overhead VMware CPU intensive apps 2 10 overhead I O intensive apps 25 60 overhead June 1 2009 CSE 120 Lecture 16 Virtual Machine Monitors 5 Rough VMM Model VMM runs with privilege Want to run OS code in a VM directly on CPU Think in terms of making the OS a user level process What OS code can run directly what will cause problems Ideally want privileged instructions to trap OS in VM runs at lesser privilege think user level VMM multiplexes resources among VMs Exception vectors to VMM it emulates operation returns Nothing modified running unprivileged is transparant Known as trap and emulate Unfortunately on architectures like x86 not so easy June 1 2009 CSE 120 Lecture 16 Virtual Machine Monitors 6 Virtualizing the x86 Ease of virtualization influenced by the architecture x86 is perhaps the last architecture you would choose But it s what everyone uses so that s what we deal with Issues Unvirtualizable events popf does not trap when it cannot modify system flags Hardware managed TLB VMM cannot easily interpose on a TLB miss more in a bit Untagged TLB Have to flush on context switches just a performance issue Why Intel and AMD have added virtualization support June 1 2009 CSE 120 Lecture 16 Virtual Machine Monitors 7 Xen Early versions use paravirtualization Fancy word for we have to modify recompile the OS Since you re modifying the OS make life easy for yourself Create a VMM interface to minimize porting and overhead Xen hypervisor VMM implements interface VMM runs at privilege VMs domains run unprivileged Trusted OS Linux runs in own domain Domain0 Use Domain0 to manage system operate devices etc Most recent version of Xen does not require OS mods Because of Intel AMD hardware support Commercialized via XenSource but also open source June 1 2009 CSE 120 Lecture 16 Virtual Machine Monitors 8 Xen Architecture June 1 2009 CSE 120 Lecture 16 Virtual Machine Monitors 9 VMware VMware workstation uses hosted model VMware ESX server uses hypervisor model VMM runs unprivileged installed on base OS Relies upon base OS for device functionality Similar to Xen but no guest domain OS VMware uses software virtualization Dynamic binary rewriting translates code executed in VM Rewrite privileged instructions with emulation code may trap CPU only executes translated code Think JIT compilation for JVM but full binary x86 IR code safe subset of x86 June 1 2009 Incurs overhead but can be well tuned small hit CSE 120 Lecture 16 Virtual Machine Monitors 10 VMware Hosted Architecture June 1 2009 CSE 120 Lecture 16 Virtual Machine Monitors 11 What needs to be virtualized Exactly what you would expect CPU Events exceptions and interrupts Memory I O devices Isn t this just duplicating OS functionality in a VMM Yes and no Approaches will be similar to what we do with OSes Simpler in functionality though VMM much smaller than OS But implements a different abstraction Hardware interface vs OS interface June 1 2009 CSE 120 Lecture 16 Virtual Machine Monitors 12 Virtualizing Privileged Insts OSes can no longer successfully execute privileged instructions For those instructions that cause an exception Virtual memory registers interrupts I O halt etc Trap to VMM take care of business return to OS in VM For those that do not June 1 2009 Xen modify OS to hypervisor call into VMM VMware rewrite OS instructions to emulate or call into VMM CSE 120 Lecture 16 Virtual Machine Monitors 13 Virtualizing the CPU VMM needs to multiplex VMs on CPU How Just as you would expect Timeslice the VMs Each VM will timeslice its OS applications during its quantum Typically relatively simple scheduler June 1 2009 Round robin work conserving give unused quantum to other VMs CSE 120 Lecture 16 Virtual Machine Monitors 14 Virtualizing Events VMM receives interrupts exceptions Needs to vector to appropriate VM June 1 2009 Xen modify OS to use virtual interrupt register event queue VMware craft appropriate handler invocation emulate event registers CSE 120 Lecture 16 Virtual Machine Monitors 15 Virtualizing I O OSes can no longer interact directly with I O devices Xen modify OS to use low level I O interface hybrid Define generic devices with simple
View Full Document
Unlocking...