making nested virtualization real by using hardware virtualization features · 2017-12-14 · •...

19
Making Nested Virtualization Real by Using Hardware Virtualization Features 1 May 28, 2013 Jun Nakajima Intel Corporation

Upload: others

Post on 17-Jun-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Making Nested Virtualization Real by Using Hardware Virtualization Features · 2017-12-14 · • Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing,

Making Nested Virtualization Real by Using Hardware Virtualization Features

1

May 28, 2013

Jun Nakajima Intel Corporation

Page 2: Making Nested Virtualization Real by Using Hardware Virtualization Features · 2017-12-14 · • Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing,

Legal Disclaimer �  INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH INTEL® PRODUCTS. NO

LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT. EXCEPT AS PROVIDED IN INTEL’S TERMS AND CONDITIONS OF SALE FOR SUCH PRODUCTS, INTEL ASSUMES NO LIABILITY WHATSOEVER, AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR USE OF INTEL® PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. INTEL PRODUCTS ARE NOT INTENDED FOR USE IN MEDICAL, LIFE SAVING, OR LIFE SUSTAINING APPLICATIONS.

�  Intel may make changes to specifications and product descriptions at any time, without notice.

�  All products, dates, and figures specified are preliminary based on current expectations, and are subject to change without notice.

�  Intel, processors, chipsets, and desktop boards may contain design defects or errors known as errata, which may cause the product to deviate from published specifications. Current characterized errata are available on request.

�  Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

�  *Other names and brands may be claimed as the property of others.

�  Copyright © 2013 Intel Corporation.

Page 3: Making Nested Virtualization Real by Using Hardware Virtualization Features · 2017-12-14 · • Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing,

Agenda

• Why does “Nested Virtualization” matter for cloud? − What is it? − How does it enhance the cloud?

• How is Nested Virtualization implemented? − What are the challenges? − Which hardware virtualization features are helpful?

• Current status − Performance and functionality − Summary

3

Page 4: Making Nested Virtualization Real by Using Hardware Virtualization Features · 2017-12-14 · • Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing,

How Virtualization is Used in the Cloud?

• Compute Nodes: − Cloud software (e.g. OpenStack) uses API to manage VMs − VMMs (e.g. KVM, Xen, etc.) use H/W Virtualization features to run guests − H/W Virtualization features are not available for guests

4

VM1 VM0

Guest OS0

App App App ...

... Guest OS1

App ...

Virtual Machine Monitor (VMM)

Physical Host Hardware

App App VM1

... Guest OS1

App ...

VMM

Physical Host Hardware

App App VM0

Guest OS0

App App App ...

...

VMM

Physical Host Hardware

APIs

APIs for VM Management

H/W Virtualization features (e.g. Intel® VT)

No H/W Virtualization features advertised

Compute Node

Page 5: Making Nested Virtualization Real by Using Hardware Virtualization Features · 2017-12-14 · • Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing,

Lack of H/W Virtualization Features in Cloud Applications Means: • VMs: − No KVM on Linux, No Hyper-V functionality on Windows − No HVM (Hardware-based VM) on Xen – e.g. No Windows support − Need to use software emulation – Very slow

5

...

VMM

Physical Host Hardware

VM0

Guest OS

App App App ...

APIs

H/W Virtualization features (e.g. Intel® VT)

No H/W Virtualization features advertised

Guest VMM (e.g Xen)

VM0

Guest OS

App App App ... VM0

Guest OS

App App App ...

... VM

Linux No KVM

App App App ...

Page 6: Making Nested Virtualization Real by Using Hardware Virtualization Features · 2017-12-14 · • Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing,

What’s “Nested Virtualization”? • Software feature in (Root) VMM that allows

Guest VMM to use H/W virtualization features − “Virtual” H/W virtualization features (nested) − May use H/W virtualization features

• H/W virtualization features (e.g. Intel® VT) − VT-x (CPU virtualization) − VXM instructions, VMCS (Virtual Machine

Control Structure), EPT (Extended Page Table), etc.

− VT-d (Direct I/O) − VT-c (Connectivity, especially SR-IOV of NIC)

6

HW

Root VMM

VM

Guest VMM

VM VM

Page 7: Making Nested Virtualization Real by Using Hardware Virtualization Features · 2017-12-14 · • Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing,

Motivations (1) – Enhance Hosting Capabilities/Features of the Cloud • Data centers using H/W virtualization products − Cannot be hosted in clouds without nested virtualization

• Operating systems with built-in H/W virtualization support − Lose features (or fail back to software solutions) − XP mode for VDI − Hyper-V

• System Emulators with H/W virtualization −  Run very slow in cloud (or fall back to software emulation) − Android Emulator on Linux (KVM) and Windows (HAXM*)

7

*: Intel® Hardware Accelerated Execution Manager http://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager

Page 8: Making Nested Virtualization Real by Using Hardware Virtualization Features · 2017-12-14 · • Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing,

Motivations (2) – Cloud Virtualization •  Hosting clouds with fewer physical severs − More cores, dynamic resource utilization using Virtual Compute Nodes

•  Cloud Development − Increase productivity, lower cost

•  Large-scale testing of cloud − Improve security, quality

8

VMM

Physical Host Hardware

APIs

H/W Virtualization features advertised

Guest VMM

VM0

Guest OS

App App App ... VM0

Guest OS

App App App ...

...

Guest VMM

VM0

Guest OS

App App App ... VM0

Guest OS

App App App ...

...

Virtual Compute Node Virtual Compute Node

Page 9: Making Nested Virtualization Real by Using Hardware Virtualization Features · 2017-12-14 · • Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing,

Agenda

• Why does “Nested Virtualization” matter for cloud? − What is it? − How does it enhance the cloud?

• How is Nested Virtualization implemented? − What are the challenges? − Which hardware virtualization features are helpful?

• Current status − Performance and functionality − Summary

9

Page 10: Making Nested Virtualization Real by Using Hardware Virtualization Features · 2017-12-14 · • Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing,

Challenges of Nested Virtualization

• Extra Overheads – Potentially lower performance − Higher VM Exit rates (Next slides) − Software overhead of virtualizing “H/W virtualization features”

• Complexity of Root VMM Software − More surface areas for security attacks − Sometimes exposes existing bugs with (Guest) VMMs

− Requires more QA because of various combinations

10

Page 11: Making Nested Virtualization Real by Using Hardware Virtualization Features · 2017-12-14 · • Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing,

Example of Extra Overheads – VM Entry/Exit

11

L1 (Guest) VMM

L0

L1

L2 Guest L2

Real VM Entry/Exit Virtual VM Entry/Exit

VMCS EPT

VMX

VMCS EPT

VMX

VMCS EPT

VMX

H/W Functionality Additional Software Code & Data

Virtualize Shadowing

1.  L1 creates VT-x structures for L2 2.  L1 enters VM (Virtual VM Enter)

VMLAUNCH, VMRESUME 3.  Trapped by L0 (VM Exit) 4.  L0 sets up real VMCS 5.  L0 enters L2 VM (Real VM Enter)

VMLAUNCH, VMRESUME 6.  At some point L2 causes VM exit to

L0 (Real VM Exit) 7.  L0 handles VM Exit itself and

resumes L2 (Real VM Enter) or injects VM Exit to L1 (Virtual VM Exit)

8.  Repeat from 2.

*VMCS (Virtual Machine Control Structure)

−  Guest/Host states

*EPT (Extend Page Table)

−  Guest memory virtualization

L0 (Root) VMM

Page 12: Making Nested Virtualization Real by Using Hardware Virtualization Features · 2017-12-14 · • Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing,

L1 (Guest)

VMM

L2 (True) Guest

L0 (Root) VMM

Nested Virtualization

VM-n VM-1

Reducing Extra Overheads

VMM

VM-0

VM Exit VM Entry R W R R R R W

VMREADs / VMWRITEs

R R R R R W W

Build Foil

Opportunity #3: Eliminate VM exits on guest VMCS Accesses

Standard Virtualization

VMCS (Virtual Machine Control Structure) •  Holds guest and host CPU register state •  Increasingly optimized with each VT implementation •  The key to reducing VT latencies over time

VMCS

Opportunity #2: Reduce “virtual” VM exits entirely

(e.g., via EPT, APIC Virtualization)

Opportunity #1: Reduce transition latencies

*KVM/Xen : 8+ VMREADs, 3+ VMWRITEs per VM Exit (Approximately, depends on the Exit type and version)

Page 13: Making Nested Virtualization Real by Using Hardware Virtualization Features · 2017-12-14 · • Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing,

Improving Performance of Nested Virtualization (Recap)

• Opportunity #1: Reduce Transition Latencies − Reduce unique overheads of virtualization. Intel is fanatically committed. − Optimize software code

• Opportunity #2: Reduce “Virtual” VM Exits Entirely − EPT (Implemented as Virtual EPT) − APIC Virtualization − Eliminate or reduce VM exits with access to local APIC − Guest VMMs can access local APICs more frequently to virtualize timers, I/

O devices − VT-d, SR-IOV − Reduce overhead of I/O virtualization − Guest VMMs can access I/O devices more frequently

• Opportunity #3: Eliminate VM Exits on guest VMCS Accesses − VMCS Shadowing

13

Page 14: Making Nested Virtualization Real by Using Hardware Virtualization Features · 2017-12-14 · • Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing,

Virtual EPT

L1 (Guest)

VMM

L2 Guest

VMCS L1 EPT L2 GPA è L1 GPA

L0 EPT L1 GPA è HPA

Switch to Shadow EPT @ VM Entry to L2

VMCS

Sha

dow

ing

L2 GPA è HPA Shadow EPT

Sha

dow

ing

14

VMCS

•  GPA (Guest Physical Address) −  Physical address in guest’s

view

•  HPA (Host Physical Address) −  Real (machine) physical

address

•  EPT Shadowing −  Points to real H/W data structures −  Convert GPA to HPA

Page 15: Making Nested Virtualization Real by Using Hardware Virtualization Features · 2017-12-14 · • Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing,

L1 (Guest)

VMM

L2 (True) Guest

L0 (Root) VMM

New H/W Feature: VMCS Shadowing

R R R R R W W L1 (Guest)

VMM

L2 (True) Guest

L0 (Root) VMM

R R R R R W W

Shadow VMCS

Software-only VMCS Shadowing

•  VMREAD-Bitmap and VMWRITE-Bitmap − VM Exit if Bit n in VMREAD/VMWRITE bitmap is 1, where n is value of bits 14:0 of register

source/destination operand

•  Direct Guest VMM VMREAD/VMWRITE to a Shadow VMCS − Accesses to Shadow VMCS done by hardware − Eliminates majority of nesting-induced VM exits −  Improves performance of software stacks that support nesting

Page 16: Making Nested Virtualization Real by Using Hardware Virtualization Features · 2017-12-14 · • Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing,

Agenda

• Why does “Nested Virtualization” matter for cloud? − What is it? − How does it enhance the cloud?

• How is Nested Virtualization implemented? − What are the challenges? − Which hardware virtualization features are helpful?

• Current status − Performance and functionality − Summary

16

Page 17: Making Nested Virtualization Real by Using Hardware Virtualization Features · 2017-12-14 · • Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing,

Performance Trending

• With only virtual EPT and VMCS Shadowing, performance of L2 is around 80% of L1*

• APIC Virtualization could provide approx. 3% additional improvement in Kernel Build and SPECCPU cases (not shown in the chart)*

• Expect more gain from: − VT-d, SR-IOV

•  Looking at issues with SPECjbb

17

0  

10  

20  

30  

40  

50  

60  

70  

80  

90  

L2-­‐EPT-­‐shadowVMCS  

L2-­‐no-­‐EPT-­‐no-­‐shadowVMCS  

L2 (Linux) Performance relative to L1 (KVM on KVM) *Estimated Results Benchmark Disclaimer Results have been estimated based on internal Intel analysis and are provided for informational purposes only. Any difference in system hardware or software design or configuration may affect actual performance.

WordPress: L2 Guest OS: RHEL6.4 (with 4vCPUs and 4GB memory) Web Server: Apache (httpd-2.2.15-26.el6.x86_64.rpm) Database: MySQL (mysql-server-5.1.66-2.el6_3.x86_64.rpm) Web App: WordPress v3.5.1 JMeter (a client on another machine): JMeter v2.9

Page 18: Making Nested Virtualization Real by Using Hardware Virtualization Features · 2017-12-14 · • Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing,

Current Status

18

• Crucial features for Nested Virtualization in KVM and Xen − Virtual EPT – KVM (WIP, v3 submitted), Xen (upstream) − VMCS Shadowing – KVM (upstream), Xen (upstream) − APIC Virtualization – KVM (upstream), Xen (upstream) − VT-d, SR-IOV – KVM (in distributions), Xen (in distributions)

• Our Test Cases (KVM and Xen as L0) − L1 − KVM (L0 KVM and Xen) − Xen (on L0 Xen, issues on L0 KVM) − VMware Player 5.0 on Windows 7 (pass on L0 Xen, issues on L0 KVM) − VirutalBox 4.2 on Windows 7 (on L0 Xen) – Issues

− L2 − 32/64-bit Linux − 32/64-bit Windows

Page 19: Making Nested Virtualization Real by Using Hardware Virtualization Features · 2017-12-14 · • Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing,

Summary

• Nested Virtualization − Extends hosting capabilities/features of cloud − Provides a means to virtualize cloud − Becoming realistic solutions with new H/W features and software support

• Performance is getting closer to L1 − With only virtual EPT and VMCS Shadowing, performance of L2 is getting

around 80% of L1* − More gains are expected with other H/W virtualization features

•  Functionality − KVM on KVM, KVM/Xen on Xen − VMware on Xen, VMware on KVM (WIP)

19

*Estimated Results Benchmark Disclaimer Results have been estimated based on internal Intel analysis and are provided for informational purposes only. Any difference in system hardware or software design or configuration may affect actual performance.

Nested Virtualization Is Becoming Real