Running Mantevo Benchmark on Baremetal
Download
Report
Transcript Running Mantevo Benchmark on Baremetal
Kernel-based Virtual Machine
(KVM)
Memory Management Unit
(MMU)
Virtualization
Mohammad H. Mofrad
February 11, 2016
[email protected]
1
Contents
• Kernel-based Virtual Machine
• Linux memory management unit
• memory management unit virtualization
2
KVM as a Virtual Machine Monitor (KVM)
Host Applications
Virtual Machine
qemu
Linux Kernel
Hardware
Architecture of the Kernel-based Virtual Machine (KVM), Jan Kiszka, Siemens AG
Kvm.ko
/dev/kvm
open("/dev/kvm")
ioctl(KVM_CREATE_VM)
ioctl(KVM_CREATE_VCPU)
ioctl(KVM_MEMORY_REGION)
for (;;) {
ioctl(KVM_RUN)
switch (exit_reason) {
case KVM_EXIT_IO: /* ... */
case KVM_EXIT_HLT: /* ... */
}
}
3
Linux Memory Management Unit (MMU)
• A Memory Management Unit (MMU) translates physical memory
addresses to virtual address used by the operating system.
• It requests a page fault interrupt
• MMU uses a Translation Lookaside Buffer (TLB) to improve virtual
address translation speed.
Host Virtual Address (HVA)
Host Physical Address (HPA)
Source: The Linux Kernel’s Memory Management Unit API , William Gatliff
MMU
TLB
----------------------|
|
|
HPA
Host Physical
Memory
------------Page #1
------------Page #2
------------…
4
Physical Machine
CPU
HVA
MMU in Virtualization
Physical Machine Virtual Machine
Host Physical Memory | | | | | |
|…
MMU Virtualization
GVA
CPU
Host Virtual Address (HVA)
Host Physical Address (HPA)
Guest Virtual Address (GVA)
Guest Physical Address (GPA)
MMU
TLB
----------------------|
|
|
GPA
Guest Physical
Memory
------------Page #1
------------Page #2
------------…
5
Memory virtualization problems
• 3 levels of indirection
• But MMU can translate only one
• But MMU virtualization translates GVA to HPA.
GVA
Virtualization in Linux KVM + QEMU
>>
GPA
>>
HVA
>>
HPA
6
Memory Virtualization
• Shadow paging
• Hardware assisted virtualization
• MMU paravitualization
7
VM
GVA >> GPA
Shadow page table
GVA
1|2|3|4|
GPA
1|2|3|4|5|6|
Guest process
page table
----------------------|
|
|…
|…
HVA
1|2|3|4|5|6|7|8|9|10|
|…
HPA
A|B|C|D|E|F|G|H|I|J|
|…
Page fault >> VM EXIT
KVM\Qemu
GPA >> HPA
Shadow Paging
Shadow page
table
----------------------|
|
8
Shadow Paging pros and cons
+ + Software solution
+ + No need to change guest OS
+ + No special hardware is required
- - Every guest page needs a shadow version
- - Shadow page table must be consistent with guest and host
Virtualization in Linux KVM + QEMU
9
Hardware Assisted Virtualization (NTP/EPT )
• Eliminate the need for shadow paging (software approach)
• Provide architectural support
• Nested Page Table (NPT) by AMD
• Extended Page Table (EPT) by Intel
Address Translation for Virtual Machines
10
NTP/EPT table
KVM/Qemu
GPA >> HPA
GVA
1|2|3|4|
GPA
1|2|3|4|5|6|
Guest process
page table
----------------------|
|
|…
|…
HVA
1|2|3|4|5|6|7|8|9|10|
|…
HPA
A|B|C|D|E|F|G|H|I|J|
|…
Page fault >> NTP/EPT violation
VM
GVA >> GPA
Hardware Assisted Virtualization (NTP/EPT )
N/ETP page table
----------------------|
|
11
NTP/EPT Pros and Cons
+ + OS independent
+ + No need to change guest OS
+ + NTP/EPT table is proportional to guest memory
- - Need hardware support
- - Considerable overhead for TLB misses
- - More memory access + longer latency
Virtualization in Linux KVM + QEMU
12
MMU Paravirtualization
• Paravirtualization involves modifying OS kernel to replace
nonvirtualize instructions with virtualization hypercalls.
• MMU paravirtualization is one of the original innovations of Xen
VMM.
• So, guest is aware of how to map GVA to HPA!!!
http://wiki.xenproject.org/wiki/X86_Paravirtualised_Memory_Management
13
1|2|3|4|
HPA
A|B|C|D|E|F|G|H|I|J|
|…
Guest process
page table
----------------------|
|
.
.
.
G2P
GVA
http://wiki.xenproject.org/wiki/X86_Paravirtualised_Memory_Management
|…
Page fault >> NTP/EPT violation
Xen direct paging
GVA >>HPA
MMU Paravirtualization
|
14
MMU Paravirtualization Pros and Cons
+ + Near native solution
+ + Low memory overhead while taking full advantage of hardware
- - Compatibility cost [modifying the guest kernel]
- - All updates/changes need to be validated by VMM
- - More memory access + longer latency
kvm: the Linux virtual machine monitor
15
Useful References
[1] Kivity, Avi, et al. "kvm: the Linux virtual machine
monitor." Proceedings of the Linux symposium. Vol. 1. 2007.
[2 ] Bae, Chang S., John R. Lange, and Peter A. Dinda. "Enhancing
virtualized application performance through dynamic adaptive paging
mode selection.“ Proceedings of the 8th ACM international conference
on Autonomic computing. ACM, 2011.
[3] Wang, Xiaolin, et al. "Selective hardware/software memory
virtualization.“ ACM SIGPLAN Notices 46.7, 217-226, 2011.
16