ARM VIRTUALIZATION FOR THE MASSES. Christoffer Dall <c.dall@virtualopensystems.com> <cdall@cs.columbia.edu>



Similar documents
KVM/ARM: Experiences Building the Linux ARM Hypervisor

KVM/ARM: The Design and Implementation of the Linux ARM Hypervisor

ARMv8 Technology Preview. By Richard Grisenthwaite Lead Architect and Fellow. ARM

Hardware accelerated Virtualization in the ARM Cortex Processors

Virtualization in the ARMv7 Architecture Lecture for the Embedded Systems Course CSD, University of Crete (May 20, 2014)

ARM Cortex-R Architecture

Prototype of Light-weight Hypervisor for ARM Server Virtualization

Virtualization. Pradipta De

Virtualization in Linux KVM + QEMU

Architecture of the Kernel-based Virtual Machine (KVM)

Cortex-A9 MPCore Software Development

ARM Virtualization: CPU & MMU Issues

PROCESSOR VIRTUALIZATION ON EMBEDDED LINUX SYSTEMS

A Choices Hypervisor on the ARM architecture

Nested Virtualization

UNIT 4 Software Development Flow

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

Virtualization Technology. Zhiming Shen

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

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

The ARM Architecture. With a focus on v7a and Cortex-A8

ARM Caches: Giving you enough rope... to shoot yourself in the foot. Marc Zyngier KVM Forum 15

Nested Virtualization

Virtualization. Types of Interfaces

ARM Microprocessor and ARM-Based Microcontrollers

Exception and Interrupt Handling in ARM

Full and Para Virtualization

kvm: Kernel-based Virtual Machine for Linux

Advanced Computer Networks. Network I/O Virtualization

Hardware Based Virtualization Technologies. Elsie Wahlig Platform Software Architect

Interrupt handling. Andrew N. Sloss

Exploring the Design of the Cortex-A15 Processor ARM s next generation mobile applications processor. Travis Lanier Senior Product Manager

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

IOMMU: A Detailed view

Virtualization. Dr. Yingwu Zhu

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

Nested Virtualization

Going beyond a faster horse to transform mobile devices

COS 318: Operating Systems. Virtual Machine Monitors

Distributed Systems. Virtualization. Paul Krzyzanowski

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

Taming Hosted Hypervisors with (Mostly) Deprivileged Execution

Formal virtualization requirements for the ARM architecture

Hypervisors and Virtual Machines

System Virtual Machines

Hardware Virtualization on. ARM Cortex-A Low-Cost Building automation

Real-time KVM from the ground up

Virtual Machines. COMP 3361: Operating Systems I Winter

ARM Accredited Engineer AAE Syllabus. Document number: ARM AEG 0052C Copyright ARM Limited 2012

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

Embedded Hypervisor Xvisor: A comparative analysis

Virtual machines and operating systems

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

Performance tuning Xen

Operating Systems. Lecture 03. February 11, 2013

Sierraware Overview. Simply Secure

Virtualization System Vulnerability Discovery Framework. Speaker: Qinghao Tang Title:360 Marvel Team Leader

Microkernels, virtualization, exokernels. Tutorial 1 CSC469

Using Linux as Hypervisor with KVM

Kernel Virtual Machine

Virtual Machines. Virtualization

x86 ISA Modifications to support Virtual Machines

Development of Type-2 Hypervisor for MIPS64 Based Systems

Hypervisor: Requirement Document (Version 3)

Virtualization VMware Inc. All rights reserved

Leveraging Thin Hypervisors for Security on Embedded Systems

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

Intel Virtualization Technology Overview Yu Ke

Cloud Computing #6 - Virtualization

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

Efficient Load Balancing using VM Migration by QEMU-KVM

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

kvm: the Linux Virtual Machine Monitor

Chapter 5 Cloud Resource Virtualization

COMP9242 Advanced Operating Systems S2/2013 Week 8: Virtualization

KVM Architecture Overview

matasano Hardware Virtualization Rootkits Dino A. Dai Zovi

FRONT FLYLEAF PAGE. This page has been intentionally left blank

The Xen of Virtualization

The MIPS architecture and virtualization

Comprehensive Security for Internet-of-Things Devices With ARM TrustZone

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

ARM7TDMI-S. Technical Reference Manual. (Rev 3) Copyright ARM Limited All rights reserved. ARM DDI 0084F

Virtualization. Jia Rao Assistant Professor in CS

GUEST OPERATING SYSTEM BASED PERFORMANCE COMPARISON OF VMWARE AND XEN HYPERVISOR

A Hypervisor IPS based on Hardware assisted Virtualization Technology

x86 Virtualization Hardware Support Pla$orm Virtualiza.on

Using SmartOS as a Hypervisor

Beyond the Hypervisor

Electrical Engineering and Computer Science Department

A quantitative comparison between xen and kvm

KVM: Kernel-based Virtualization Driver

Porting Linux to a Hypervisor Based Embedded System

12. Introduction to Virtual Machines

A Unified View of Virtual Machines

An Introduction to the ARM 7 Architecture

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

KVM on S390x. Revolutionizing the Mainframe

Introduction to Virtualization & KVM

Research on System Virtualization using Xen Hypervisor for ARM based secure mobile phones

Transcription:

ARM VIRTUALIZATION FOR THE MASSES Christoffer Dall <c.dall@virtualopensystems.com> <cdall@cs.columbia.edu>

ARM

Smartphones

Smartphones

Tablets

Tablets

ARM Servers But now also...

But now also... ARM Servers Laptops

Even in cars

... and toasters!

So why virtualize?

So why virtualize? Server virtualization brings high availability, load balancing, and more..

So why virtualize? Phone virtualization ios on Android Home-phone Work-phone Throw-away virtual phones

So why virtualize? Rich OS in embedded space with legacy OS support

So why virtualize? Or debug events leading up to this kernel crash using GDB?

People Marc Zyngier from ARM: VGIC + Timers Antonios Motakis from Virtual Open Systems: VFP Rusty Russell from Linaro: User space register interface Peter Maydell from Linaro: QEMU and arch. compliance Christoffer Dall from Virtual Open Systems: Maintainer

KVM/ARM

ARM is not virtualizable KVM/ARM

KVM/ARM ARM is not virtualizable Requires Hardware Virtualization Extensions

KVM/ARM ARM is not virtualizable Requires Hardware Virtualization Extensions Runs on Cortex-A15 and Cortex-A7

KVM/ARM upstreaming Being upstreamed in mainline 14th patch series revision Waiting for ARM ack s Upstreamed through kvm/next or Russell King (ARM)

ARM Architecture RISC-style load/store architecture Two instruction modes: ARM and Thumb-2 Co-processors: An extension to the instruction set CP15 holds CPU control state

ARMv7 Processor Modes PL 0 User System SVC FIQ PL 1 IRQ UNDEF ABT

ARM Architecture Registers User System SVC ABT UND IRQ FIQ R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 SP_usr SP_svc SP_abt SP_und SP_irq SP_fiq LR_usr LR_svc LR_abt LR_und LR_irq LR_fiq PC CPSR SPSR_svc SPSR_abt SPSR_und SPSR_irq SPSR_fiq

ARM Virtualization Extensions Hardware support for virtualization Hyp-mode Stage-2 memory translation

ARMv7 Processor Modes PL 0 User System SVC FIQ PL 1 IRQ UNDEF ABT

Security Extensions (TrustZone) Non-Secure Secure PL 0 User User PL 1 System SVC FIQ IRQ UNDEF ABT System SVC FIQ IRQ UNDEF ABT Monitor

Virtualization Extensions Non-Secure Secure PL 0 User User PL 1 PL 2 System SVC FIQ IRQ UNDEF ABT HYP System SVC FIQ IRQ UNDEF ABT Monitor

Hyp mode Access to hypervisor control registers Controls stage-2 translations Entry through exception (ex. HVC instruction) Exit by exception return

LPAE Large-Physical-Address-Extension (LPAE) 40-bit physical addresses 64-bit page table descriptors Page table format used for stage-2 translations

Memory Translation with LPAE Virtual Addresses 0 User space application Kernel 4 GB MMU Stage-1 Page Tables Physical Addresses 0 2^40 RAM Devices

Stage-2 Page Tables Virtual Addresses 0 User space application Kernel 4 GB MMU Stage-1 Page Tables Intermediate Physical Addresses (IPA) 0 2^40 RAM Devices MMU Stage-1 Page Tables 0 2^40 Physical Addresses RAM Devices

Compared to x86 No concept of VMCS or VMRESUME / VMEXIT Instead, control registers must be programmed in Hyp mode Hyp mode is not a superset of normal privileged mode! We cannot run the host kernel in Hyp mode. Hyp mode was designed with classic embedded hypervisor in mind

KVM QEMU VM0 VM1 Devices Guest Kernel Guest Kernel File Descriptors and IOCTLs Host Kernel KVM CPU + RAM Hardware

User space code void *mem; kvm_fd = open( /dev/kvm ); vm_fd = ioctl(kvm_fd, KVM_CREATE_VM, 0); posix_memalign(&mem, PAGE_SIZE, 0x20000000); ioctl(kvm_fd, KVM_SET_USER_MEMORY_REGION, mem); vcpu1_fd = ioctl(vm_fd, KVM_CREATE_VCPU, 0); vcpu2_fd = ioctl(vm_fd, KVM_CREATE_VCPU, 0); thread1_start(run_vcpu(vcpu1_fd)); thread1_start(run_vcpu(vcpu2_fd)); while (1) process_io();

KVM and Hyp mode Running VMs have to go through Hyp mode VM data structures must be mapped in Hyp mode Host Kernel KVM Hyp mode KVM VM

Owning Hyp mode HVC instruction enters Hyp mode CPU jumps to HVBAR + offset Host kernel must control HVBAR and HTTBR Boot the kernel in Hyp mode, not SVC!

KVM/ARM Architecture QEMU PL0 VM0 Guest Kernel PL0 + PL1 VM1 Guest Kernel PL0 + PL1 Host Kernel PL1 KVM PL1 + PL2 Hardware

KVM/ARM Architecture KVM virtualizes CPU and Memory QEMU virtualizes platform and devices Two exceptions: VGIC and Timer

CPU virtualization Context switching guest accessible registers Trap access to other registers and emulate in software

Memory Virtualization Built on hardware support VMID tagged caches and TLB Support swapping through MMU notifiers Support freeing stage-2 page tables Support hugetlbfs and THP (waiting on ARM support)

Handling stage-2 aborts

Handling stage-2 aborts 1.Assign a blank stage-2 PGD to the VM

Handling stage-2 aborts 1.Assign a blank stage-2 PGD to the VM 2.Run vcpu

Handling stage-2 aborts 1.Assign a blank stage-2 PGD to the VM 2.Run vcpu 3.VM generates stage-2 fault to Hyp mode

Handling stage-2 aborts 1.Assign a blank stage-2 PGD to the VM 2.Run vcpu 3.VM generates stage-2 fault to Hyp mode 4.Capture fault information

Handling stage-2 aborts 1.Assign a blank stage-2 PGD to the VM 2.Run vcpu 3.VM generates stage-2 fault to Hyp mode 4.Capture fault information 5.Create stage-2 mapping

Handling stage-2 aborts 1.Assign a blank stage-2 PGD to the VM 2.Run vcpu 3.VM generates stage-2 fault to Hyp mode 4.Capture fault information 5.Create stage-2 mapping 6.Run vcpu

I/O Virtualization Intermediate Physical Addresses (IPA) 2^40 All I/O is MMIO A stage-2 abort not in RAM considered I/O Emulation hints in HSR RAM 0

Load/Store instruction decoding

Load/Store instruction decoding ldr sp, {r0, #4}!

Load/Store instruction decoding addr = reg[0] + 4; ldr sp, {r0, #4}! reg[sp] = mem[addr]; reg[0] = addr;

Load/Store instruction decoding addr = reg[0] + 4; ldr sp, {r0, #4}! reg[sp] = mem[addr]; reg[0] = addr; No decode hints in HSR!

Load/Store instruction decoding addr = reg[0] + 4; ldr sp, {r0, #4}! reg[sp] = mem[addr]; reg[0] = addr; No decode hints in HSR! Avoided in newer kernels

Hardware Interrupts VM SVC/USR Configured to trap to Hyp mode IRQ World-Switch back into host Re-enable IRQs KVM HYP World-Switch HOST SVC

Generic Interrupt Controller Devices CPU 0 GIC CPU 1

Generic Interrupt Controller Devices Dist. CPU Interface CPU 0 CPU Interface CPU 1 GIC

Generic Interrupt Controller Devices Dist. CPU Interface CPU 0 CPU Interface CPU 1 GIC

Generic Interrupt Controller Devices Dist. CPU Interface CPU 0 CPU Interface CPU 1 GIC

Generic Interrupt Controller Devices Dist. CPU Interface CPU 0 CPU Interface CPU 1 GIC

Generic Interrupt Controller Devices Dist. CPU Interface CPU 0 CPU Interface CPU 1 GIC

Generic Interrupt Controller Devices Dist. CPU Interface Virtual CPU Interface CPU 0 Virtual Control Interface GIC CPU Interface Virtual CPU Interface CPU 1

Virtual Interrupts Generated by QEMU devices KVM_IRQ_LINE Programmed in VGIC list registers No virtual distributor interface

Architected Generic Timers Defines physical + virtual timer and counter Virtual counter = Physical counter + offset Counter reads from guest without trap Timer interrupts do trap

DEMO

Voodoo Bug

Voodoo Bug page = get_user_pages(...);... if (map_writable) SetPageDirty(page); stage2_set_pte(page,...); put_page(page);

Voodoo Bug page = get_user_pages(...);... SetPageDirty(page); stage2_set_pte(page,...); put_page(page);

Clues?

Questions?