Architecture of the Kernel-based Virtual Machine (KVM)

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

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

KVM in Embedded Requirements, Experiences, Open Challenges

Full and Para Virtualization

Using Linux as Hypervisor with KVM

Nested Virtualization

KVM: Kernel-based Virtualization Driver

Advanced Computer Networks. Network I/O Virtualization

KVM Architecture Overview

BHyVe. BSD Hypervisor. Neel Natu Peter Grehan

Hybrid Virtualization The Next Generation of XenLinux

Virtual Machines. COMP 3361: Operating Systems I Winter

Kernel Virtual Machine

Nested Virtualization

KVM on S390x. Revolutionizing the Mainframe

Virtualization Technology. Zhiming Shen

Performance tuning Xen

Real-Time KVM for the Masses Unrestricted Siemens AG All rights reserved

Virtualization in Linux KVM + QEMU

COS 318: Operating Systems. Virtual Machine Monitors

Virtual machines and operating systems

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

Cloud Computing CS

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

kvm: the Linux Virtual Machine Monitor

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

Real-time KVM from the ground up

Real-Time Virtualization How Crazy Are We?

The QEMU/KVM Hypervisor

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

Virtualization. Pradipta De

Assessing the Performance of Virtualization Technologies for NFV: a Preliminary Benchmarking

Introduction to Virtualization & KVM

Tracing Kernel Virtual Machines (KVM) and Linux Containers (LXC)

Chapter 5 Cloud Resource Virtualization

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

vpf_ring: Towards Wire-Speed Network Monitoring Using Virtual Machines

Intel Virtualization Technology Overview Yu Ke

Virtualization. Types of Interfaces

The Art of Virtualization with Free Software

The Xen of Virtualization

Virtualization. Jia Rao Assistant Professor in CS

kvm: Kernel-based Virtual Machine for Linux

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

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

Hardware Based Virtualization Technologies. Elsie Wahlig Platform Software Architect

Enterprise-Class Virtualization with Open Source Technologies

KVM KERNEL BASED VIRTUAL MACHINE

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

12. Introduction to Virtual Machines

ARM VIRTUALIZATION FOR THE MASSES. Christoffer Dall

Performance Profiling in a Virtualized Environment

Virtualization. Jukka K. Nurminen

RPM Brotherhood: KVM VIRTUALIZATION TECHNOLOGY

VMkit A lightweight hypervisor library for Barrelfish

Xen and the Art of. Virtualization. Ian Pratt

Microkernels, virtualization, exokernels. Tutorial 1 CSC469

ELI: Bare-Metal Performance for I/O Virtualization

Chapter 14 Virtual Machines

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

Database Virtualization

vpf_ring: Towards Wire-Speed Network Monitoring Using Virtual Machines

The Microsoft Windows Hypervisor High Level Architecture

Virtualization Overview

Virtualization benefits Introduction to XenSource How Xen is changing virtualization The Xen hypervisor architecture Xen paravirtualization

PROCESSOR VIRTUALIZATION ON EMBEDDED LINUX SYSTEMS

Virtualization and Performance NSRC

Virtual device passthrough for high speed VM networking

Virtual Machines. Virtualization

Compromise-as-a-Service

High-performance vnic framework for hypervisor-based NFV with userspace vswitch Yoshihiro Nakajima, Hitoshi Masutani, Hirokazu Takahashi NTT Labs.

Taming Hosted Hypervisors with (Mostly) Deprivileged Execution

A quantitative comparison between xen and kvm

Knut Omang Ifi/Oracle 19 Oct, 2015

Virtualization. Dr. Yingwu Zhu

Beyond the Hypervisor

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

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

Basics of Virtualisation

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

KVM Virtualized I/O Performance

Hypervisors and Virtual Machines

Cloud Operating Systems for Servers

Distributed Systems. Virtualization. Paul Krzyzanowski

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

Embedded Hypervisor Xvisor: A comparative analysis

Development of Type-2 Hypervisor for MIPS64 Based Systems

HRG Assessment: Stratus everrun Enterprise

Nested Virtualization

Enabling Technologies for Distributed Computing

How Linux kernel enables MidoNet s overlay networks for virtualized environments. LinuxTag Berlin, May 2014

DPDK Summit 2014 DPDK in a Virtual World

Xen and the Art of Virtualization

I/O Virtualization Using Mellanox InfiniBand And Channel I/O Virtualization (CIOV) Technology

Virtualizing a Virtual Machine

Large-scale performance monitoring framework for cloud monitoring. Live Trace Reading and Processing

Hardware accelerated Virtualization in the ARM Cortex Processors

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

Transcription:

Corporate Technology Architecture of the Kernel-based Virtual Machine (KVM) Jan Kiszka, Siemens AG, CT T DE IT 1 Corporate Competence Center Embedded Linux jan.kiszka@siemens.com Copyright Siemens AG 2010. All rights reserved.

Agenda Introduction Basic KVM model Memory API Optimizations Paravirtual devices Outlook Slide 2 2010-09-23 Jan Kiszka, CT T DE IT 1

Virtualization of Commodity Computers Busses & I/O Devices Instruction Set CPU MMU On-Chip Resources Interrupt Controllers Clocks & Timers Memory Slide 3 2010-09-23 Jan Kiszka, CT T DE IT 1

Virtualizing the x86 Instruction Set Architecture x86 originally virtualization unfriendly No hardware provisions Instructions behave differently depending on privilege context Performance suffered on trap-and-emulate CISC nature complicates instruction replacements Early approaches to x86 virtualization Binary translation (e.g. VMware) Execute substitution code for privileged guest code May require substantial replacements to preserve illusion CPU paravirtualization (e.g Xen) Guest is aware of instruction restrictions Hypervisor provides replacement services (hypercalls) Raised abstraction levels for better performance Slide 4 2010-09-23 Jan Kiszka, CT T DE IT 1

Hardware-assisted x86 CPU Virtualization Two variants Intel's Virtualization Technology, VT-x AMD-V (aka Secure Virtual Machine) Identical core concept CPU 3 2 1 0 Host State Guest State VCPU 3 2 1 0 Slide 5 2010-09-23 Jan Kiszka, CT T DE IT 1

Advent and Evolution of KVM Introduced to make VT-x/AMD-V available to user space Exposes virtualization features securely Interface: /dev/kvm Merged quickly Available since 2.6.20 (2006) From first LKML posting to merge: 3 months One reason: originally 100% orthogonal to core kernel Evolved significantly since then Ported to further architectures (s390, PowerPC, IA64) Always with latest x86 virtualization features Became recognized & driving part of Linux Slide 6 2010-09-23 Jan Kiszka, CT T DE IT 1

The KVM Model Processes can create virtual machines VMs can contain Memory Virtual CPUs In-kernel device models Guest physical memory part of creating process' address space Guest Memory VCPU VCPU Thread Thread Hypervisor Process Thread VCPUs run in process execution contexts Process usually maps VCPUs on threads CPU KVM CPU Linux Kernel CPU Slide 7 2010-09-23 Jan Kiszka, CT T DE IT 1

Architectural Advantages of the KVM Model Proximity of guest and user space hypervisor Only one address space switch: guest host Less rescheduling Massive Linux kernel reuse Scheduler Memory management with swapping (though you don't what this) I/O stacks Power management Host CPU hot-plugging Massive Linux user land reuse Network configuration Handling VM images Logging, tracing, debugging... Slide 8 2010-09-23 Jan Kiszka, CT T DE IT 1

VCPU Execution Flow (KVM View) Update context, raise IRQs Update guest state Run Save Host, Load Guest State Handle In-Kernel I/O [vmmu]... Handle I/O Invalid states... Save Guest, Load Host State Handle Signal Handle Host IRQ Kernel User Space VM entry Execute native guest code VM exit (with reason) CPU Slide 9 2010-09-23 Jan Kiszka, CT T DE IT 1

KVM Memory Model Slot-based guest memory Maps guest physical to host virtual memory Reconfigurable Supports dirty tracking In-Kernel Virtual MMU Coalesced MMIO Optimizes guest access to RAM-like virtual MMIO regions Out of scope Memory ballooning (guest user space hypervisor) Kernel Same-page Merging (not KVM-specific) RAM RAM RAM Coalesced MMIO Unassigned RAM Guest Address Space Hypervisor Address Space Slide 10 2010-09-23 Jan Kiszka, CT T DE IT 1

KVM API Overview Step #1: open /dev/kvm Three groups of IOCTLs System-level requests VM-level requests VCPU-level requests Per-group file descriptors /dev/kvm fd for system level Creating a VM or VCPU returns new fd mmap on file descriptors VCPU: fast kernel-user communication segment Frequently read/modified part of VCPU state Includes coalesced MMIO backlog VM: map guest physical memory (deprecated) Slide 11 2010-09-23 Jan Kiszka, CT T DE IT 1

Basic KVM IOCTLs KVM_CREATE_VM KVM_SET_USER_MEMORY_REGION KVM_CREATE_IRQCHIP /...PIT KVM_CREATE_VCPU (x86) KVM_SET_REGS /...SREGS /...FPU /... KVM_SET_CPUID /...MSRS /...VCPU_EVENTS /... KVM_SET_LAPIC KVM_RUN (x86) (x86) Slide 12 2010-09-23 Jan Kiszka, CT T DE IT 1

Optimizations of KVM Hardware evolves quickly Near-native performance in guest mode Decreasing costs of mode switches Additional features avoid software solutions, thus exits Nested page tables TLB tagging APIC virtualization... What will continue to consume cycles? Code path between VM-exit and VM-entry Mode switches, i.e. the need to exit at all Slide 13 2010-09-23 Jan Kiszka, CT T DE IT 1

Lightweight vs. Heavy-weight VM-Exits Exits cost time! Basic state switch in hardware Additional state switches in software Analyze exit reason Return In-kernel to APIC user space Analyze exit reason In-kernel IO-APIC + PIC Obtain KVM state (VCPU, devices) Coalescing MMIO Handle exit cause Write In-kernel back instruction states interpreter (detect MMIO access) Invoke In-kernel KVM_RUN network stub (vhost-net) >7.000 cycles Software-managed state switch Hardware state switch >10.000 cycles Slide 14 2010-09-23 Jan Kiszka, CT T DE IT 1

Optimizing Lightweight Exits Let's get lazy! Perform only partial state switches Complete at latest possible point Late restoring for guest and host state Candidates (x86) FPU Debug registers Model-specific registers (MSRs) Requirements Usage detection when in guest mode Depends on hardware support Demand detection while in host mode Preemption notifiers User-return notifier z z z Slide 15 2010-09-23 Jan Kiszka, CT T DE IT 1

Lazy MSR Switching Why is this possible? Some MSRs unused by Linux Some MSRs only relevant when in user space Some are identical for host & guest Approach Keep guest values of certain MSRs until... sched-out fires KVM_RUN IOCTL returns Keep others until user-return fires (Intel only) Optimizations are vendor-specific Exemplary saving: 2000 cycles for guest idle thread guest Slide 16 2010-09-23 Jan Kiszka, CT T DE IT 1

Paravirtual Devices Advantages Reduce VM exits or make them lightweight Improve I/O throughput & latency (less emulation) Compensates virtualization effects Enable direct host-guest interaction Available interfaces & implementions virtio (PCI or alternative transports) Network Block Serial I/O (console, host-guest channel, ) Memory balloon File system (9P) Clock (x86 only) Via shared page + MSRs Enables safe TM TSC guest usage user space business (primarily) KVM business Slide 17 2010-09-23 Jan Kiszka, CT T DE IT 1

An Almost-In-Kernel Device vhost-net Goal: high throughput / low latency guest networking Avoid heavy exits Reduce packet copying No in-kernel QEMU, please! The vhost-net model Host user space opens and configures kernel helper virtio as guest-host interface KVM interface: eventfd TX trigger ioeventfd RX signal irqfd Linux interface vie tap or macvtap Enables multi-gigabit throughput irqfd VCPU vhost-net worker kthread Linux network stack KVM ioeventfd memory r/w r/w r virtio ring & buffers memory slot table hypervisor process Slide 18 2010-09-23 Jan Kiszka, CT T DE IT 1

What's next? Generic Linux improvements Transparent huge pages (mm topic) NUMA optimizations (scheduler topic) Improve spin-lock-holder preemption effects Zero-copy & multi-queue vhost-net Further optimize exits Instruction interpretation (hardware may help) Faster in-kernel device dispatching Nested virtualization as standard feature AMD-V bits already merged and working VT-x more complex but likely solvable Hardware-assisted virtualization on non-x86 PowerPC ISA 2.06 ARMv7-A Eagle extensions Slide 19 2010-09-23 Jan Kiszka, CT T DE IT 1

Thanks you for listening! Questions? Slide 20 2010-09-23 Jan Kiszka, CT T DE IT 1