Lecture 5. User-Mode Linux. Jeff Dike. November 7, 2012. Operating Systems Practical. OSP Lecture 5, UML 1/33

Similar documents
User-Mode Linux. Jeff Dike. Abstract. 2 Devices. 1 Introduction

Process Description and Control william stallings, maurizio pizzonia - sistemi operativi

Running virtualized native drivers in User Mode Linux p.1/30

Red Hat Linux Internals

Virtual machines and operating systems

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

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

Operating Systems. Lecture 03. February 11, 2013

KVM: Kernel-based Virtualization Driver

Virtual Private Systems for FreeBSD

Architecture of the Kernel-based Virtual Machine (KVM)

x86 ISA Modifications to support Virtual Machines

Making Linux Safe for Virtual Machines

Security Overview of the Integrity Virtual Machines Architecture

kvm: Kernel-based Virtual Machine for Linux

An Implementation Of Multiprocessor Linux

Nested Virtualization

The Microsoft Windows Hypervisor High Level Architecture

evm Virtualization Platform for Windows

CSC 2405: Computer Systems II

Page 1 of 5. IS 335: Information Technology in Business Lecture Outline Operating Systems

Virtualization Technology. Zhiming Shen

KVM Architecture Overview

COS 318: Operating Systems

Chapter 5 Cloud Resource Virtualization

6.828 Operating System Engineering: Fall Quiz II Solutions THIS IS AN OPEN BOOK, OPEN NOTES QUIZ.

A Look through the Android Stack

BHyVe. BSD Hypervisor. Neel Natu Peter Grehan

Xen and the Art of. Virtualization. Ian Pratt

POSIX. RTOSes Part I. POSIX Versions. POSIX Versions (2)

Kernel comparison of OpenSolaris, Windows Vista and. Linux 2.6

Thomas Fahrig Senior Developer Hypervisor Team. Hypervisor Architecture Terminology Goals Basics Details

Review from last time. CS 537 Lecture 3 OS Structure. OS structure. What you should learn from this lecture

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

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

Software Tracing of Embedded Linux Systems using LTTng and Tracealyzer. Dr. Johan Kraft, Percepio AB

CPS221 Lecture: Operating System Structure; Virtual Machines

Operating Systems. Design and Implementation. Andrew S. Tanenbaum Melanie Rieback Arno Bakker. Vrije Universiteit Amsterdam

Outline. Operating Systems Design and Implementation. Chap 1 - Overview. What is an OS? 28/10/2014. Introduction

How To Write A Windows Operating System (Windows) (For Linux) (Windows 2) (Programming) (Operating System) (Permanent) (Powerbook) (Unix) (Amd64) (Win2) (X

Windows8 Internals, Sixth Edition, Part 1

Virtual vs Physical Addresses

White Paper. Real-time Capabilities for Linux SGI REACT Real-Time for Linux

Hardware Assisted Virtualization

Overview of Operating Systems Instructor: Dr. Tongping Liu

Application of RT-Preempt Linux and Sercos III for Real-time Simulation

1. Computer System Structure and Components

Microkernels, virtualization, exokernels. Tutorial 1 CSC469

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

Virtual Machines. COMP 3361: Operating Systems I Winter

Porting Plan 9 to the PowerPC Architecture. Ian Friedman Ajay Surie Adam Wolbach

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Real-time KVM from the ground up

SunOS Minix: a tool for use in. Paul Ashton. Daniel Ayers. Peter Smith. Department of Computer Science. University of Canterbury, Private Bag 4800

ELEC 377. Operating Systems. Week 1 Class 3

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Operating Systems 4 th Class

COS 318: Operating Systems. Virtual Machine Monitors

Hardware Based Virtualization Technologies. Elsie Wahlig Platform Software Architect

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

W4118 Operating Systems. Junfeng Yang

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

Virtual Machines.

Intel DPDK Boosts Server Appliance Performance White Paper

Binary Device Driver Reuse. Bernhard Poess. Diplomarbeit

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

Chapter 2: OS Overview

Libmonitor: A Tool for First-Party Monitoring

Practical Experiences With Software Crash Analysis in TV. Wim Decroix/Yves Martens, TPVision

CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study

Process definition Concurrency Process status Process attributes PROCESES 1.3

L 4 Linux Porting Optimizations

Virtualization for Cloud Computing

Minix Mini Unix (Minix) basically, a UNIX - compatible operating system. Minix is small in size, with microkernel-based design. Minix has been kept

FRONT FLYLEAF PAGE. This page has been intentionally left blank

Virtualization. Jia Rao Assistant Professor in CS

Operating System Structures

The Xen of Virtualization

These sub-systems are all highly dependent on each other. Any one of them with high utilization can easily cause problems in the other.

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

Virtual Machine Security

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

Introduction to Operating Systems. Perspective of the Computer. System Software. Indiana University Chen Yu

A Survey on Virtualization Technologies

Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

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

Operating System Impact on SMT Architecture

REAL TIME OPERATING SYSTEM PROGRAMMING-II: II: Windows CE, OSEK and Real time Linux. Lesson-12: Real Time Linux

Processes, Protection and the Kernel: Mode, Space, and Context

Operating System Tutorial

Development of Type-2 Hypervisor for MIPS64 Based Systems

Automatic Logging of Operating System Effects to Guide Application-Level Architecture Simulation

LSN 10 Linux Overview

CSE 120 Principles of Operating Systems. Modules, Interfaces, Structure

COS 318: Operating Systems. Virtual Machine Monitors

Transcription:

Lecture 5 User-Mode Linux Jeff Dike Operating Systems Practical November 7, 2012 OSP Lecture 5, UML 1/33

Contents User-Mode Linux Keywords Resources Questions OSP Lecture 5, UML 2/33

Outline User-Mode Linux Keywords Resources Questions OSP Lecture 5, UML 3/33

UML A linux kernel port on Linux A virtual machine in user-space The simulated hardware is built on top of the native kernel services The UML kernel is ported on top of the native s kernel system calls The associated code is in the arch interface (arch/um/) There are no drivers Processes run in a closed environment OSP Lecture 5, UML 4/33

UML (2) OSP Lecture 5, UML 5/33

Devices console the main console is the one in which the UML kernel was started subsequent consoles run inside an xterm block devices emulated through files serial links emulated through pseudo-terminals (/dev/pts/0) networking daemon used to send Ethernet frames between virtual machines can link the virtual device to the real one OSP Lecture 5, UML 6/33

Processor implemented using the arch interface the entire code is a separate architecture named um : # l s / u s r / s r c / l i n u x / a r c h /um/ K c o n f i g K c o n f i g. x86 64 M a k e f i l e s k a s [... ] K c o n f i g. c h a r M a k e f i l e M a k e f i l e t t [... ] K c o n f i g. debug M a k e f i l e i 3 8 6 M a k e f i l e x86 64 os L i n u x K c o n f i g. i 3 8 6 M a k e f i l e i a 6 4 c o n f i g. r e l e a s e s c r i p t s K c o n f i g. n e t M a k e f i l e os L i n u x d e f c o n f i g sys i 3 8 6 K c o n f i g. s c s i M a k e f i l e ppc d r i v e r s sys i a 6 4 user space code need to be able to run unmodified in the virtual machine system calls are interpreted and run on the virtual machine UML runs in user space as a process OSP Lecture 5, UML 7/33

Intercepting system calls uses ptrace - controlled execution (gdp uses ptrace) one thread uses ptrace to control the other threads and processes the thread is notified by a system call from another thread the arguments are gathered redirects to kernel code running in user space for execution OSP Lecture 5, UML 8/33

Trap traps are used to switch from user mode to kernel mode on physical systems are generated by hardware components the result is forcing the processor to jump to a certain address in kernel space traps are implemented using Linux signals SIGALRM/SIGVTALRM - clock SIGIO - hardware interrupts SIGSEGV - memory faults the user-space kernel declares handlers for these signals OSP Lecture 5, UML 9/33

Trap (2) signal handlers need to run in kernel-mode (in the UML process) 1. need to use a kernel stack 2. need to deactivate the interception of system calls OSP Lecture 5, UML 10/33

Trap (3) OSP Lecture 5, UML 11/33

Kernel address space when a process enters kernel mode, it automatically changes the address space the UML problem? the kernel and the process co-exist in the same address space - the UML process address space solution: placing the UML kernel in a memory area that is not likely to be accessed (0xa0000000 0xbfffffff) mmaps a file in each process space OSP Lecture 5, UML 12/33

Process address space Each process on the virtual machine has a real process on the physical machine associated with it All processes share kernel data mmap a file with kernel data in the address space of each andevery process (shared segment) context changes are implemented using real (native) context changes what preempts a process? clock interrupt on the native kernel SIGVTALRM on the UML kernel OSP Lecture 5, UML 13/33

Address space OSP Lecture 5, UML 14/33

Initialization and shutdown example:./linux-2.6.19-rc5 ubda=fedoracore5-x86-root fs mem=128m arguments are sent through a buffer init memory, start idle thread the monitoring thread starts intercepting start kernel, mem init, paging init register and init drivers on shutdown, all processes and threads are killed OSP Lecture 5, UML 15/33

Processes for creating a new process, the generic code in the kernle calls the specific architecture code from /arch/ in the UML case, a new process is created on the host system the monitoring thread is used (MT) new process/thread executes init operation (handlers for SIGVTALRM, SIGIO, SIGSEGV, etc.) after init it sends itself a SIGSTOP the MT detects the stopping of the process and ends the system call and returns a return value specific to fork the process is killed on the host system and the memory is freed OSP Lecture 5, UML 16/33

System calls The virtualization of the system calls is done through MT system calls are redirected to the virtual kernel the system call is mapped to a getpid on the host system OSP Lecture 5, UML 17/33

System calls (2) how to call the system call switch on the kernel stack? 1. creating an execution context that positions the process at the beginning of the switch statement 2. use a signal at the return from the kernel; the handler for this signal is the execution of the system call switch statement the MT is notified at the end of the system call in the MT the MT stores the return value in the specialized register the process continues to execute user level code OSP Lecture 5, UML 18/33

System calls (3) OSP Lecture 5, UML 19/33

System calls (4) OSP Lecture 5, UML 20/33

Context switch in the case of a process switch - a process calls schedule a new process is chosen and the architecture dependent code is called the MT is notified from the arch/um/ code the MT stops the process and starts the new one OSP Lecture 5, UML 21/33

Context switch (2) after re-planning, some pages can be swapped - but the mapping exists the pages are stored in a circular buffer after re-planning this buffer is checked and the address space is updated OSP Lecture 5, UML 22/33

Delivering signals delivered signals are stored in a queue in the process task struct the queue is inspected upon every exit from kernel mode the signal is delivered to the process running on the host kernel through SIGUSR2 the SIGUSR2 handler executes the actual signal handler OSP Lecture 5, UML 23/33

Memory faults what is demand paging? a memory fault causes the delivery of SIGSEGV to the UML process the handler checks the nature of the fault: user-mode fault or kernel-mode fault if the page is valid - it is mapped otherwise SIGSEGV is sent to the user process or kernel panic exception: sending of a invalid pointer from user-space or kernel space checks the address of the instruction that generated the fault OSP Lecture 5, UML 24/33

IRQ copied from i386 for i386: the interrupt routine is called through do irq for um: interrupts are simulated through SIGIO the routine is chosen through the file descriptor that is associated with the device OSP Lecture 5, UML 25/33

The result a Linux virtual machine runs on a Linux host operating system native applications run un-modified on UML has the advantage of using the latest kernel (over other virtualization techniques) from 2.6 up, the um architecture is included in the kernel from 2.6 up SKAS (separate kernel address space) is used instead of MT OSP Lecture 5, UML 26/33

Applications kernel debugging isolation prototiping (testing on a virtual system before launching on the physical system) multiple environments on the same physical system OSP Lecture 5, UML 27/33

Outline User-Mode Linux Keywords Resources Questions OSP Lecture 5, UML 28/33

Keywords Linux kernel user-mode context switch address space system calls traps memory faults IRQ OSP Lecture 5, UML 29/33

Outline User-Mode Linux Keywords Resources Questions OSP Lecture 5, UML 30/33

Resources http://www.usenix.org/publications/library/ proceedings/als00/2000papers/papers/full_papers/ dike/ https://www.usenix.org/publications/library/ proceedings/als01/full_papers/dike/ http://user-mode-linux.sourceforge.net/ http://user-mode-linux.sourceforge.net/old/ UserModeLinux-HOWTO.html http://www.coherenthosting.com/prj/uml/henrique/ pool_h01/ OSP Lecture 5, UML 31/33

Outline User-Mode Linux Keywords Resources Questions OSP Lecture 5, UML 32/33

Questions? OSP Lecture 5, UML 33/33