SlideShare a Scribd company logo
Porting Xen Paravirtualization to
MIPS Architecture
Yonghong Song
Broadcom




                                    1
Motivation

• Broadcom XLP
  –   8 cores, 4 threads each core
  –   Out-Of-
      Out-Of-Order
  –   L1D, L1I, L2 each core, shared L3
  –   Accelerators: NET, SEC, RAID, DMA, COMP, etc.
  –   SOCs: USB, PCIE, FLASH, I2C, etc.
• Need for a software enabled virtualization solution
• Xen ported and provided as a solution




                                                        2
General Xen Usage Model




     Xen dom0               Xen domU          Xen domU
    (Mgmt App)              (Guest OS)        (Guest OS)




launch   Create, monitor, destroy


                             Xen Hypervisor


            Hardware (CPU, Memory, Disk, Net/PCI, etc)


                                                           3
Hybrid Control/Data Plane Model



                       Shared Memory




       Control Plane         Data Plane     Data Plane



                       Bare Metal Linux


                                          NET



                                                         4
Proposed Model in Xen



                       Shared Memory




          Dom0                DomU           DomU
       Control Plane        Data Plane     Data Plane



                           Xen


                                         NET



                                                        5
Outline

• CPU Virtualization (mips64r2 only)
   • Memory virtualization
   • Instruction emulation
   • Exception handling
   • Event Channel and Timer Interrupt
• Preliminary Benchmarking Results
• Summary and Future Work




                                         6
Change of Privilege Levels


       Bare Metal Mode              Virtualization Mode

          User apps                     User apps
                                          Linux


             Linux
               L                             Xen
                                              L




         : user ring     : supervisor ring          : kernel ring



                                                                    7
Address Spaces


              user space         guest kernel virtual space
GVA
               (0 – 2^40)        (0x4000 0000 0000 0000 -)




 GPA        guest 0 phys addr                    guest N phys addr



  MA                               machine memory

 Kernel code + data | shared pages with xen | … | kernel page table | free pages


0x0                                                 Size allocated to each guest
       Xen in unmapped space
                                                                                   8
Page Table Management


        guest page table               P2M table



                            GPA                    MA
  GVA



                    new guest page table



              GVA                          MA




                                                        9
Page Table Layout



                       Bare Metel Linux
         pgd
                                 pmd
                                           pte
    VA pf PMD page
                          VA pf PTE page   PA




    pgd: page global directory
    pmd: page middle directory
    pte: page table entry



                                                 10
Page Table Layout

                              PV Linux
             pgd
                                   pmd
 xkphys (MA of PMD page)                              pte
                           xkphys(MA of PTE page)   MA address




 xkphys: 64-bit kernel physical space (unmapped)
 xkphys: avoid TLB refill during page table walk
 Hardware page walker is used


                                                                 11
Instruction Emulation

• Privileged instructions in guests get trapped and emulated
• XEN trap handlers decipher the instruction and emulate
  appropriately
• A few instructions cause hardware state to change, while
  others change the shadow state
• Shadow state is maintained per virtual cpu of domains
                                    Privileged Insns
                                                       Guest
                                                        Xen
         Shadow states

           cop0 regs        mfc0      tlbp
                            mtc0
                                              tlbs
                                      tlbr
          Bookkeeping for   ei/di
          Exception prop    eret             caches
                            …
                                                               12
Hypercalls

• The service API between guests and xen
• Analogous to system calls between userspace and linux
• Used when a particular service is requested or the overhead
  of trap and emulate is high
• Implemented using the “syscall” instruction
• Sample uses: vcpu creation, request cache flush, etc

                      userspace
          syscall
                        linux
        hypercall
                        xen

                                                                13
Exception Handling

• Exceptions triggered by guests handled by xen
  – Hypercalls
  – Address error exception
  – Privileged instruction traps
• Exceptions triggered by userspace bounced into guests
  – Guests register callbacks for exception entry points such as general
    exception vector etc
  – Xen maintains shadow state to return to userspace after the
    propagated exception is handled
  – Interrupts injected into guests while the bounced exception is
    handled, retaining regular linux semantics




                                                                           14
A syscall example

                                                                     Applications

1. syscall insn                                                8. app resumes
                                                               after syscall

                  4. xen bounces     5. guest syscall
                  syscall to guest   handling
                                                                    Guest Kernel
                           priv
                           insn                         eret
                           trap
   2. control          e                                       7. xen restores
   transfers           r                                       Original state,
   xen                 e                                       Does final eret
                       t
                                       Shadow                  6. xen executes
 3. xen syscall                      architecture              Eret handler      Xen
 handler
                                        state




                                                                                       15
Event Channels

• Events: asynchronous notifications to domains (akin to
  signals in Unix)
• Event channels: abstract duplex communication channels
  (akin to sockets): <dom1, port1; dom2, port2>
• Interrupts are mapped to events
  – Intradomain & interdomain events (e.g., domU console)
  – Virtual IRQ (e.g., timer interrupts)
  – Physical IRQ (e.g., passthrough device interrupts)
• Delivered through a callback function




                                                            16
Time Management

• Time keeping in xen
  – Maintaining system time – Using XLP-specific internal global 64bit
    free running counter
  – Requesting timer interrupts: done by maintaining per-cpu timer list
    and programming the count/compare registers
• Guest OS
  – Xen clocksource: a hardware abstraction for a free running counter to
    maintain system time
     – Maintained through timestamps written by xen on a shared page
  – Xen clockevent: an interface to request timer interrupts
     – Done using the hypercall to program a single shot timer in xen




                                                                            17
Timer Interrupt Illustration


                                                                       Applications


   1. timer
    interrupt           6. guest executes
   occurs               event handler
                                                                       Guest Kernel
                      5. xen injects   7. guest
                      event into       does eret
   2. control         guest                              9. xen restores
   transfers                                             original state,
   to xen                                                does final eret

   3. xen interrupt   4. xen sets           8. xen exectues
   handler            event pending         eret handler                       Xen
   executes           for the guest




                                                                                      18
Performance Optimization

• Expose certain shadow states for guest OS to avoid
  excessive exception start/end cost
• When guest executes “wait” insn, xen tries to “wait” also to
  avoid burning cpu resources




                                                                 19
Preliminary Benchmarking Result

• XLP832: 8 cores, 4 threads each core, 1.0GHZ
  – Only 1 core, 4 threads used for measuring time
• Intel Core 2: 2 cores, 1 thread per core, 2.4GHZ
  – Not using hardware virtualization extensions
• CPU/Memory intensive benchmarks like dhrystone, eembc,
  coremark, etc.
  – 0 – 5% slowdown for dom0 compared to bare metal linux, for both x86
    and XLP
• Hackbench (a lot of system calls)
  – 2X slowdown for dom0 compared to bare metal linux, for both x86
    and XLP
• No noticeable performance difference between dom0 and
  domU on XLP

                                                                          20
Summary and Future Work

• A MIPS port of xen paravirtualization has implemented
  – MMU, exception/interrupt handling, etc.
  – Comparable performance to x86 for bare metal vs. xen
• Currently, our implementation uses xen 3.4.0 for xen
  hypervisor, 4.0.0 for xen tools, linux 2.6.32 for PV linux, so
  we need to
  – Update to latest versions of Xen
  – Submit patches upstream
• More work on I/O paravirtualization
• Ongoing collaboration with MIPS Technologies




                                                                   21
Thank You

More Related Content

PDF
XenSummit NA 2012: Xen on ARM Cortex A15
The Linux Foundation
 
PDF
From printk to QEMU: Xen/Linux Kernel debugging
The Linux Foundation
 
PPTX
XenTT: Deterministic Systems Analysis in Xen
The Linux Foundation
 
PDF
Linaro connect : Introduction to Xen on ARM
The Linux Foundation
 
PDF
Xen Debugging
The Linux Foundation
 
PDF
Virtunoid: Breaking out of KVM
Nelson Elhage
 
PDF
QEMU Disk IO Which performs Better: Native or threads?
Pradeep Kumar
 
PDF
Kvm performance optimization for ubuntu
Sim Janghoon
 
XenSummit NA 2012: Xen on ARM Cortex A15
The Linux Foundation
 
From printk to QEMU: Xen/Linux Kernel debugging
The Linux Foundation
 
XenTT: Deterministic Systems Analysis in Xen
The Linux Foundation
 
Linaro connect : Introduction to Xen on ARM
The Linux Foundation
 
Xen Debugging
The Linux Foundation
 
Virtunoid: Breaking out of KVM
Nelson Elhage
 
QEMU Disk IO Which performs Better: Native or threads?
Pradeep Kumar
 
Kvm performance optimization for ubuntu
Sim Janghoon
 

What's hot (20)

PDF
Qemu Introduction
Chiawei Wang
 
PPTX
QEMU and Raspberry Pi. Instant Embedded Development
GlobalLogic Ukraine
 
PDF
XPDS14: Removing the Xen Linux Upstream Delta of Various Linux Distros - Luis...
The Linux Foundation
 
ODP
Kvm
Bert Desmet
 
PDF
KVM tools and enterprise usage
vincentvdk
 
PDF
Xen in Linux 3.x (or PVOPS)
The Linux Foundation
 
PPTX
PV-Drivers for SeaBIOS using Upstream Qemu
The Linux Foundation
 
PDF
kdump: usage and_internals
LinuxCon ContainerCon CloudOpen China
 
ODP
Disk Performance Comparison Xen v.s. KVM
nknytk
 
PDF
XPDS14 - Xen as High-Performance NFV Platform - Jun Nakajima, Intel
The Linux Foundation
 
PDF
Kernel Recipes 2017 - Build farm again - Willy Tarreau
Anne Nicolas
 
PDF
FreeBSD and Drivers
Kernel TLV
 
PDF
Virtualization - Kernel Virtual Machine (KVM)
Wan Leung Wong
 
PDF
IITCC15: The Bare-Metal Hypervisor as a Platform for Innovation
The Linux Foundation
 
PDF
LCE13: Virtualization Forum
Linaro
 
PDF
Look Into Libvirt Osier Yang
OpenCity Community
 
PPTX
Drive into kvm
Udayendu Kar
 
PDF
IITCC15: Xen Project 4.6 Update
The Linux Foundation
 
PPTX
Link Virtualization based on Xen
The Linux Foundation
 
Qemu Introduction
Chiawei Wang
 
QEMU and Raspberry Pi. Instant Embedded Development
GlobalLogic Ukraine
 
XPDS14: Removing the Xen Linux Upstream Delta of Various Linux Distros - Luis...
The Linux Foundation
 
KVM tools and enterprise usage
vincentvdk
 
Xen in Linux 3.x (or PVOPS)
The Linux Foundation
 
PV-Drivers for SeaBIOS using Upstream Qemu
The Linux Foundation
 
kdump: usage and_internals
LinuxCon ContainerCon CloudOpen China
 
Disk Performance Comparison Xen v.s. KVM
nknytk
 
XPDS14 - Xen as High-Performance NFV Platform - Jun Nakajima, Intel
The Linux Foundation
 
Kernel Recipes 2017 - Build farm again - Willy Tarreau
Anne Nicolas
 
FreeBSD and Drivers
Kernel TLV
 
Virtualization - Kernel Virtual Machine (KVM)
Wan Leung Wong
 
IITCC15: The Bare-Metal Hypervisor as a Platform for Innovation
The Linux Foundation
 
LCE13: Virtualization Forum
Linaro
 
Look Into Libvirt Osier Yang
OpenCity Community
 
Drive into kvm
Udayendu Kar
 
IITCC15: Xen Project 4.6 Update
The Linux Foundation
 
Link Virtualization based on Xen
The Linux Foundation
 
Ad

Viewers also liked (9)

PDF
HDT: General overview April 1999
Piero Belforte
 
PPT
Diplomacia PúBlica De Los Estados Unidos
Leandro Pavón
 
PPTX
Campus Party México 2011
Melina Maqueda
 
PPT
PIC32MX Microcontroller Family
Premier Farnell
 
PPTX
The HaLVM: A Simple Platform for Simple Platforms
The Linux Foundation
 
PDF
Erlang on OSv
Zvi Avraham
 
PDF
Ling on PIC32 microcontroller
Viktor Sovietov
 
PDF
OSv at Cassandra Summit
Don Marti
 
PPTX
LinuxCon Japan 13 : 10 years of Xen and Beyond
The Linux Foundation
 
HDT: General overview April 1999
Piero Belforte
 
Diplomacia PúBlica De Los Estados Unidos
Leandro Pavón
 
Campus Party México 2011
Melina Maqueda
 
PIC32MX Microcontroller Family
Premier Farnell
 
The HaLVM: A Simple Platform for Simple Platforms
The Linux Foundation
 
Erlang on OSv
Zvi Avraham
 
Ling on PIC32 microcontroller
Viktor Sovietov
 
OSv at Cassandra Summit
Don Marti
 
LinuxCon Japan 13 : 10 years of Xen and Beyond
The Linux Foundation
 
Ad

Similar to Porting Xen Paravirtualization to MIPS Architecture (20)

PPTX
Dealing with Hardware Heterogeneity Using EmbeddedXEN, a Virtualization Frame...
The Linux Foundation
 
PPTX
Linuxcon EU : Virtualization in the Cloud featuring Xen and XCP
The Linux Foundation
 
PDF
Xen & the Art of Virtualization
Tareque Hossain
 
PDF
Xen Community Update 2011
The Linux Foundation
 
PPTX
Nested Virtualization Update from Intel
The Linux Foundation
 
ODP
UDS 2012 Xen
George Dunlap
 
PPSX
LinuxCon NA 2012: Virtualization in the cloud featuring xen
The Linux Foundation
 
PPTX
ARMvisor @ Linux Symposium 2012
Peter Chang
 
PPTX
Xen Project Update LinuxCon Brazil
The Linux Foundation
 
PDF
12 christian ferber xen_server_advanced
Digicomp Academy AG
 
PPTX
2011 10-19
Yaoyao Wang
 
PPTX
Xen cloud platform v1.1 (given at Build a Cloud Day in Antwerp)
The Linux Foundation
 
PPTX
Xen in the Cloud at SCALE 10x
The Linux Foundation
 
PPTX
Virtualization in the cloud
CloudStack - Open Source Cloud Computing Project
 
PPTX
Virtualization in the Cloud @ Build a Cloud Day SFO May 2012
The Linux Foundation
 
PPTX
Hyper V R2 Deep Dive
Aidan Finn
 
PDF
S4 xen hypervisor_20080622
Todd Deshane
 
PDF
Xenserver Highload Frank Kohler
Ontico
 
PDF
Highload Frank Kohler
Ontico
 
PDF
ARMvisor, more details
Peter Chang
 
Dealing with Hardware Heterogeneity Using EmbeddedXEN, a Virtualization Frame...
The Linux Foundation
 
Linuxcon EU : Virtualization in the Cloud featuring Xen and XCP
The Linux Foundation
 
Xen & the Art of Virtualization
Tareque Hossain
 
Xen Community Update 2011
The Linux Foundation
 
Nested Virtualization Update from Intel
The Linux Foundation
 
UDS 2012 Xen
George Dunlap
 
LinuxCon NA 2012: Virtualization in the cloud featuring xen
The Linux Foundation
 
ARMvisor @ Linux Symposium 2012
Peter Chang
 
Xen Project Update LinuxCon Brazil
The Linux Foundation
 
12 christian ferber xen_server_advanced
Digicomp Academy AG
 
2011 10-19
Yaoyao Wang
 
Xen cloud platform v1.1 (given at Build a Cloud Day in Antwerp)
The Linux Foundation
 
Xen in the Cloud at SCALE 10x
The Linux Foundation
 
Virtualization in the Cloud @ Build a Cloud Day SFO May 2012
The Linux Foundation
 
Hyper V R2 Deep Dive
Aidan Finn
 
S4 xen hypervisor_20080622
Todd Deshane
 
Xenserver Highload Frank Kohler
Ontico
 
Highload Frank Kohler
Ontico
 
ARMvisor, more details
Peter Chang
 

More from The Linux Foundation (20)

PDF
ELC2019: Static Partitioning Made Simple
The Linux Foundation
 
PDF
XPDDS19: How TrenchBoot is Enabling Measured Launch for Open-Source Platform ...
The Linux Foundation
 
PDF
XPDDS19 Keynote: Xen in Automotive - Artem Mygaiev, Director, Technology Solu...
The Linux Foundation
 
PDF
XPDDS19 Keynote: Xen Project Weather Report 2019 - Lars Kurth, Director of Op...
The Linux Foundation
 
PDF
XPDDS19 Keynote: Unikraft Weather Report
The Linux Foundation
 
PDF
XPDDS19 Keynote: Secret-free Hypervisor: Now and Future - Wei Liu, Software E...
The Linux Foundation
 
PDF
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx
The Linux Foundation
 
PDF
XPDDS19 Keynote: Patch Review for Non-maintainers - George Dunlap, Citrix Sys...
The Linux Foundation
 
PDF
XPDDS19: Memories of a VM Funk - Mihai Donțu, Bitdefender
The Linux Foundation
 
PPTX
OSSJP/ALS19: The Road to Safety Certification: Overcoming Community Challeng...
The Linux Foundation
 
PPTX
OSSJP/ALS19: The Road to Safety Certification: How the Xen Project is Making...
The Linux Foundation
 
PDF
XPDDS19: Speculative Sidechannels and Mitigations - Andrew Cooper, Citrix
The Linux Foundation
 
PDF
XPDDS19: Keeping Coherency on Arm: Reborn - Julien Grall, Arm ltd
The Linux Foundation
 
PDF
XPDDS19: QEMU PV Backend 'qdevification'... What Does it Mean? - Paul Durrant...
The Linux Foundation
 
PDF
XPDDS19: Status of PCI Emulation in Xen - Roger Pau Monné, Citrix Systems R&D
The Linux Foundation
 
PDF
XPDDS19: [ARM] OP-TEE Mediator in Xen - Volodymyr Babchuk, EPAM Systems
The Linux Foundation
 
PDF
XPDDS19: Bringing Xen to the Masses: The Story of Building a Community-driven...
The Linux Foundation
 
PDF
XPDDS19: Will Robots Automate Your Job Away? Streamlining Xen Project Contrib...
The Linux Foundation
 
PDF
XPDDS19: Client Virtualization Toolstack in Go - Nick Rosbrook & Brendan Kerr...
The Linux Foundation
 
PDF
XPDDS19: Core Scheduling in Xen - Jürgen Groß, SUSE
The Linux Foundation
 
ELC2019: Static Partitioning Made Simple
The Linux Foundation
 
XPDDS19: How TrenchBoot is Enabling Measured Launch for Open-Source Platform ...
The Linux Foundation
 
XPDDS19 Keynote: Xen in Automotive - Artem Mygaiev, Director, Technology Solu...
The Linux Foundation
 
XPDDS19 Keynote: Xen Project Weather Report 2019 - Lars Kurth, Director of Op...
The Linux Foundation
 
XPDDS19 Keynote: Unikraft Weather Report
The Linux Foundation
 
XPDDS19 Keynote: Secret-free Hypervisor: Now and Future - Wei Liu, Software E...
The Linux Foundation
 
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx
The Linux Foundation
 
XPDDS19 Keynote: Patch Review for Non-maintainers - George Dunlap, Citrix Sys...
The Linux Foundation
 
XPDDS19: Memories of a VM Funk - Mihai Donțu, Bitdefender
The Linux Foundation
 
OSSJP/ALS19: The Road to Safety Certification: Overcoming Community Challeng...
The Linux Foundation
 
OSSJP/ALS19: The Road to Safety Certification: How the Xen Project is Making...
The Linux Foundation
 
XPDDS19: Speculative Sidechannels and Mitigations - Andrew Cooper, Citrix
The Linux Foundation
 
XPDDS19: Keeping Coherency on Arm: Reborn - Julien Grall, Arm ltd
The Linux Foundation
 
XPDDS19: QEMU PV Backend 'qdevification'... What Does it Mean? - Paul Durrant...
The Linux Foundation
 
XPDDS19: Status of PCI Emulation in Xen - Roger Pau Monné, Citrix Systems R&D
The Linux Foundation
 
XPDDS19: [ARM] OP-TEE Mediator in Xen - Volodymyr Babchuk, EPAM Systems
The Linux Foundation
 
XPDDS19: Bringing Xen to the Masses: The Story of Building a Community-driven...
The Linux Foundation
 
XPDDS19: Will Robots Automate Your Job Away? Streamlining Xen Project Contrib...
The Linux Foundation
 
XPDDS19: Client Virtualization Toolstack in Go - Nick Rosbrook & Brendan Kerr...
The Linux Foundation
 
XPDDS19: Core Scheduling in Xen - Jürgen Groß, SUSE
The Linux Foundation
 

Recently uploaded (20)

PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Doc9.....................................
SofiaCollazos
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
The Future of Artificial Intelligence (AI)
Mukul
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 

Porting Xen Paravirtualization to MIPS Architecture

  • 1. Porting Xen Paravirtualization to MIPS Architecture Yonghong Song Broadcom 1
  • 2. Motivation • Broadcom XLP – 8 cores, 4 threads each core – Out-Of- Out-Of-Order – L1D, L1I, L2 each core, shared L3 – Accelerators: NET, SEC, RAID, DMA, COMP, etc. – SOCs: USB, PCIE, FLASH, I2C, etc. • Need for a software enabled virtualization solution • Xen ported and provided as a solution 2
  • 3. General Xen Usage Model Xen dom0 Xen domU Xen domU (Mgmt App) (Guest OS) (Guest OS) launch Create, monitor, destroy Xen Hypervisor Hardware (CPU, Memory, Disk, Net/PCI, etc) 3
  • 4. Hybrid Control/Data Plane Model Shared Memory Control Plane Data Plane Data Plane Bare Metal Linux NET 4
  • 5. Proposed Model in Xen Shared Memory Dom0 DomU DomU Control Plane Data Plane Data Plane Xen NET 5
  • 6. Outline • CPU Virtualization (mips64r2 only) • Memory virtualization • Instruction emulation • Exception handling • Event Channel and Timer Interrupt • Preliminary Benchmarking Results • Summary and Future Work 6
  • 7. Change of Privilege Levels Bare Metal Mode Virtualization Mode User apps User apps Linux Linux L Xen L : user ring : supervisor ring : kernel ring 7
  • 8. Address Spaces user space guest kernel virtual space GVA (0 – 2^40) (0x4000 0000 0000 0000 -) GPA guest 0 phys addr guest N phys addr MA machine memory Kernel code + data | shared pages with xen | … | kernel page table | free pages 0x0 Size allocated to each guest Xen in unmapped space 8
  • 9. Page Table Management guest page table P2M table GPA MA GVA new guest page table GVA MA 9
  • 10. Page Table Layout Bare Metel Linux pgd pmd pte VA pf PMD page VA pf PTE page PA pgd: page global directory pmd: page middle directory pte: page table entry 10
  • 11. Page Table Layout PV Linux pgd pmd xkphys (MA of PMD page) pte xkphys(MA of PTE page) MA address xkphys: 64-bit kernel physical space (unmapped) xkphys: avoid TLB refill during page table walk Hardware page walker is used 11
  • 12. Instruction Emulation • Privileged instructions in guests get trapped and emulated • XEN trap handlers decipher the instruction and emulate appropriately • A few instructions cause hardware state to change, while others change the shadow state • Shadow state is maintained per virtual cpu of domains Privileged Insns Guest Xen Shadow states cop0 regs mfc0 tlbp mtc0 tlbs tlbr Bookkeeping for ei/di Exception prop eret caches … 12
  • 13. Hypercalls • The service API between guests and xen • Analogous to system calls between userspace and linux • Used when a particular service is requested or the overhead of trap and emulate is high • Implemented using the “syscall” instruction • Sample uses: vcpu creation, request cache flush, etc userspace syscall linux hypercall xen 13
  • 14. Exception Handling • Exceptions triggered by guests handled by xen – Hypercalls – Address error exception – Privileged instruction traps • Exceptions triggered by userspace bounced into guests – Guests register callbacks for exception entry points such as general exception vector etc – Xen maintains shadow state to return to userspace after the propagated exception is handled – Interrupts injected into guests while the bounced exception is handled, retaining regular linux semantics 14
  • 15. A syscall example Applications 1. syscall insn 8. app resumes after syscall 4. xen bounces 5. guest syscall syscall to guest handling Guest Kernel priv insn eret trap 2. control e 7. xen restores transfers r Original state, xen e Does final eret t Shadow 6. xen executes 3. xen syscall architecture Eret handler Xen handler state 15
  • 16. Event Channels • Events: asynchronous notifications to domains (akin to signals in Unix) • Event channels: abstract duplex communication channels (akin to sockets): <dom1, port1; dom2, port2> • Interrupts are mapped to events – Intradomain & interdomain events (e.g., domU console) – Virtual IRQ (e.g., timer interrupts) – Physical IRQ (e.g., passthrough device interrupts) • Delivered through a callback function 16
  • 17. Time Management • Time keeping in xen – Maintaining system time – Using XLP-specific internal global 64bit free running counter – Requesting timer interrupts: done by maintaining per-cpu timer list and programming the count/compare registers • Guest OS – Xen clocksource: a hardware abstraction for a free running counter to maintain system time – Maintained through timestamps written by xen on a shared page – Xen clockevent: an interface to request timer interrupts – Done using the hypercall to program a single shot timer in xen 17
  • 18. Timer Interrupt Illustration Applications 1. timer interrupt 6. guest executes occurs event handler Guest Kernel 5. xen injects 7. guest event into does eret 2. control guest 9. xen restores transfers original state, to xen does final eret 3. xen interrupt 4. xen sets 8. xen exectues handler event pending eret handler Xen executes for the guest 18
  • 19. Performance Optimization • Expose certain shadow states for guest OS to avoid excessive exception start/end cost • When guest executes “wait” insn, xen tries to “wait” also to avoid burning cpu resources 19
  • 20. Preliminary Benchmarking Result • XLP832: 8 cores, 4 threads each core, 1.0GHZ – Only 1 core, 4 threads used for measuring time • Intel Core 2: 2 cores, 1 thread per core, 2.4GHZ – Not using hardware virtualization extensions • CPU/Memory intensive benchmarks like dhrystone, eembc, coremark, etc. – 0 – 5% slowdown for dom0 compared to bare metal linux, for both x86 and XLP • Hackbench (a lot of system calls) – 2X slowdown for dom0 compared to bare metal linux, for both x86 and XLP • No noticeable performance difference between dom0 and domU on XLP 20
  • 21. Summary and Future Work • A MIPS port of xen paravirtualization has implemented – MMU, exception/interrupt handling, etc. – Comparable performance to x86 for bare metal vs. xen • Currently, our implementation uses xen 3.4.0 for xen hypervisor, 4.0.0 for xen tools, linux 2.6.32 for PV linux, so we need to – Update to latest versions of Xen – Submit patches upstream • More work on I/O paravirtualization • Ongoing collaboration with MIPS Technologies 21