Introduction Hypervisors Credits: P. Chaganti – Xen Virtualization – A practical handbook D. Chisnall – The definitive guide to Xen Hypervisor G. Kesden – Lect. 25 CS 15-440 G. Heiser – UNSW/NICTA/OKL Agenda Introduction Introduction to virtualization Virtualization is a technique of partitioning the resources of a single computing platform into Techniques to implement virtualization multiple segregated, virtualized, execution environments. The role of virtualization in embedded systems Each environment runs independently of the A (quick) overview on the Xen Hypervisor other, thus allowing multiple operating systems to run on the same hardware. Introduction Introduction The concept of virtualization already present in Virtualization of the CPU: If a process tries to every-day computing… consume all of the CPU, the operating system will preempt it and allow other processes to execute; Most modern operating systems contain a Virtualization of the memory: a running process simplified system of virtualization; has its own virtual address space that the Each running process is able to act as if it is the operating system maps to physical memory to only thing running. The CPUs and memory are give the process the illusion that it is the only user virtualized. of RAM. 1
Introduction Introduction Virtualization of the CPU: If an OS tries to Each execution environment is called a guest and consume all of the CPU, the hypervisor will the computing platform on which they execute is preempt it and allow other processes to execute; called the host . Virtualization of the memory: a running OS has its The software enabling these multiple execution own virtual address space that the hypervisor environments is commonly referred to as maps to physical memory to give the process the Hypervisor or Virtual Machine Monitor (VMM). illusion that it is the only user of RAM. The Hypervisor runs on the host and acts as a bridge between the host and the guests; Mixed OS Environment Mixed OS Environment Multiple VMs can be implemented on a single Virtualization implies a two-level hierarchical hardware platform to provide individuals or user scheduling framework groups with their own OS environments VM1 VM2 VM3 VM4 VM5 VM1 VM2 VM3 VM4 VM5 Local Local Local Local Local Scheduler Scheduler Scheduler Scheduler Scheduler Linux Red Hat Solaris 10 XP Vista Mac OS Linux Red Hat Solaris 10 XP Vista Mac OS Hypervisor Hypervisor Global Scheduler Hardware Hardware Figure: G. Kesden Figure: G. Kesden Benefits of Virtualization Virtualization Properties • A system VM provides • Virtualization helps a sandbox that isolate the effects of a isolates one system failure to the VM •Fault Isolation •All VM state can be captured •All guest actions go through environment from where the failure into a file (i.e., you can the virtualizing software other environments occurred operate on VM by operating which can inspect, modify, Multiple Failure •Software Isolation on file– cp, rm) and deny operations Secure Isolation Environment •Performance Isolation •Complexity is proportional to •Security (accomplished through virtual HW model and scheduling and resource independent of guest allocation) software configuration Better Mixed ‐ OS System Environment Utilization • A single hardware • A virtualized system Isolation Encapsulation Interposition 2 platform can support can be (dynamically 1 3 multiple operating or statically) re- systems concurrently configured for changing needs Figure: G. Kesden Figure: G. Kesden 2
Methodologies Methodologies Three main methodologies used for providing System Emulation – All the hardware resources are virtualization: emulated. The guest operating system can be run without any modification; System Emulation It can use the hardware resources through the hardware emulation layer; Paravirtualization The VMM executes the CPU instructions that need more privileges than are available in the user space. Binary Translation OS Level Virtualization Methodologies Methodologies System Emulation – All the hardware resources are Paravirtualization – No hardware emulation. emulated. The operating system that runs on a guest needs to be a modified version that is aware of the fact that it PRO is running inside a hypervisor; Complete isolation Lower number of privileged CPU instructions that need to be executed; Total portability (VMs are not related to any specific Typically paravirtualization of device drivers is also HW platform) needed No modifications to the OS are needed CONS Slow! (Since everything is emulated) Methodologies Methodologies Paravirtualization – No hardware emulation. Hardware-assited Paravirtualization – higher efficiency thanks to special CPU instructions PRO CPUs are fully aware of the presence of a virtualization stack More efficient than System Emulation CPUs provide an Instruction Set Architecture that Virtualized OSes can directly communicate with simplifies the development of a VMM hardware resources Automatic trap of sensitive instructions Automatic space isolation (i.e., memory areas) to CONS improve efficiency Need to modify the OS! Isolation is more challenging 3
Methodologies Methodologies Binary Translation – intercept OS code OS Level Virtualization – Each guest is isolated and runs in a secure environment. Run-time translation of some OS instructions Only multiple instances of guests that run the same User-level code is directly executed on the real operating systems as the host; hardware Close to sandboxes; No modifications to the OS are needed: the guest OS is not aware of virtualization Low run-time overhead. Specific device drivers are required E.g., FreeBSD Jails, Solaris Zones Types of Hypervisor Types of Hypervisor Gerald J. Popek and Robert P. Goldberg – “Formal Requirements for Virtualizable Third OS OS OS OS OS OS Generation Architectures”, 1974 Type 1: native (bare-metal) hypervisors Hypervisor Hypervisor The Hypervisor runs directly on the host's hardware to control the hardware and to manage guest operating systems. OS E.g., Xen, VMWare ESXi, Microsoft Hyper-V Hardware Type 2: hosted hypervisors Hardware These hypervisors run on a conventional operating system just as other computer programs do. Type-1 Type-2 ( bare-metal ) ( hosted ) E.g., VMWare Workstation, VirtualBox Implementation Implementation Preliminaries Preliminaries Sensitive instructions = those that attempt to Example: Privileged rings in x86 change the configuration of resources in the system Examples: update virtual to physical memory mappings, communication with devices, manipulation of global configuration registers, etc. Privileged instructions = those that are executed in privileged mode (protected, ring 0,…) and trap if executed in user mode 4
Implementation Implementation “Trap and Emulate” “Trap and Emulate” Raise of an exception (trap) when the guest Popek and Goldberg, 1974 executes a privileged instruction (e.g., accessing “For any conventional third-generation computer, an a physical resources); effective VMM may be constructed if the set of The exception handler is used to invoke the sensitive instructions for that computer is a subset of hypervisor code. the set of privileged instructions.” Figure: G. Heiser Figure: G. Heiser Implementation Implementation “Trap and Emulate” “Trap and Emulate” Popek and Goldberg, 1974 – In other words… Most common architectures are not virtualizable according to definition of Popek and Goldberg It is sufficient that all the instructions that could affect x86 – lots of unvirtualizable features the correct functioning of the VMM (sensitive instructions) always trap and pass control to the E.g., PUSH of PSW (Processor State Word) is not privileged VMM. MIPS – mostly virtualizable, but… Kernel registers k0,k1 (needed to save/restore state) are user- accessible ARM – mostly virtualizable but… Some instructions are undefined in user-mode Figure: G. Heiser Implementation Embedded Systems Virtualization historically used for easier sharing Impure Virtualization of expensive mainframes. Change the Guest OS code replacing sensitive Gone out of fashion in 80’s and resurrected in instructions recent years for improved isolation in modern Paravirtualization – by trapping code (hypercalls) computing systems. Binary translation - In-line code emulation (run-time) Why virtualization for Embedded Systems? Hypercall 5
Recommend
More recommend