Virtual machines and operating systems



Similar documents
Virtual Machines. COMP 3361: Operating Systems I Winter

Virtualization Technology. Zhiming Shen

Full and Para Virtualization

Virtualization. Pradipta De

CS 695 Topics in Virtualization and Cloud Computing. More Introduction + Processor Virtualization

Virtualization. Jia Rao Assistant Professor in CS

COS 318: Operating Systems. Virtual Machine Monitors

Uses for Virtual Machines. Virtual Machines. There are several uses for virtual machines:

Virtualization. Jukka K. Nurminen

Hardware Based Virtualization Technologies. Elsie Wahlig Platform Software Architect

Virtualization. Types of Interfaces

Virtualization. Explain how today s virtualization movement is actually a reinvention

x86 Virtualization Hardware Support Pla$orm Virtualiza.on

CS5460: Operating Systems. Lecture: Virtualization 2. Anton Burtsev March, 2013

Intel s Virtualization Extensions (VT-x) So you want to build a hypervisor?

VMkit A lightweight hypervisor library for Barrelfish

kvm: Kernel-based Virtual Machine for Linux

Hypervisors. Introduction. Introduction. Introduction. Introduction. Introduction. Credits:

Basics in Energy Information (& Communication) Systems Virtualization / Virtual Machines

Virtualization. ! Physical Hardware. ! Software. ! Isolation. ! Software Abstraction. ! Encapsulation. ! Virtualization Layer. !

Microkernels, virtualization, exokernels. Tutorial 1 CSC469

x86 ISA Modifications to support Virtual Machines

Xen and the Art of. Virtualization. Ian Pratt

Chapter 5 Cloud Resource Virtualization

VMware and CPU Virtualization Technology. Jack Lo Sr. Director, R&D

Implementation of a Purely Hardware-assisted VMM for x86 Architecture

Virtualization Technologies

Distributed Systems. Virtualization. Paul Krzyzanowski

Basics of Virtualisation

Virtual Machine Monitors. Dr. Marc E. Fiuczynski Research Scholar Princeton University

Cloud Computing CS

Hybrid Virtualization The Next Generation of XenLinux

System Virtual Machines

Intel Virtualization Technology Overview Yu Ke

Knut Omang Ifi/Oracle 19 Oct, 2015

Hypervisors and Virtual Machines

OS Virtualization Frank Hofmann

Virtualization. Clothing the Wolf in Wool. Wednesday, April 17, 13

The Microsoft Windows Hypervisor High Level Architecture

matasano Hardware Virtualization Rootkits Dino A. Dai Zovi

Jukka Ylitalo Tik TKK, April 24, 2006

Chapter 16: Virtual Machines. Operating System Concepts 9 th Edition

Nested Virtualization

Virtualization in Linux KVM + QEMU

The Xen of Virtualization

COS 318: Operating Systems. Virtual Machine Monitors

Virtualization. Dr. Yingwu Zhu

Virtualization VMware Inc. All rights reserved

KVM: A Hypervisor for All Seasons. Avi Kivity avi@qumranet.com

AMD 64 Virtualization

How To Understand The Power Of A Virtual Machine Monitor (Vm) In A Linux Computer System (Or A Virtualized Computer)

Virtualization for Cloud Computing

Outline. Outline. Why virtualization? Why not virtualize? Today s data center. Cloud computing. Virtual resource pool

FRONT FLYLEAF PAGE. This page has been intentionally left blank

IOS110. Virtualization 5/27/2014 1

Understanding Full Virtualization, Paravirtualization, and Hardware Assist. Introduction...1 Overview of x86 Virtualization...2 CPU Virtualization...

Virtualization. P. A. Wilsey. The text highlighted in green in these slides contain external hyperlinks. 1 / 16

Virtual Machines. Virtualization

OS Virtualization. CSC 456 Final Presentation Brandon D. Shroyer

Virtualization. P. A. Wilsey. The text highlighted in green in these slides contain external hyperlinks. 1 / 16

Architecture of the Kernel-based Virtual Machine (KVM)

Performance tuning Xen

ARM Virtualization: CPU & MMU Issues

Brian Walters VMware Virtual Platform. Linux J. 1999, 63es, Article 6 (July 1999).

A Hypervisor IPS based on Hardware assisted Virtualization Technology

Cloud Computing #6 - Virtualization

VMware Server 2.0 Essentials. Virtualization Deployment and Management

Virtual Machine Security

KVM: Kernel-based Virtualization Driver

OSes. Arvind Seshadri Mark Luk Ning Qu Adrian Perrig SOSP2007. CyLab of CMU. SecVisor: A Tiny Hypervisor to Provide

Regional SEE-GRID-SCI Training for Site Administrators Institute of Physics Belgrade March 5-6, 2009

Windows Server Virtualization & The Windows Hypervisor

New Virtualization Techniques. Lic. Matías Zabaljáuregui

BHyVe. BSD Hypervisor. Neel Natu Peter Grehan

Securing Your Cloud with Xen Project s Advanced Security Features

Virtual Machines.

Security Challenges in Virtualized Environments

Enabling Technologies for Distributed Computing

Bluepilling the Xen Hypervisor

Introduction to Virtual Machines

Presentation of Diagnosing performance overheads in the Xen virtual machine environment

Survey On Hypervisors

Enabling Technologies for Distributed and Cloud Computing

Cloud^H^H^H^H^H Virtualization Technology. Andrew Jones May 2011

Using Linux as Hypervisor with KVM

Data Centers and Cloud Computing

Virtualization. Michael Tsai 2015/06/08

How do Users and Processes interact with the Operating System? Services for Processes. OS Structure with Services. Services for the OS Itself

Xen and the Art of Virtualization

Development of Type-2 Hypervisor for MIPS64 Based Systems

RPM Brotherhood: KVM VIRTUALIZATION TECHNOLOGY

How To Create A Cloud Based System For Aaas (Networking)

Nested Virtualization

Virtualization is set to become a key requirement

A hypervisor approach with real-time support to the MIPS M5150 processor

KVM Security Comparison

kvm: the Linux Virtual Machine Monitor

Anh Quach, Matthew Rajman, Bienvenido Rodriguez, Brian Rodriguez, Michael Roefs, Ahmed Shaikh

Compromise-as-a-Service

KVM KERNEL BASED VIRTUAL MACHINE

Transcription:

V i r t u a l m a c h i n e s a n d o p e r a t i n g s y s t e m s Virtual machines and operating systems Krzysztof Lichota lichota@mimuw.edu.pl

A g e n d a Virtual machines and operating systems interactions x86 processor architecture problems Pacifica/VT XEN Security Full virtualization based on VirtualBox code

V i r t u a l m a c h i n e s a n d o p e r a t i n g s y s t e m s Guest system thinks it is working on real machine and has all the resources for himself Host system has to provide simulated environment for guest Host systems has to isolate virtual machines and share the resources among them

V i r t u a l i z a t i o n b a s i c s Guest system is put in unprivileged (or less privileged) mode Privileged instructions cause exception and pass control to virtual machine manager (hypervisor) Hypervisor emulates proper behaviour by modifying machine state and passes control back to machine

V i r t u a l i z a t i o n o f h a r d w a r e d e v i c e s Harware device drivers work by programming device registers (using I/O ports and MMIO) and acting upon interrupts Virtual machine emulates real hardware device IN/OUT instructions are intercepted as they are privileged MMIO can be intercepted by protecting pages

V i r t u a l i z a t i o n o f h a r d w a r e d e v i c e s ( 2 ) Virtual machine simulated device driver performs operation as if device did it (reads some data from virtual disk, sends some data to virtual network, etc.) When operation is complete, virtual machine simulates interrupt on virtual machine Examples: simulating IRQ, attaching to VM simulated port, VM interface for virtual drivers

V i r t u a l i z a t i o n o f m e m o r y m a n a g e m e n t Hypervisor cannot allow guest direct access to physical memory All modifications of memory management structures must be intercepted and somehow simulated (or ignored) by modifying real page tables Writes to page table register (CR3 on x86 ) can be easily intercepted as it is privileged operation But guest OS can also modify page tables

P a g e t a b l e s m o d i f i c a t i o n Hypervisor creates shadow page tables Page tables modified by guest OS are dummy, writes to CR3 are intercepted Hypervisor intercepts modifications to guest OS page tables (by write-protecting them) and transforms them into proper operations on real page tables Note: if guest was granted direct access to hardware device this might cause problems, as it does not know physical location and it might not be contiguous

O t h e r O S a c t i o n s Interrupts - obviously guest cannot modify interrupt handling interrupt handler tables are shadowed, enabling/disabling interrupts is intercepted Writes to control registers (switching processor mode, etc.) are also intercepted TLB flushes,...

G u e s t t o h o s t s e r v i c e s Some services are useful and require cooperation between host and guest (clipboard sharing, drag-and-drop, etc.) Guest must somehow pass information to VMM and get results back Implemented by causing special exceptions which cause VMM to execute action and return result by modifying machine state Exception invoked using interrupt (Vmware) or illegal instruction (Virtual PC)

x86 processor architecture problems Dual-purpose instructions (example: POPF instruction can modify Interrupt Flag in kernel mode, but does not generate trap in user mode it is ignored) Store/load instruction pairs where load instruction is privileged, but store does not generate trap (e.g. SIDT/LIDT) Instructions which compare privilege level or allow storing it from segment registers (LAR, LSL, PUSH CS,...) Real mode (8086 mode) must emulate direct access to hardware and real mode

S o l v i n g x 8 6 a r c h i t e c t u r e p r o b l e m s Use Pacifica/VT-x extensions which address these problems Dynamically scan the code and replace bad instructions with call to emulator using INT3 (callout-and-emulate): read-protect pages and perform scanning upon execution write-protect pages after scanning to prevent modification of code use execute-only tricks to prevent selfexamining code

S o l v i n g x 8 6 a r c h i t e c t u r e p r o b l e m s ( 2 ) Perform binary translation of code by rewriting it to run emulation code 8086 mode dynamically recompile and emulate real-mode code

V T - x / P a c i f i c a Instruction set extensions which implement virtualization, designed separately by Intel and AMD, incompatible with each other but using similar techniques New privilege level is added for hypervisor, sometimes called ring (-1) Hypervisor works in ring -1 and can start virtual machines in ring 0 under supervision

V T - x / P a c i f i c a ( 2 ) Hypervisor can control which events in ring 0 cause exceptions Troublesome instructions in ring 0 (like POPF or POP CS) also cause exceptions, so inconsistencies can be avoided Exceptions can be turned off to boost performance, some exceptions are selective (e.g. change in PE bit in CR0) -> It is possible to intercept VMRUN instructions so nesting virtual machines is possible

V T - x / P a c i f i c a ( 3 ) Tagging of TLB (VMM and separately each VM address space) is added to avoid penalty when switching between hypervisor and guest It is possible to route IRQ to specific guest, intercept guest IRQs and invoke simulated interrupts in guests It is possible to intecept I/O ports in guests selectively (and allow some to be accesses directly)

V T - x / P a c i f i c a ( 4 ) Virtual machine state is kept in VMCB (Virtual Machine Control Block) which has 4 KB size and contains information which instructions and events to intercept, state of VM (registers, cause of exit to VMM, interrupt shadow after STI,...) At the moment of exit to VMM hypervisor can check in detail machine state based on VMCB

V T - x / P a c i f i c a ( 5 ) Paged real mode has been added to allow efficient simulation of real mode The possibility to limit hardware devices access to certain regions of physical memory has been added to provide isolation of virtual machines which have direct access to hardware devices (using IOMMU)

V T - x / P a c i f i c a ( 6 ) Nested paging has been added Addresses generated in VM are in guest linear space, which is further translated using paging into host linear space addresses This mechanism eliminates need for shadow page tables OS in virtual machine can maintain page tables on its own, no need of intercepting

P e r f o r m a n c e Usermode code (ring 3) runs with native speed Ring 0 code causes performance penalty as privileged instructions must be emulated Simplest emulation (trap-and-emulate) has poor performance, VT-x/Pacifica in most VMMs is used in limited way! Callout-and-emulate has better performance, but also has significant overhead (interrupt)

P e r f o r m a n c e ( 2 ) Binary translation performs best in most cases. Example: RDTSC trap-and-emulate: 2030 cycles callout-and-emulate: 1254 cycles binary translation: 216 cycles

P e r f o r m a n c e ( 3 ) In standard x86 virtualization exception handling has big overhead: context switch from guest ring 3 to VMM detecting that trap should be passed to VM context switch to VM guest kernel VT-x/Pacifica provide better performance for traps no need to route traps through VMM, they go directly to guest kernel

X e n Everything is easier and faster if we modify guest and it is aware it is running as guest (so called paravirtualization) Guest calls hypervisor (using hypercall) to perform some privileged action (modifying page tables, routing IRQs, modifying registers) Hypervisor checks if requested operation is OK and performs action instead of guest

X e n ( 2 ) Guests implemented as another architecture for Linux (also other OSs) Example: sti() Original Linux implementation (link) Xen architecture implementation (link) Host kernel also modified to work as domain 0 (hypervisor)

S e c u r i t y Virtual machines interact in complicated way with hypervisor Hypervisor is very complicated code and there are always bugs in complicated code Result: it is possible to force bugs in VMM and thus break out of VM or cause some nasty behavior Ring -1 can be used to create superrootkit (BluePill)

B i b l i o g r a p h y http://www.virtualbox.org/browser/trunk/src/v http://www.virtualbox.org/wiki/virtualbox_arc http://www.cs.wisc.edu/areas/os/seminar/sch http://www.cs.nps.navy.mil/people/faculty/irv http://www.cs.utexas.edu/users/hunt/class/20 http://softwarecommunity.intel.com/wiki/vt-v http://www.intel.com/technology/itj/2006/v10 http://www.blackhat.com/presentations/bh-eu

http://www.symantec.com/avcenter/reference http://www.dell.com/downloads/global/power