SlideShare a Scribd company logo
ARMvisor
                                   Peter Chang




            This side is licensed under CC-BY-NC-SA
             姓名標示─非商業性─相同方式分享
(http://creativecommons.org/licenses/by-nc-sa/3.0/tw/legalcode)
Who am I?
Who am I?

• Peter Chang
Who am I?

• Peter Chang
• One of the current developers of ARMvisor
Who am I?

• Peter Chang
• One of the current developers of ARMvisor
• http://tw.linkedin.com/in/peterchangtw
What is ARMvisor?
ARMvisor, more details
ARM
ARM
ARM
What is KVM?
What is KVM?

• A.k.a. Kernel-based Virtual Machine
What is KVM?

• A.k.a. Kernel-based Virtual Machine
• Type-II Virtual Machine Monitor
What is KVM?

• A.k.a. Kernel-based Virtual Machine
• Type-II Virtual Machine Monitor
• A module of Linux kernel
What is KVM?
What is KVM?


• Officially support x86/x64, PowerPC, S390
What is KVM?


• Officially support x86/x64, PowerPC, S390
 • No official support for ARM architecture
What is ARMvisor?
What is ARMvisor?

• ARM架構上的KVM
What is ARMvisor?

• ARM架構上的KVM
• Para-virtualization
What is ARMvisor?

• ARM架構上的KVM
• Para-virtualization
• Trap & Emulation
What is ARMvisor?

• ARM架構上的KVM
• Para-virtualization
• Trap & Emulation
• Dynamic Memory Allocation
What is ARMvisor?

• ARM架構上的KVM
• Para-virtualization
• Trap & Emulation
• Dynamic Memory Allocation
• virtio & IRQchip-in-kernel
Guest OS: Linux 2.6.35




            QEMU 0.14                   Driver


                      Device
Driver                             ARMvisor
           Host OS: Linux 2.6.38



         Hardware: ARM Cortex-A8
2012



       2011



2010



       2009
2012



       2011



2010



       2009
2012



                  2011



           2010

Starting Point

                  2009
2012



                  2011



           2010

Starting Point

                  2009
2012



                  2011

                    ARMvisor Prototype

           2010

Starting Point

                  2009
2012



                  2011

                    ARMvisor Prototype

           2010

Starting Point

                  2009
2012
CPU Opt & Mem Opt

                      2011

                        ARMvisor Prototype

               2010

    Starting Point

                      2009
2012
CPU Opt & Mem Opt

                      2011

                        ARMvisor Prototype

               2010

    Starting Point

                      2009
I/O Opt

               2012
CPU Opt & Mem Opt

                      2011

                        ARMvisor Prototype

               2010

    Starting Point

                      2009
Supported Hardware


            ARM Realview-eb

                ARM11

              ARMv6 ISA
Supported Hardware


             TI BeagleBoard

              Cortex-A8

              ARMv7 ISA
Supported Software

• Patched Host OS:
 • Linaro Linux 2.6.38
• Host Root Filesystem
 • Ubuntu/Debian RFS (CLI or GUI)
• QEMU 0.14
Supported Software

• Patched Guest OS:
 • Linux 2.6.35 (running on ARMv6 ISA)
• Guest Root Filesystem:
 • Ubuntu/Debian RFS (CLI or GUI)
System model of ARMvisor
CPU virtualization
CPU virtualization

• ARM is non-virtualizable CPU
 • Patch guest OS
• “Trap and emulation”
ARMv6 ISA
1.Branch instructions
2.Data-processing instructions
3.Multiply instructions
4.Parallel addition and subtraction instructions
5.Extend instructions
6.Miscellaneous arithmetic instructions
7.Other miscellaneous instructions
8.Status register access instructions
9.Load and store instructions
10.Load and Store Multiple instructions
11.Semaphore instructions
12.Exception-generating instructions
13.Coprocessor instructions
ARMv6 ISA
1.Branch instructions
                                             Sensitive
2.Data-processing instructions            Instructions ?
3.Multiply instructions
4.Parallel addition and subtraction instructions
5.Extend instructions
6.Miscellaneous arithmetic instructions
7.Other miscellaneous instructions
8.Status register access instructions
9.Load and store instructions
10.Load and Store Multiple instructions
11.Semaphore instructions
12.Exception-generating instructions
13.Coprocessor instructions
ARMv6 ISA
1.Branch instructions
2.Data-processing instructions
3.Multiply instructions
4.Parallel addition and subtraction instructions
5.Extend instructions
6.Miscellaneous arithmetic instructions
7.Other miscellaneous instructions
8.Status register access instructions
9.Load and store instructions
10.Load and Store Multiple instructions
11.Semaphore instructions
12.Exception-generating instructions
13.Coprocessor instructions
Sensitive Instructions
  Data-processing instructions            S-BIT: MOVS, ...

Status register access instructions   MRS, MSR, CPS, SETEND

   Load and store instructions         T-BIT: LDRT, STRT, ...

     Load and Store Multiple
          instructions                LDM(2), LDM(3), STM(2)

Exception-generating instructions           SWI, BKPT

    Coprocessor instructions           MCR, MRC, MCRR, ...
Observation from
Guest Linux Code
• MOVS
• (MRS, MSR, CPS)
• (LDRBT, LDRT, STRBT, STRT)
• (LDM(2), LDM(3), STM(2))
• SWI
• (MCR, MRC, MCRR)

   15 sensitive instructions
 used in the guest linux code
“Trap & emulation”

                Guest%OS

 User%space%     trap
            %
Kernel%space
                 VMM
How to “trap”?
…
mov r0, r0
add sp, sp
movs pc, lr
…
How to “trap”?
…
mov r0, r0
add sp, sp
virt_svc_movs “movs pc, lr”
…
How to “trap”?
…
mov r0, r0
add sp, sp
virt_svc_movs “movs pc, lr”
…
How to “trap”?
                              .macro virt_svc_movs, inst
                              SWI 0x190
                              inst
…                             .endm
mov r0, r0
add sp, sp
virt_svc_movs “movs pc, lr”
…
How to “emulate”?
oxffff1000


0xffff001c
             Kernel Vector
oxffff0000
oxffff1000


0xffff001c
             Kernel Vector
oxffff0000
The KVM trap
               Interface
oxffff1000


0xffff001c
             Kernel Vector
oxffff0000
UND               ABORT                       SWI         IRQ/FIQ




                                  KVM	
  Trap	
  Entry



                                       KVM/Guest
 Host	
  Trap	
  Handler          	
  Context	
  Switch	
  
                                          Unit




                             KVM	
  Trap	
  Dispatcher



Instruction	
           MMU	
               Exception/Interrupt	
         QEMU	
  I/O
Emulation             Emulation                 Emulation                 Emulation
User space   Kernel space   Guest Mode




  QEMU          KVM          Guest OS
User space                 Kernel space   Guest Mode

    1. VM initialization




  QEMU                        KVM          Guest OS
User space                         Kernel space   Guest Mode

    1. VM initialization

                    2. Return to QEMU




  QEMU                                  KVM        Guest OS
User space                         Kernel space   Guest Mode

    1. VM initialization

                    2. Return to QEMU

    3. Run VM




  QEMU                                  KVM        Guest OS
User space                         Kernel space           Guest Mode

    1. VM initialization

                    2. Return to QEMU

    3. Run VM
                                         4. Enter Guest




  QEMU                                  KVM                Guest OS
User space                         Kernel space                    Guest Mode

    1. VM initialization

                    2. Return to QEMU

    3. Run VM
                                         4. Enter Guest


                                                          5. Exit Guest




  QEMU                                  KVM                         Guest OS
User space                         Kernel space                     Guest Mode

    1. VM initialization

                    2. Return to QEMU

    3. Run VM
                                          4. Enter Guest


                                                           5. Exit Guest
                      Lightweight trap




  QEMU                                   KVM                         Guest OS
User space                         Kernel space                     Guest Mode

    1. VM initialization

                    2. Return to QEMU

    3. Run VM
                                          4. Enter Guest


                                                           5. Exit Guest
                      Lightweight trap


                                          6. Enter Guest




  QEMU                                   KVM                         Guest OS
User space                         Kernel space                     Guest Mode

    1. VM initialization

                    2. Return to QEMU

    3. Run VM
                                          4. Enter Guest


                                                           5. Exit Guest
                      Lightweight trap


                                          6. Enter Guest


                                                             7. Exit Guest




  QEMU                                   KVM                         Guest OS
User space                         Kernel space                      Guest Mode

    1. VM initialization

                    2. Return to QEMU

    3. Run VM
                                           4. Enter Guest


                                                            5. Exit Guest
                      Lightweight trap


                                           6. Enter Guest


                                                              7. Exit Guest
                      8. Return to QEMU




  QEMU                                    KVM                         Guest OS
User space                         Kernel space                      Guest Mode

    1. VM initialization

                    2. Return to QEMU

    3. Run VM
                                           4. Enter Guest


                                                            5. Exit Guest
                      Lightweight trap


                                           6. Enter Guest

                     Heavyweight trap
                                                              7. Exit Guest
                      8. Return to QEMU




  QEMU                                    KVM                         Guest OS
User space                         Kernel space                      Guest Mode

    1. VM initialization

                    2. Return to QEMU

    3. Run VM
                                           4. Enter Guest


                                                            5. Exit Guest
                      Lightweight trap


                                           6. Enter Guest

                     Heavyweight trap
                                                              7. Exit Guest
                      8. Return to QEMU


    9. Run VM




  QEMU                                    KVM                         Guest OS
User space                         Kernel space                       Guest Mode

    1. VM initialization

                    2. Return to QEMU

    3. Run VM
                                           4. Enter Guest


                                                             5. Exit Guest
                      Lightweight trap


                                           6. Enter Guest

                     Heavyweight trap
                                                               7. Exit Guest
                      8. Return to QEMU


    9. Run VM

                                           10. Enter Guest


  QEMU                                    KVM                          Guest OS
VCPU	
        oxffff2000
Register	
  
               Sync
  File



                            The KVM trap
                              Interface
               oxffff1000

               0xffff001c
                            Kernel Vector
               oxffff0000
VCPU	
        oxffff2000
Register	
                  Shadow	
  Register	
  File
               Sync
  File



                             The KVM trap
                               Interface
               oxffff1000

               0xffff001c
                             Kernel Vector
               oxffff0000
mcr	
  cpsr,	
  r1



 VCPU	
        oxffff2000
Register	
                  Shadow	
  Register	
  File
               Sync
  File



                             The KVM trap
                               Interface
               oxffff1000

               0xffff001c
                             Kernel Vector
               oxffff0000
mcr	
  cpsr,	
  r1



 VCPU	
        oxffff2000
Register	
                  Shadow	
  Register	
  File
               Sync
  File



                             The KVM trap
                               Interface
               oxffff1000

               0xffff001c
                             Kernel Vector
               oxffff0000
mcr	
  cpsr,	
  r1



 VCPU	
        oxffff2000
                                                         Read/Write
Register	
                  Shadow	
  Register	
  File
               Sync                                      Instructions
  File



                             The KVM trap
                               Interface
               oxffff1000

               0xffff001c
                             Kernel Vector
               oxffff0000
mcr	
  cpsr,	
  r1



 VCPU	
        oxffff2000
                                                         Read/Write
Register	
                  Shadow	
  Register	
  File
               Sync                                      Instructions
  File



                             The KVM trap
                               Interface
               oxffff1000

               0xffff001c
                             Kernel Vector
               oxffff0000
Memory virtualization
PTB   Virtual	
  Address




      Physical	
  Address
GVA



GPA


HVA


HPA
Guest	
  PTB
               GVA



               GPA


               HVA


               HPA
Guest	
  PTB
               GVA



               GPA


               HVA


               HPA
Guest	
  PTB
               GVA



               GPA


                     Host	
  PTB
               HVA


               HPA
Guest	
  PTB
                        GVA



                        GPA


                              Host	
  PTB
                        HVA
   New	
  SPTE	
  !!!
                        HPA
ARMvisor, more details
PABT/DABT	
  trap
PABT/DABT	
  trap



     guest	
  
   page	
  table	
  
     walker
PABT/DABT	
  trap



       guest	
  
     page	
  table	
  
       walker




True	
  Translation	
  fault
PABT/DABT	
  trap



       guest	
             Guest	
  
     page	
  table	
     permission	
  
       walker             checker




True	
  Translation	
  fault
PABT/DABT	
  trap



       guest	
              Guest	
  
     page	
  table	
      permission	
  
       walker              checker




                  True	
  permission	
  fault

True	
  Translation	
  fault
PABT/DABT	
  trap



       guest	
              Guest	
  
                                           MMIO	
  access	
  
     page	
  table	
      permission	
  
                                            checker
       walker              checker




                  True	
  permission	
  fault

True	
  Translation	
  fault
PABT/DABT	
  trap



       guest	
              Guest	
  
                                               MMIO	
  access	
  
     page	
  table	
      permission	
  
                                                checker
       walker              checker




                  True	
  permission	
  fault

True	
  Translation	
  fault               MMIO	
  emulation
PABT/DABT	
  trap



       guest	
              Guest	
                                 Shadow	
  page	
  
                                               MMIO	
  access	
  
     page	
  table	
      permission	
                                 table	
  
                                                checker
       walker              checker                                    mapping




                  True	
  permission	
  fault

True	
  Translation	
  fault               MMIO	
  emulation
Hidden	
  protection	
  fault
 PABT/DABT	
  trap



       guest	
              Guest	
                                 Shadow	
  page	
  
                                               MMIO	
  access	
  
     page	
  table	
      permission	
                                 table	
  
                                                checker
       walker              checker                                    mapping




                  True	
  permission	
  fault

True	
  Translation	
  fault               MMIO	
  emulation
Hidden	
  protection	
  fault
 PABT/DABT	
  trap



       guest	
              Guest	
                                 Shadow	
  page	
  
                                               MMIO	
  access	
  
     page	
  table	
      permission	
                                 table	
  
                                                checker
       walker              checker                                    mapping




                  True	
  permission	
  fault            Hidden	
  translation	
  fault

True	
  Translation	
  fault               MMIO	
  emulation
Hidden	
  protection	
  fault
 PABT/DABT	
  trap



       guest	
              Guest	
                                 Shadow	
  page	
  
                                               MMIO	
  access	
                          Shadow	
  page	
  
     page	
  table	
      permission	
                                 table	
  
                                                checker                                  table	
  update
       walker              checker                                    mapping




                  True	
  permission	
  fault            Hidden	
  translation	
  fault

True	
  Translation	
  fault               MMIO	
  emulation
I/O virtualization
I/O virtualization

• Emulation by QEMU
• virtio
• IRQ chip in kernel
Emulate by QEMU
Guest OS: Linux 2.6.35




            QEMU 0.14                   Driver


                   Device
                                   ARMvisor
Driver     Host OS: Linux 2.6.38



         Hardware: ARM Cortex-A8
Guest OS: Linux 2.6.35


                                              1


            QEMU 0.14                   Driver


                   Device
                                   ARMvisor
Driver     Host OS: Linux 2.6.38



         Hardware: ARM Cortex-A8
Guest OS: Linux 2.6.35


                                              1


            QEMU 0.14                   Driver


                   Device
                                   2
                                   ARMvisor
Driver     Host OS: Linux 2.6.38



         Hardware: ARM Cortex-A8
Guest OS: Linux 2.6.35


                                                1


             QEMU 0.14                    Driver


                     Device
         3                           2
                                     ARMvisor
Driver       Host OS: Linux 2.6.38



         Hardware: ARM Cortex-A8
Guest OS: Linux 2.6.35


                                                1


             QEMU 0.14                    Driver


                     Device
         3                           2
                                     ARMvisor
Driver       Host OS: Linux 2.6.38

4



         Hardware: ARM Cortex-A8
Guest OS: Linux 2.6.35




            QEMU 0.14                   Driver


                   Device
                                   ARMvisor
Driver     Host OS: Linux 2.6.38



         Hardware: ARM Cortex-A8
Guest OS: Linux 2.6.35




                QEMU 0.14                   Driver


                       Device
                                       ARMvisor
    Driver     Host OS: Linux 2.6.38

5


             Hardware: ARM Cortex-A8
Guest OS: Linux 2.6.35




                 QEMU 0.14                    Driver


                         Device
             6
                                         ARMvisor
    Driver       Host OS: Linux 2.6.38

5


             Hardware: ARM Cortex-A8
Guest OS: Linux 2.6.35




                 QEMU 0.14                    Driver


                         Device
                                         7
             6
                                         ARMvisor
    Driver       Host OS: Linux 2.6.38

5


             Hardware: ARM Cortex-A8
Guest OS: Linux 2.6.35


                                                    8


                 QEMU 0.14                    Driver


                         Device
                                         7
             6
                                         ARMvisor
    Driver       Host OS: Linux 2.6.38

5


             Hardware: ARM Cortex-A8
virtio
virtio
      Vir,o	
  Driver
                               Guest
Vir,o	
  AMBA	
  Controller

          Vring               Transport
Vir,o	
  AMBA	
  Controller
                               QEMU
      Vir,o	
  Device
irq_chip in kernel
Opera,ng	
  System                          Interrupt	
  Controller

                     Deliver	
  Interrupt

                     Get	
  IRQ	
  number
     1
                     Ack	
  IRQ	
  number

                         Mask	
  IRQ
     2



                        End	
  of	
  IRQ
     3



                       Unmask	
  IRQ
     4
irq_chip in kernel
                             Guest

                                       Deliver7

          GIC               QEMU       IRQ7

                                                  Control7
                                                  GIC7

Device   Device    Device
                              IOCTL7


                  ARMvisor
irq_chip in kernel
                            Guest
                                  Deliver$
                                  IRQ$
                           QEMU

Device   Device   Device                     Control$
                                             GIC$




    GIC$in$Kernel                            KVM
Future Works
Future Works
Future Works

• Support for ARM’s Virtualization extension
Future Works

• Support for ARM’s Virtualization extension
 • Cortex-A15 and beyond
Future Works

• Support for ARM’s Virtualization extension
 • Cortex-A15 and beyond
• SMP for host and guest
Future Works

• Support for ARM’s Virtualization extension
 • Cortex-A15 and beyond
• SMP for host and guest
• AArch64 Support
Future Works

• Support for ARM’s Virtualization extension
 • Cortex-A15 and beyond
• SMP for host and guest
• AArch64 Support
 • ARMv8
By the way, ...
OpenSource
OpenSource

• We HAVE opened source in late August,
  2012.
OpenSource

• We HAVE opened source in late August,
  2012.
• GNU GPLv2
OpenSource

• We HAVE opened source in late August,
  2012.
• GNU GPLv2
• Source code of Host and Guest OS
OpenSource

• We HAVE opened source in late August,
  2012.
• GNU GPLv2
• Source code of Host and Guest OS
• https://github.com/SSLab-NTHU
Q &A

More Related Content

PPTX
ARMvisor @ Linux Symposium 2012
PDF
ARMvisor @ COSCUP2012
PDF
Implements BIOS emulation support for BHyVe
PDF
Implements BIOS emulation support for BHyVe: A BSD Hypervisor
PDF
Hypervisor Framework
PPTX
Link Virtualization based on Xen
PDF
I/O仮想化最前線〜ネットワークI/Oを中心に〜
PDF
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)
ARMvisor @ Linux Symposium 2012
ARMvisor @ COSCUP2012
Implements BIOS emulation support for BHyVe
Implements BIOS emulation support for BHyVe: A BSD Hypervisor
Hypervisor Framework
Link Virtualization based on Xen
I/O仮想化最前線〜ネットワークI/Oを中心に〜
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)

What's hot (20)

PPT
PDF
XS Boston 2008 Cache
PDF
ACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introduction
PDF
Malicious Hypervisor - Virtualization in Shellcodes by Adhokshaj Mishra
PDF
Project ACRN: SR-IOV implementation
PDF
ACRN vMeet-Up EU 2021 - debug ACRN hypervisor
PDF
openqrm4.9 Quick Start Guide
PDF
LCA13: Xen on ARM
PDF
Project ACRN CPU sharing BVT scheduler in ACRN hypervisor
PDF
Project ACRN hypervisor introduction
PDF
HKG15-400: Next steps in KVM enablement on ARM
PDF
Project ACRN expose and pass through platform hidden PCIe devices to SOS
PDF
Running Dual Android Xen Instances on Nexus 10
PDF
Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...
PDF
Project ACRN configuration scenarios and config tool
PDF
Project ACRN Device Model architecture introduction
PDF
Embedded Systems Conference 2014 Presentation
PPT
Hardware accelerated Virtualization in the ARM Cortex™ Processors
PDF
ACRN vMeet-Up EU 2021 - hypervisor new platform enabling
PDF
Esx.sc.quickref
XS Boston 2008 Cache
ACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introduction
Malicious Hypervisor - Virtualization in Shellcodes by Adhokshaj Mishra
Project ACRN: SR-IOV implementation
ACRN vMeet-Up EU 2021 - debug ACRN hypervisor
openqrm4.9 Quick Start Guide
LCA13: Xen on ARM
Project ACRN CPU sharing BVT scheduler in ACRN hypervisor
Project ACRN hypervisor introduction
HKG15-400: Next steps in KVM enablement on ARM
Project ACRN expose and pass through platform hidden PCIe devices to SOS
Running Dual Android Xen Instances on Nexus 10
Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...
Project ACRN configuration scenarios and config tool
Project ACRN Device Model architecture introduction
Embedded Systems Conference 2014 Presentation
Hardware accelerated Virtualization in the ARM Cortex™ Processors
ACRN vMeet-Up EU 2021 - hypervisor new platform enabling
Esx.sc.quickref
Ad

Similar to ARMvisor, more details (20)

PDF
Virtualization Primer for Java Developers
PDF
Qemu Introduction
PDF
Mobile Virtualization using the Xen Technologies
PDF
Porting Xen Paravirtualization to MIPS Architecture
PDF
The kvm virtualization way
ODP
UDS 2012 Xen
ODP
Kvm and libvirt
PDF
Linaro Connect Asia 13 : Citrix - Xen on ARM plenary session
KEY
Cis222 2
PDF
Linux Foundation Collaboration Summit 13 :10 years of Xen and Beyond
KEY
AMD SVMってなあに
PPTX
2011 10-19
PDF
Toward a practical “HPC Cloud”: Performance tuning of a virtualized HPC cluster
PDF
virtualization tutorial at ACM bangalore Compute 2009
PPTX
Xen Project Update LinuxCon Brazil
PDF
XS Boston 2008 Self IO Emulation
PPTX
Nested Virtualization Update from Intel
PPTX
Linuxcon EU : Virtualization in the Cloud featuring Xen and XCP
PDF
S4 xen hypervisor_20080622
Virtualization Primer for Java Developers
Qemu Introduction
Mobile Virtualization using the Xen Technologies
Porting Xen Paravirtualization to MIPS Architecture
The kvm virtualization way
UDS 2012 Xen
Kvm and libvirt
Linaro Connect Asia 13 : Citrix - Xen on ARM plenary session
Cis222 2
Linux Foundation Collaboration Summit 13 :10 years of Xen and Beyond
AMD SVMってなあに
2011 10-19
Toward a practical “HPC Cloud”: Performance tuning of a virtualized HPC cluster
virtualization tutorial at ACM bangalore Compute 2009
Xen Project Update LinuxCon Brazil
XS Boston 2008 Self IO Emulation
Nested Virtualization Update from Intel
Linuxcon EU : Virtualization in the Cloud featuring Xen and XCP
S4 xen hypervisor_20080622
Ad

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
A Presentation on Artificial Intelligence
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Big Data Technologies - Introduction.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Approach and Philosophy of On baking technology
Encapsulation_ Review paper, used for researhc scholars
A Presentation on Artificial Intelligence
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
MYSQL Presentation for SQL database connectivity
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Understanding_Digital_Forensics_Presentation.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Dropbox Q2 2025 Financial Results & Investor Presentation
Big Data Technologies - Introduction.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
NewMind AI Weekly Chronicles - August'25 Week I
Chapter 3 Spatial Domain Image Processing.pdf
Review of recent advances in non-invasive hemoglobin estimation
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Digital-Transformation-Roadmap-for-Companies.pptx
Approach and Philosophy of On baking technology

ARMvisor, more details

  • 1. ARMvisor Peter Chang This side is licensed under CC-BY-NC-SA 姓名標示─非商業性─相同方式分享 (http://creativecommons.org/licenses/by-nc-sa/3.0/tw/legalcode)
  • 3. Who am I? • Peter Chang
  • 4. Who am I? • Peter Chang • One of the current developers of ARMvisor
  • 5. Who am I? • Peter Chang • One of the current developers of ARMvisor • http://tw.linkedin.com/in/peterchangtw
  • 8. ARM
  • 9. ARM
  • 10. ARM
  • 12. What is KVM? • A.k.a. Kernel-based Virtual Machine
  • 13. What is KVM? • A.k.a. Kernel-based Virtual Machine • Type-II Virtual Machine Monitor
  • 14. What is KVM? • A.k.a. Kernel-based Virtual Machine • Type-II Virtual Machine Monitor • A module of Linux kernel
  • 16. What is KVM? • Officially support x86/x64, PowerPC, S390
  • 17. What is KVM? • Officially support x86/x64, PowerPC, S390 • No official support for ARM architecture
  • 19. What is ARMvisor? • ARM架構上的KVM
  • 20. What is ARMvisor? • ARM架構上的KVM • Para-virtualization
  • 21. What is ARMvisor? • ARM架構上的KVM • Para-virtualization • Trap & Emulation
  • 22. What is ARMvisor? • ARM架構上的KVM • Para-virtualization • Trap & Emulation • Dynamic Memory Allocation
  • 23. What is ARMvisor? • ARM架構上的KVM • Para-virtualization • Trap & Emulation • Dynamic Memory Allocation • virtio & IRQchip-in-kernel
  • 24. Guest OS: Linux 2.6.35 QEMU 0.14 Driver Device Driver ARMvisor Host OS: Linux 2.6.38 Hardware: ARM Cortex-A8
  • 25. 2012 2011 2010 2009
  • 26. 2012 2011 2010 2009
  • 27. 2012 2011 2010 Starting Point 2009
  • 28. 2012 2011 2010 Starting Point 2009
  • 29. 2012 2011 ARMvisor Prototype 2010 Starting Point 2009
  • 30. 2012 2011 ARMvisor Prototype 2010 Starting Point 2009
  • 31. 2012 CPU Opt & Mem Opt 2011 ARMvisor Prototype 2010 Starting Point 2009
  • 32. 2012 CPU Opt & Mem Opt 2011 ARMvisor Prototype 2010 Starting Point 2009
  • 33. I/O Opt 2012 CPU Opt & Mem Opt 2011 ARMvisor Prototype 2010 Starting Point 2009
  • 34. Supported Hardware ARM Realview-eb ARM11 ARMv6 ISA
  • 35. Supported Hardware TI BeagleBoard Cortex-A8 ARMv7 ISA
  • 36. Supported Software • Patched Host OS: • Linaro Linux 2.6.38 • Host Root Filesystem • Ubuntu/Debian RFS (CLI or GUI) • QEMU 0.14
  • 37. Supported Software • Patched Guest OS: • Linux 2.6.35 (running on ARMv6 ISA) • Guest Root Filesystem: • Ubuntu/Debian RFS (CLI or GUI)
  • 38. System model of ARMvisor
  • 40. CPU virtualization • ARM is non-virtualizable CPU • Patch guest OS • “Trap and emulation”
  • 41. ARMv6 ISA 1.Branch instructions 2.Data-processing instructions 3.Multiply instructions 4.Parallel addition and subtraction instructions 5.Extend instructions 6.Miscellaneous arithmetic instructions 7.Other miscellaneous instructions 8.Status register access instructions 9.Load and store instructions 10.Load and Store Multiple instructions 11.Semaphore instructions 12.Exception-generating instructions 13.Coprocessor instructions
  • 42. ARMv6 ISA 1.Branch instructions Sensitive 2.Data-processing instructions Instructions ? 3.Multiply instructions 4.Parallel addition and subtraction instructions 5.Extend instructions 6.Miscellaneous arithmetic instructions 7.Other miscellaneous instructions 8.Status register access instructions 9.Load and store instructions 10.Load and Store Multiple instructions 11.Semaphore instructions 12.Exception-generating instructions 13.Coprocessor instructions
  • 43. ARMv6 ISA 1.Branch instructions 2.Data-processing instructions 3.Multiply instructions 4.Parallel addition and subtraction instructions 5.Extend instructions 6.Miscellaneous arithmetic instructions 7.Other miscellaneous instructions 8.Status register access instructions 9.Load and store instructions 10.Load and Store Multiple instructions 11.Semaphore instructions 12.Exception-generating instructions 13.Coprocessor instructions
  • 44. Sensitive Instructions Data-processing instructions S-BIT: MOVS, ... Status register access instructions MRS, MSR, CPS, SETEND Load and store instructions T-BIT: LDRT, STRT, ... Load and Store Multiple instructions LDM(2), LDM(3), STM(2) Exception-generating instructions SWI, BKPT Coprocessor instructions MCR, MRC, MCRR, ...
  • 45. Observation from Guest Linux Code • MOVS • (MRS, MSR, CPS) • (LDRBT, LDRT, STRBT, STRT) • (LDM(2), LDM(3), STM(2)) • SWI • (MCR, MRC, MCRR) 15 sensitive instructions used in the guest linux code
  • 46. “Trap & emulation” Guest%OS User%space% trap % Kernel%space VMM
  • 47. How to “trap”? … mov r0, r0 add sp, sp movs pc, lr …
  • 48. How to “trap”? … mov r0, r0 add sp, sp virt_svc_movs “movs pc, lr” …
  • 49. How to “trap”? … mov r0, r0 add sp, sp virt_svc_movs “movs pc, lr” …
  • 50. How to “trap”? .macro virt_svc_movs, inst SWI 0x190 inst … .endm mov r0, r0 add sp, sp virt_svc_movs “movs pc, lr” …
  • 52. oxffff1000 0xffff001c Kernel Vector oxffff0000
  • 53. oxffff1000 0xffff001c Kernel Vector oxffff0000
  • 54. The KVM trap Interface oxffff1000 0xffff001c Kernel Vector oxffff0000
  • 55. UND ABORT SWI IRQ/FIQ KVM  Trap  Entry KVM/Guest Host  Trap  Handler  Context  Switch   Unit KVM  Trap  Dispatcher Instruction   MMU   Exception/Interrupt   QEMU  I/O Emulation Emulation Emulation Emulation
  • 56. User space Kernel space Guest Mode QEMU KVM Guest OS
  • 57. User space Kernel space Guest Mode 1. VM initialization QEMU KVM Guest OS
  • 58. User space Kernel space Guest Mode 1. VM initialization 2. Return to QEMU QEMU KVM Guest OS
  • 59. User space Kernel space Guest Mode 1. VM initialization 2. Return to QEMU 3. Run VM QEMU KVM Guest OS
  • 60. User space Kernel space Guest Mode 1. VM initialization 2. Return to QEMU 3. Run VM 4. Enter Guest QEMU KVM Guest OS
  • 61. User space Kernel space Guest Mode 1. VM initialization 2. Return to QEMU 3. Run VM 4. Enter Guest 5. Exit Guest QEMU KVM Guest OS
  • 62. User space Kernel space Guest Mode 1. VM initialization 2. Return to QEMU 3. Run VM 4. Enter Guest 5. Exit Guest Lightweight trap QEMU KVM Guest OS
  • 63. User space Kernel space Guest Mode 1. VM initialization 2. Return to QEMU 3. Run VM 4. Enter Guest 5. Exit Guest Lightweight trap 6. Enter Guest QEMU KVM Guest OS
  • 64. User space Kernel space Guest Mode 1. VM initialization 2. Return to QEMU 3. Run VM 4. Enter Guest 5. Exit Guest Lightweight trap 6. Enter Guest 7. Exit Guest QEMU KVM Guest OS
  • 65. User space Kernel space Guest Mode 1. VM initialization 2. Return to QEMU 3. Run VM 4. Enter Guest 5. Exit Guest Lightweight trap 6. Enter Guest 7. Exit Guest 8. Return to QEMU QEMU KVM Guest OS
  • 66. User space Kernel space Guest Mode 1. VM initialization 2. Return to QEMU 3. Run VM 4. Enter Guest 5. Exit Guest Lightweight trap 6. Enter Guest Heavyweight trap 7. Exit Guest 8. Return to QEMU QEMU KVM Guest OS
  • 67. User space Kernel space Guest Mode 1. VM initialization 2. Return to QEMU 3. Run VM 4. Enter Guest 5. Exit Guest Lightweight trap 6. Enter Guest Heavyweight trap 7. Exit Guest 8. Return to QEMU 9. Run VM QEMU KVM Guest OS
  • 68. User space Kernel space Guest Mode 1. VM initialization 2. Return to QEMU 3. Run VM 4. Enter Guest 5. Exit Guest Lightweight trap 6. Enter Guest Heavyweight trap 7. Exit Guest 8. Return to QEMU 9. Run VM 10. Enter Guest QEMU KVM Guest OS
  • 69. VCPU   oxffff2000 Register   Sync File The KVM trap Interface oxffff1000 0xffff001c Kernel Vector oxffff0000
  • 70. VCPU   oxffff2000 Register   Shadow  Register  File Sync File The KVM trap Interface oxffff1000 0xffff001c Kernel Vector oxffff0000
  • 71. mcr  cpsr,  r1 VCPU   oxffff2000 Register   Shadow  Register  File Sync File The KVM trap Interface oxffff1000 0xffff001c Kernel Vector oxffff0000
  • 72. mcr  cpsr,  r1 VCPU   oxffff2000 Register   Shadow  Register  File Sync File The KVM trap Interface oxffff1000 0xffff001c Kernel Vector oxffff0000
  • 73. mcr  cpsr,  r1 VCPU   oxffff2000 Read/Write Register   Shadow  Register  File Sync Instructions File The KVM trap Interface oxffff1000 0xffff001c Kernel Vector oxffff0000
  • 74. mcr  cpsr,  r1 VCPU   oxffff2000 Read/Write Register   Shadow  Register  File Sync Instructions File The KVM trap Interface oxffff1000 0xffff001c Kernel Vector oxffff0000
  • 76. PTB Virtual  Address Physical  Address
  • 78. Guest  PTB GVA GPA HVA HPA
  • 79. Guest  PTB GVA GPA HVA HPA
  • 80. Guest  PTB GVA GPA Host  PTB HVA HPA
  • 81. Guest  PTB GVA GPA Host  PTB HVA New  SPTE  !!! HPA
  • 84. PABT/DABT  trap guest   page  table   walker
  • 85. PABT/DABT  trap guest   page  table   walker True  Translation  fault
  • 86. PABT/DABT  trap guest   Guest   page  table   permission   walker checker True  Translation  fault
  • 87. PABT/DABT  trap guest   Guest   page  table   permission   walker checker True  permission  fault True  Translation  fault
  • 88. PABT/DABT  trap guest   Guest   MMIO  access   page  table   permission   checker walker checker True  permission  fault True  Translation  fault
  • 89. PABT/DABT  trap guest   Guest   MMIO  access   page  table   permission   checker walker checker True  permission  fault True  Translation  fault MMIO  emulation
  • 90. PABT/DABT  trap guest   Guest   Shadow  page   MMIO  access   page  table   permission   table   checker walker checker mapping True  permission  fault True  Translation  fault MMIO  emulation
  • 91. Hidden  protection  fault PABT/DABT  trap guest   Guest   Shadow  page   MMIO  access   page  table   permission   table   checker walker checker mapping True  permission  fault True  Translation  fault MMIO  emulation
  • 92. Hidden  protection  fault PABT/DABT  trap guest   Guest   Shadow  page   MMIO  access   page  table   permission   table   checker walker checker mapping True  permission  fault Hidden  translation  fault True  Translation  fault MMIO  emulation
  • 93. Hidden  protection  fault PABT/DABT  trap guest   Guest   Shadow  page   MMIO  access   Shadow  page   page  table   permission   table   checker table  update walker checker mapping True  permission  fault Hidden  translation  fault True  Translation  fault MMIO  emulation
  • 95. I/O virtualization • Emulation by QEMU • virtio • IRQ chip in kernel
  • 97. Guest OS: Linux 2.6.35 QEMU 0.14 Driver Device ARMvisor Driver Host OS: Linux 2.6.38 Hardware: ARM Cortex-A8
  • 98. Guest OS: Linux 2.6.35 1 QEMU 0.14 Driver Device ARMvisor Driver Host OS: Linux 2.6.38 Hardware: ARM Cortex-A8
  • 99. Guest OS: Linux 2.6.35 1 QEMU 0.14 Driver Device 2 ARMvisor Driver Host OS: Linux 2.6.38 Hardware: ARM Cortex-A8
  • 100. Guest OS: Linux 2.6.35 1 QEMU 0.14 Driver Device 3 2 ARMvisor Driver Host OS: Linux 2.6.38 Hardware: ARM Cortex-A8
  • 101. Guest OS: Linux 2.6.35 1 QEMU 0.14 Driver Device 3 2 ARMvisor Driver Host OS: Linux 2.6.38 4 Hardware: ARM Cortex-A8
  • 102. Guest OS: Linux 2.6.35 QEMU 0.14 Driver Device ARMvisor Driver Host OS: Linux 2.6.38 Hardware: ARM Cortex-A8
  • 103. Guest OS: Linux 2.6.35 QEMU 0.14 Driver Device ARMvisor Driver Host OS: Linux 2.6.38 5 Hardware: ARM Cortex-A8
  • 104. Guest OS: Linux 2.6.35 QEMU 0.14 Driver Device 6 ARMvisor Driver Host OS: Linux 2.6.38 5 Hardware: ARM Cortex-A8
  • 105. Guest OS: Linux 2.6.35 QEMU 0.14 Driver Device 7 6 ARMvisor Driver Host OS: Linux 2.6.38 5 Hardware: ARM Cortex-A8
  • 106. Guest OS: Linux 2.6.35 8 QEMU 0.14 Driver Device 7 6 ARMvisor Driver Host OS: Linux 2.6.38 5 Hardware: ARM Cortex-A8
  • 107. virtio
  • 108. virtio Vir,o  Driver Guest Vir,o  AMBA  Controller Vring Transport Vir,o  AMBA  Controller QEMU Vir,o  Device
  • 110. Opera,ng  System Interrupt  Controller Deliver  Interrupt Get  IRQ  number 1 Ack  IRQ  number Mask  IRQ 2 End  of  IRQ 3 Unmask  IRQ 4
  • 111. irq_chip in kernel Guest Deliver7 GIC QEMU IRQ7 Control7 GIC7 Device Device Device IOCTL7 ARMvisor
  • 112. irq_chip in kernel Guest Deliver$ IRQ$ QEMU Device Device Device Control$ GIC$ GIC$in$Kernel KVM
  • 115. Future Works • Support for ARM’s Virtualization extension
  • 116. Future Works • Support for ARM’s Virtualization extension • Cortex-A15 and beyond
  • 117. Future Works • Support for ARM’s Virtualization extension • Cortex-A15 and beyond • SMP for host and guest
  • 118. Future Works • Support for ARM’s Virtualization extension • Cortex-A15 and beyond • SMP for host and guest • AArch64 Support
  • 119. Future Works • Support for ARM’s Virtualization extension • Cortex-A15 and beyond • SMP for host and guest • AArch64 Support • ARMv8
  • 120. By the way, ...
  • 122. OpenSource • We HAVE opened source in late August, 2012.
  • 123. OpenSource • We HAVE opened source in late August, 2012. • GNU GPLv2
  • 124. OpenSource • We HAVE opened source in late August, 2012. • GNU GPLv2 • Source code of Host and Guest OS
  • 125. OpenSource • We HAVE opened source in late August, 2012. • GNU GPLv2 • Source code of Host and Guest OS • https://github.com/SSLab-NTHU
  • 126. Q &A