f8603ad266d1278420c45e96ee6fdd7b11337354
[slides-virt.git] / index.rst
1
2 .. System Virtualization and OS Virtual Machines slides file, created by
3    hieroglyph-quickstart on Mon Oct 28 09:39:30 2013.
4
5 =============================================
6 System Virtualization and OS Virtual Machines
7 =============================================
8
9 :Date: 2013-10-29
10 :Authors: Ivan Boule, Olivier Matz
11
12 Plan
13 ====
14
15 Contents
16 --------
17
18 .. contents::
19    :depth: 2
20    :backlinks: none
21
22 History
23 =======
24
25 History of Virtual Machines
26 ---------------------------
27
28 - VM introduced in the sixties on IBM/370 series
29
30 - Co-Designed VM: IBM AS/400
31
32   - High level ISA including I/Os
33   - Proprietary CISC → PowerPC
34
35 - Application VMs
36
37   - Sun Java, Microsoft Common Language Infrastructure
38
39 - OS VMs
40
41   - VMware (virtualized PC on x86)
42   - Virtual PC (PC emulation on Mac OS/PowerPC)
43   - Many others : Bochs, VirtualBox, Qemu, ...
44
45 Virtualization Usages
46 =====================
47
48 System Virtualization Principles
49 --------------------------------
50
51 - Run multiple OS's on the same machine
52
53 - By design, an OS assumes to have full control over all physical
54   resources of the machine
55
56 - Manage sharing/partitioning of machine resources between Guest OS's
57
58   - CPU
59   - Physical memory & MMU
60   - I/O devices
61
62 Goals of System Virtualization
63 ------------------------------
64
65 - Reduction of Total Cost of Ownership (TCO)
66
67   - Increase utilisation of server resources
68
69 - Reduction of Total Cost of Functioning
70
71   - Energy consumption
72   - Cooling
73   - Occupied Space
74
75 - Hardware Consolidation
76
77 - Reduction of Build Of Material (BOM) for high-volume low-end
78   products
79
80 - Isolation of OS for security purposes
81
82
83 Virtualization in high-throughput network equipments
84 ----------------------------------------------------
85
86 .. figure:: high-thput1.jpg
87
88 .. figure:: high-thput2.jpg
89
90 Virtualization in Multimedia devices
91 ------------------------------------
92
93 - Reduction of Build Of Material (BOM) for high-volume low-end
94   products
95
96   - No need for a general purpose processor
97
98     - 20 to 25 % BOM reduction
99
100   - Run Linux together with OS supporting Codecs on a single TI DSP
101
102   - Leverage Linux environment
103
104   - Reuse existing DSP software
105
106 XXX 2 images
107
108 Usages of Virtual Machines
109 --------------------------
110
111 - Server virtualization
112
113   - Web sites hosting
114
115 - OS partitionning
116
117   - Time sharing
118   - Security
119
120 - OS/kernel education & training
121
122   - OS fault recovery
123   - OS kernel development
124   - Test machine = development host
125
126 - Keep backward compatibility of legacy software
127
128 - Run applications not supported by host OS
129
130 Recovery Servers
131 ----------------
132
133 .. figure:: recovery.png
134
135
136 Multi-Core CPU Issues (1)
137 -------------------------
138
139 - CPU power gain
140
141   - No more achieved through Frequency/Speed increase
142   - But obtained with higher density & multi-core chips
143
144 - Many RTOS designed with mono-processor assumption
145
146   - Adding multi-processor support is complex & costly
147   - Scaling requires time, at best...
148
149 - Legacy RT applications also designed for mono-processor
150
151   - Adaptation to multi-pro even more difficult than RTOS
152
153 Multi-Core CPU Issues (2)
154 -------------------------
155
156 - OS virtualization allows to run simultaneously on a multi-cores CPU
157   multiple instances of mono-processor OS's
158
159 - Each OS instance is run in a mono-processor
160
161 - Virtual Machine assigned to a single CPU core
162
163 - No need to change legacy software
164
165 - Scalability managed at virtualization level
166
167 Virtualization Taxonomy
168 =======================
169
170 Machines Interfaces
171 -------------------
172
173 .. figure:: isa-abi.svg
174
175 - ISA = Instruction Set Architecture
176
177   - System level interface
178   - All CPU instructions, memory architecture, I/O
179
180 - ABI = Application Binary Interface
181
182   - Process level interface
183   - User-level non privileged ISA instructions + OS systems 14 calls
184
185 Virtualization Taxonomy
186 -----------------------
187
188 - Process level virtualization
189
190   - Emulation of Operating System ABI
191   - Emulation of OS ABI, cross-architecture
192   - Virtual Servers
193
194 - System level virtualization
195
196 - Standalone / Hosted Virtualization
197 - Machine Emulation / Machine Virtualization
198
199 Hosted versus Standalone Virtualization
200 ---------------------------------------
201
202 - Hosted Virtualization
203
204   - Hosted VM Monitor (VMM) runs on top of native OS
205   - VMware WKS, Microsoft VirtualPC, QEMU/KVM, UML
206
207 - Standalone Virtualization
208
209   - VMM directly runs on bare hardware
210   - VMware ESX, IBM/VM, Xen
211
212 - OS run in a VM is named a Guest OS
213
214 Hosted Virtualization
215 ---------------------
216
217 .. figure:: hosted.svg
218
219 Example: VMware Workstation
220 ----------------------------
221
222 .. figure:: vmware-wks.png
223
224 - Hosted VM
225 - Unmodified OSes
226 - Specific device drivers
227 - x86 only
228 - Guest OS executed in user mode
229
230 Standalone Virtualization
231 -------------------------
232
233 .. figure:: standalone.svg
234
235 Example: VMware ESX
236 -------------------
237
238 - Standalone VMM
239 - Supports unmodified OS binaries
240
241   - Configuration with appropriate device drivers
242
243 - x86 only
244 - No Intel-VT
245 - Guest OS
246 - runs in user mode
247
248 Process Level Virtualization
249 ============================
250
251 Process level ABI Emulation
252 ---------------------------
253
254 - Goal: execute binary applications of a given system **X** on the ABI of
255   another system **Y**
256
257 - Emulate system **X** ABI on top of system **Y** ABI
258
259   - Emulation done by application-level code
260
261 - System **Y** must provide services equivalent to those of system
262   **X** (file system, sockets, etc...)
263
264 Process Level (ABI) Emulators
265 -----------------------------
266
267 - Wine - Windows Emulator on Unix/Linux
268
269   - Windows API in userland
270   - Adobe Photoshop, Google Picasa, ...
271
272 - Cygwin
273
274   - Unix emulation on Windows
275   - POSIX library
276   - Bash shell + many Unix commands
277   - GNU development tool chain (gcc, gdb)
278   - X Window, GNOME, Apache, sshd, ...
279
280 Process Level Cross-architecture Emulators
281 ------------------------------------------
282
283 - Emulate the Operating System ABI
284
285   - Emulated OS and native OS are the same (ex: both are linux)
286   - Emulated arch is different than native architecture (ex: x86 and
287     powerpc)
288
289 - Example: qemu-user::
290
291       $ gcc hello.c
292       $ ./a.out
293       hello
294       
295       $ powerpc-linux-gnu-gcc -static hello.c
296       $ ./a.out
297       bash: ./a.out: cannot execute binary file
298       $ qemu-ppc ./a.out
299       hello
300
301 Virtual Servers (1)
302 -------------------
303
304 - Single OS kernel / Multiple resource instances
305
306 - Isolated kernel execution environments
307
308   - Root file system
309   - Network: Routing table, IP tables, interfaces...
310   - Process for signals
311
312 - Solaris 10 Containers
313 - LXC, Linux-VServer, openVZ
314 - FreeBSD Jail
315
316 Virtual Servers (2)
317 -------------------
318
319 .. figure:: virtual-servers.svg
320
321 Virtual Servers (3)
322 -------------------
323
324 - Pro's
325
326   - CPU independent
327   - Lightweight
328
329     - Low memory footprint
330     - Low CPU overhead
331
332   - Scalable
333
334 - Con's
335
336   - No OS heterogeneity (no GPOS/RTOS combination)
337   - Single OS binary instance (common point of failure)
338
339 Transparent Hardware Emulation
340 ==============================
341
342 Transparent Hardware Emulation (1)
343 ----------------------------------
344
345 - Run unmodified OS binaries
346
347 - Includes emulation of physical devices
348
349 - Cross ISA Emulation
350
351   - qemu-system
352
353 - Same ISA Emulation
354
355   - VirtualBox (Intel x86)
356
357 Transparent Hardware Emulation (2)
358 ----------------------------------
359
360 - Emulate machine X on top of machine Y
361
362 - Interpretation
363
364   - 1 instruction of X executed by N instructions of Y
365   - Huge slow down method
366
367 - Dynamic Binary Translation
368
369   - Convert blocs of X instructions in Y instructions
370
371 - Application-level emulator runs on a native OS
372 - One VM running a single Guest OS
373
374 QEMU Architecture
375 -----------------
376
377 .. figure:: qemu.svg
378
379 QEMU: Hosted Hardware Emulator
380 ------------------------------
381
382 - Cross ISA Emulation
383
384   - Emulate machine X on top of machine Y
385
386 - Interpretation + translation
387
388 - Intel x86, PowerPC, ARM, Sparc architectures
389
390 - Emulation of SMP architectures
391
392 - Emulates physical I/O devices
393
394   - Hard Disk drives, CD-ROM, network controllers, USB controllers, ...
395   - Synchronous emulation of device I/O operations
396
397 Transparent Hardware Virtualization
398 ===================================
399
400 Transparent Hardware Virtualization
401 -----------------------------------
402
403 - Guest and host architectures are the same
404
405 - Execute native/unmodified OS binary images
406
407 - Provide in each VM a complete simulation of hardware
408
409   - Full CPU instruction set
410   - Interrupts, exceptions
411   - Memory access and MMU
412   - I/O devices
413
414 - Share machine resources among multiple VMs
415
416 Full CPU Virtualization (1)
417 ---------------------------
418
419 - Present same functional CPU to all Guest OSes
420
421 - VMM manages a CPU context for each VM
422
423   - saved copy of CPU registers
424   - representation of software-emulated CPU context
425
426 - VMM shares physical CPUs among all VMs
427
428   - VMM includes a VM scheduler
429
430     - round-robin
431     - priority-based
432
433 Full CPU Virtualization (2)
434 ---------------------------
435
436 - Relationships between a VMM and VMs similar to relationships between
437   native OS and applications
438
439   - Guarantee mutual isolation between all VMs
440   - Protect VMM from all VMs
441
442 - Directly execute native binary images of Guest OS's in
443   non-privileged mode
444
445 - VMM emulates access to protected resources performed by Guest OSs
446
447 CPU Virtualization
448 ------------------
449
450 - Run each Guest OS in non-privileged mode
451
452 .. figure:: cpu-virt.svg
453
454 "Hardware-Sensitive" Instructions
455 ---------------------------------
456
457 - Interact with protected hardware resources
458
459   - Privileged Instructions (cannot be executed in user mode)
460   - Critical Instructions (can be, but should not be executed by Guest OS)
461
462 - Must be detected and faked by VMM
463
464 - Dynamic Binary Translation of kernel code
465
466   - Done once, saved in Translation Cache
467   - Example: Vmware
468
469 Privileged Instructions Virtualization
470 --------------------------------------
471
472 - Only allowed in supervisor mode
473
474   - Ex: **cli/sti** to mask/unmask interrupts on Intel x86
475
476 - When executed in non-privileged mode
477
478   - CPU automatically detects a privilege violation
479   - Triggers a “privilege-violation” exception
480
481 - Caught by VMM which fakes the expected effect of the privileged
482   instruction
483
484   - Ex: **cli/sti**
485
486     - VMM does not mask/unmask CPU interrupts
487     - records « interrupt mask status » in context of VM
488
489 Critical Instructions Virtualization (1)
490 ----------------------------------------
491
492 - Hardware-sensitive instructions
493
494 - Ex: Intel IA-32 pushf/popf::
495
496     pushf /* save EFLAG reg. to stack */
497     cli   /* mask interrupts => clear EFLAG.IF */
498     ...
499     popf /* restore EFLAG reg. => unmask interrupts */
500
501 - When executed in non-privileged mode
502
503   - The cli instruction triggers an exception caught by VMM => VMM
504     record interrupts masked for current VM
505
506   - But no exception for popf => VMM not aware of Guest OS action
507     (unmask interrupts)
508
509 Critical Instructions Virtualization (2)
510 ----------------------------------------
511
512 - Must be detected and emulated by VMM
513
514 - VMM dynamically analyses Guest OS binary code to find critical instructions
515
516 - VMM replaces critical instructions by a « trap » instruction to enter the VMM
517
518 - VMM emulates expected effect of critical instruction, if any.
519
520 Full Memory Virtualization
521 --------------------------
522
523 - CPU include a Memory Management Unit (MMU)
524
525   - Isolated memory addressing spaces
526   - Independant of underlying physical memory layout
527   - Run mutually protected applications in parallel
528
529 - Virtual Memory managed by OS kernel
530
531   - Provides a virtual address space to each process
532
533     - 4 GB on most 32-bit architectures (Intel x86, PowerPC)
534
535   - Manages virtual page → physical case mappings
536   - Manages « swap » space to extend physical memory
537
538 MMU & Virtual Address Space
539 ---------------------------
540
541 .. figure:: mmu1.svg
542
543 Intel x86 MMU
544 -------------
545
546 .. figure:: mmu2.svg
547
548 Memory Virtualization (1)
549 -------------------------
550
551 - Machine Physical Memory
552
553   - Physical memory available on the machine
554
555 - Guest OS Physical Memory
556
557   - Part of machine memory assigned to a VM by VMM
558
559   - ∑ Guest Physical Memory can be > Machine Memory
560
561     - VMM uses « swap » space
562
563 - Guest OS Virtual Memory
564
565   - Guest OS manages virtual address spaces of its processes
566
567 Memory Virtualization (2)
568 -------------------------
569
570 - Guest OS manages Guest Physical Pages
571
572   - Manages MMU with its own page entries
573   - Translates Virtual Addresses into Guest Physical Addresses (GPA)
574
575 - VMM transparently manages Machine Physical Pages
576
577   - Guest Physical Address ≠ Machine Physical Address
578   - VMM dynamically translates Guest Physical Pages into Machine
579     Physical Pages
580
581 Memory Virtualization (3)
582 -------------------------
583
584 .. figure:: mem-virt.svg
585
586 Memory Virtualization (4)
587 -------------------------
588
589 - VMM maintains Shadow Page Tables
590
591   - Copies of Guest OS translation tables
592
593 - VMM catches updates operations of translation tables performed by a
594   Guest OS
595
596   - RW-protect all guest OS page tables
597   - Emulates operation in shadow page table
598   - Updates effective MMU page table entry, if needed
599
600 Memory Virtualization (5)
601 -------------------------
602
603 - PTE entries can be tagged with a context ID
604
605   - Avoids to flush TLB when switching current address space upon
606     scheduling of a new process
607
608   - usually PTE tag = OS process identifier
609
610 - Processes of different Guest OSes can be assigned the same Process
611   ID
612
613   - VMM must flush TLB when switching VMs
614
615 Memory Virtualization (6)
616 -------------------------
617
618 - VMM must respect Guest OS virtual page faults
619
620   - Not map virtual pages unmapped by Guest OS
621   - When Guest OS unmaps a virtual page:
622
623     - VMM must delete the associated real-page/physical page
624       mapping, if any.
625
626 - Conversely, VMM can transparently:
627
628   - Introduce & resolve real-page faults for Guest OSes
629   - Share physical pages between Guest OS's
630
631     - Pages with same content's (e.g. zero-ed pages)
632
633 Memory Virtualization (7)
634 -------------------------
635
636 - VMM can swap real pages of a VM
637
638   - on "swap" space managed by VMM
639
640 - VMM can dynamically distribute physical memory among VMs
641
642   - Needs a specific support in Guest OS (Linux module)
643
644   - VMM asks Guest OS to release memory
645
646     - Guest OS self-allocates real pages
647     - no more available for normal kernel allocation service
648     - VMM assigns same amount of physical pages to other VM's
649
650 Paravirtualization
651 ==================
652
653 Paravirtualization (1)
654 ----------------------
655
656 - OS adaptation to avoid binary translation overhead
657 - Requires access to OS source code
658 - Include drivers of virtual devices
659 - Examples:
660
661   - Xen
662   - User Mode Linux (UML)
663
664 Paravirtualization (2)
665 ----------------------
666
667 - Still run each Guest OS in non-privileged mode
668
669 - But with minimal virtualization overhead
670
671 - => Modified Guest OS kernel
672
673   - Remove Hardware-Sensitive Instructions
674
675     - Use fast VMM system calls instead, if needed
676
677   - Minimise usage of Privileged Instructions
678
679 - Only affect Machine/CPU dependant part of OS
680
681 - OS portage on new architecture with same CPU
682
683   - Without system ISA
684
685 Paravirtualization (3)
686 ----------------------
687
688 - Guest OS only use Virtual I/O Devices, in a cooperative way
689
690   - Front-end driver in Guest OS
691   - Back-end driver in VMM
692
693 - VMM multiplex VM Virtual Devices on physical devices
694
695   - Virtual Ethernet
696   - Virtual Disks
697
698 - Data transfer through I/O rings
699
700 Virtual I/O Devices
701 -------------------
702
703 .. figure:: virt-devices.svg
704
705 Paravirtualization Example: Xen
706 -------------------------------
707
708 - Objectives
709
710   - Scalable, support more than 100 VM
711   - Share resources of Server machines
712
713 - Intel IA-32, x86-64, ARM, ...
714
715 - Special first Guest OS called Domain 0
716
717   - Run in privileged mode
718   - Have access (and manages) all physical devices
719   - Modified version of Linux, FreeBSD
720
721 Hardware-Assisted Virtualization
722 ================================
723
724 Hardware Assisted Virtualization (1)
725 ------------------------------------
726
727 - Support of Virtualization in Hardware
728 - Run unmodified OS binaries
729 - With minimal virtualization overhead
730 - Simplify VMM development
731 - Examples
732
733   - KVM
734   - VMware
735
736 Hardware Assisted Virtualization (2)
737 ------------------------------------
738
739 - CPU virtualization
740
741   - AMD-V
742   - Intel VT-x (x86), Intel VT-i (Itanium) architectures
743   - ARM Cortex-A15
744
745 - MMU virtualization
746
747   - Intel Extended Page Tables (EPT)
748   - AMD Nested Page Tables (NPT)
749
750 Hardware Assisted Virtualization (3)
751 ------------------------------------
752
753 - DMA virtualization
754
755   - IO-MMU (Intel VT-d)
756
757 - I/O Device virtualization
758
759   - Self-Virtualizing devices
760   - Single Root I/O Virtualization and Sharing Specification (SR-IOV)
761   - Extensions to PCIe (PCI Express) Bus standard
762
763 Intel VT-x Architecture
764 -----------------------
765
766 - Support unmodified Guest OS with no need for paravirtualization
767   and/or binary code translation
768
769 - Simplify VMM tasks & improve VMM performances
770
771 - Minimize VMM memory footprint
772
773   - Suppress shadowing of Guest OS page tables
774
775 - Enable Guest OS to directly manage I/O devices
776
777   - Without performance lost
778   - While enforcing VM isolation and mutual protection
779
780 Intel VT-x Architecture Overview
781 --------------------------------
782
783 .. figure:: vt-x.svg
784
785 Intel VT-x CPU Virtualization (1)
786 ---------------------------------
787
788 - Virtual Machine eXtension (VMX)
789
790   - Two new meta-modes of CPU operation
791
792 - VMX root mode
793
794   - Behaviour similar to IA-32 without VT
795   - Intended for VMM execution
796
797 - VMX non-root mode
798
799   - Alternative IA-32 execution environment
800   - Controlled by a VMM
801   - Designed to run unchanged Guest OS in a VM
802
803 - Both modes support rings 0-3 privilege levels
804
805   - Allow VMM to use several privilege levels
806
807 Intel VT-x CPU Virtualization (2)
808 ---------------------------------
809
810 - Two additional CPU mode transitions
811
812 - From VMX root-mode to VMX non-root mode
813
814   - Named VM Enter (VMLaunch instruction)
815
816 - From VMX non-root mode to VMX root mode
817
818   - Named VM Exit (event)
819
820 - VM entries & VM exits use a new data structure
821
822   - Virtual Machine Control Structure (VMCS) per VM
823   - Referenced with a memory physical address
824   - Format and layout hidden
825   - New VT-x instructions to access a VMCS
826
827 Intel VT-x CPU Virtualization (3)
828 ---------------------------------
829
830 - Guest State Area
831
832   - Saved value of registers before beeing changed by
833   - VM Exits (e.g., Segment Registers, CR3, IDTR)
834
835 - Hidden CPU state (e.g., CPU Interruptibility State)
836
837 - Host State Area
838
839   - VM Control Fields
840   - Interrupt Virtualization
841   - Exceptions bitmaps
842   - I/O bitmaps
843   - Model Specific Register R/W bitmaps
844   - Execution rights for CPU Privileged Instructions
845
846
847 Intel VT-x Interrupt Virtualization
848 -----------------------------------
849
850 - VMCS External Interrupt Exiting
851
852   - All external interrupts cause VM Exit
853   - Guest OS cannot mask external interrupts when executing Interrupt
854     Masking instructions
855
856 - VMCS Interrupt Window Exiting
857
858   - VM Exit occurs whenever Guest OS ready to serve external interrupts
859
860 - Used by VMM to control VM interrupts
861
862 Intel VT-x MMU Virtualization
863 -----------------------------
864
865 - Extended Page Tables (EPT)
866
867   - Second level of Page Tables in MMU
868   - Translate Guest OS Physical Address into Machine Physical Address
869   - Controlled by VMM
870
871 - Virtual Processor IDentifier (VPID)
872
873   - Used to tag TLB entries
874   - Avoid to flush TLB upon VM switch
875
876 Virtual Memory Virtualization
877 -----------------------------
878
879 .. figure:: vt-x-mem.svg
880
881 Intel VT-x Extended Page Tables (1)
882 -----------------------------------
883
884 - VMM controls Extended Page Tables
885
886 - EPT used in VMX non-root operation
887
888   - Activated on VM Enter
889   - Desactivated on VM exit
890
891 - EPTP register points to Extended Page Tables
892
893   - Instanciated by VMM
894   - Saved in VMCS
895   - Loaded from VMCS on VM entry
896
897
898 Intel VT-x Extended Page Tables (2)
899 -----------------------------------
900
901 .. figure:: vt-x-mmu.svg
902
903 TLB Flush Issue
904 ---------------
905
906 .. figure:: tlb-flush-issue.svg
907
908 Intel VT-x Virtual Processor Identifier
909 ---------------------------------------
910
911 - 16-bit VPID used to tag TLB entries
912
913   - Enabled by VMM in VMCS
914   - Unique VPID is assigned by VMM to each VM
915   - VPID 0 reserved for VMM
916
917 - Current VPID is 0x0000 when
918
919   - Outside VMX operation
920   - In VMX root mode operation
921   - In VMX non-root mode if VPID disabled in VMCS
922
923 - VPID loaded from VMCS on VM Enter
924
925 DMA Virtualization (1)
926 ----------------------
927
928 - Enable Guest OS to manage I/O devices
929
930   - I/O devices assigned by VMM to Guest OSes
931
932 - Transparent mode
933
934   - Use native device driver of Guest OS
935   - Unaware of physical memory Virtualization
936
937 - Enforce isolation between Guest Oses
938
939   - Guest OS only view hardware ressources assigned by VMM (memory,
940     devices)
941
942 DMA Principles
943 --------------
944
945 .. figure:: dma.svg
946
947 DMA Virtualization (2)
948 ----------------------
949
950 .. figure:: dma-virt.svg
951
952 DMA Virtualization Issue
953 ------------------------
954
955 - Guest OS driver setup I/O registers of device with Guest Physical
956   Address of I/O buffers
957
958 - Guest Physical Address must be translated into its corresponding
959   Machine Physical Address when used for DMA operations by device
960
961 - GPA Translation cannot be done by VMM
962
963   - VMM cannot catch device-specific driver operations to setup I/O
964     buffers addresses
965
966 Intel VT-d Protection Domains
967 -----------------------------
968
969 - Intel VT-d provides DMA Protection Domains
970
971   - Extension of IOMMU translation mechanism
972   - Isolated context of a subset of the Machine Physical Memory (MPA)
973   - Correspond to the portion of Machine Physical Memory allocated to
974     a VM
975
976 - I/O devices assigned by VMM to a DMA Protection Domain
977
978   - Achieves DMA isolation by restricting memory view of I/O devices
979     through DMA address translation
980
981 Intel VT-d DMA Translation
982 --------------------------
983
984 - VT-d hardware treats address specified in DMA request as DMA Virtual
985   Address (DVA)
986
987 - DVA = GPA of the VM to which the I/O device is assigned
988
989 - VT-d translates the DVA into its corresponding Machine Physical
990   Address
991
992 - Support of multiple Protection Domains
993
994   - DVA to MPA translation table per Protection Domain
995   - Must identify the device issuing a DMA request
996
997 VT-d PCI Express North Bridge
998 -----------------------------
999
1000 .. figure:: vt-d.svg
1001
1002 PCI DMA Requester Identification
1003 --------------------------------
1004
1005 - Mapping between PCI Device and Protection Domains
1006 - 16-bit PCI DMA Requester Identifier
1007
1008   .. figure:: dma-req-id.svg
1009
1010 - Assigned by PCI configuration software
1011 - Bus # indexes Bus Context Table in Root Context Table
1012 - (Device #, Function #) indexes Device Protection Domain in Bus
1013   Context Table
1014
1015 Device / Protection Domain Mapping
1016 ----------------------------------
1017
1018 .. figure:: device-domain-mapping.svg
1019
1020 Virtual DMA Address Translation
1021 -------------------------------
1022
1023 - VDA ↔ MPA VT-d Page Tables similar to IA-32 processor Page Tables
1024
1025 - 4KB or larger page size granularity
1026
1027 - Read/Write permissions
1028
1029 - Protection Domains managed by VMM
1030
1031   - Initialized at VM creation time
1032   - With same translations of the VM Extended Page Table
1033
1034 Device Virtualization
1035 ---------------------
1036
1037 - Share I/O device among multiple VMs
1038
1039   - With no performance lost
1040   - While enforcing VM isolation and protection
1041
1042 - Move device virtualization from the VMM to the device itself
1043
1044 - Requires support from the device
1045
1046 - Example of Ethernet controllers
1047
1048 Ethernet Device Virtualization
1049 ------------------------------
1050
1051 .. figure:: ethernet-dev-virt.svg
1052
1053 Intel Single Root I/O Virtualization
1054 ------------------------------------
1055
1056 - SR-IOV capable PCI Device can be partitionned into multiple Virtual
1057   Functions
1058
1059 - SR-IOV Device appears in PCI configuration space as multiple PCI
1060   Virtual Functions
1061
1062 - Each Device Virtual Function includes
1063
1064   - PCI configuration registers
1065   - DMA streams
1066   - Interrupts
1067
1068 - Requires VT-d for DMA virtualization
1069
1070 Intel SR-IOV (1)
1071 ----------------
1072
1073 - VMM manages physical PCI device
1074
1075 - Create a PCI Virtual Function for each VM
1076
1077   - Include it into VM PCI configuration space to be probed by VM
1078     GuestOS kernel
1079   - Map it to Protection Domain of VM
1080
1081 - Programs the sharing of physical devices ressources between VFs
1082
1083 - PCI Device Virtual Functions directly managed by specific VF-Aware
1084   GuestOS drivers (kind of Para-Virtualization)
1085
1086 Intel SR-IOV (2)
1087 ----------------
1088
1089 XXX
1090
1091 Intel SR-IOV - Ethernet example
1092 -------------------------------
1093
1094 - Intel Kawela (1GB) / Niantic (10GB) Ethernet NICs
1095
1096   - Multiple RX/TX packet queues per port
1097
1098 - Virtual Device Machine Queues
1099
1100   - 1 RX paquet queue per VF
1101
1102 - Filters multiple unicast Ethernet Addresses
1103
1104 - Layer-2 paquet filtering based on Ethernet Destination Address
1105
1106 - Duplicate Broadcast / Multicast packets for all VFs
1107
1108 - Load balancing between TX paquets sent by VFs
1109
1110 Virtualization and Embedded Systems
1111 ===================================
1112
1113 Old Embedded Systems (1)
1114 ------------------------
1115
1116 - Relatively simple architecture
1117
1118 - Single-purpose devices
1119
1120 - Dominated by hardware constraints
1121
1122   - Memory, battery charge
1123
1124 - Dedicated functionalities, with moderated software size and
1125   complexity
1126
1127 - Real-time constraints
1128
1129 Old Embedded Systems (2)
1130 ------------------------
1131
1132 - Closed environment (« black boxes »)
1133
1134 - Fixed hardware configuration
1135
1136 - Full software provided by device vendor
1137
1138 - No dynamic loading of applications
1139
1140 - Software updates rareful
1141
1142 Embedded Systems Now (1)
1143 ------------------------
1144
1145 - Take on features of general-purpose OS's
1146
1147 - Growing functionalities => growing complexity and size
1148
1149 - Run applications originally developed for PC's
1150
1151   - Sophisticated Human Machine Interfaces (HMI)
1152   - Safari Web browser on iPhones
1153
1154 - Dynamic loading of applications
1155
1156   - Iphone
1157   - Google Android
1158
1159 Embedded Systems Now (2)
1160 ------------------------
1161
1162 - Dynamically load device's owner specific applications
1163
1164   - Games
1165
1166 - Applications developped by engineers with no expertise
1167   in embedded systems
1168
1169   - Java applications
1170
1171 - Need for exchanges with external world
1172
1173   - USB, Bluetooth, Wi-Fi
1174   - TCP/IP
1175
1176 - Need for open API's, and openness in general
1177
1178 - Need for high-level systems (Linux, Windows)
1179
1180 Embedded Systems Challenges
1181 ---------------------------
1182
1183 - Still Real-Time systems (part of it)
1184
1185   - Baseband stack of mobile phones
1186
1187 - Still hardware constraints
1188
1189   - Battery
1190   - Memory (to minimize device's cost)
1191
1192 - Also used in mission/life critical situations
1193
1194   - Weapons
1195   - Cars
1196
1197 - High requirements on reliability and security
1198
1199 Mobile Handsets
1200 ---------------
1201
1202 XXX
1203
1204 - Run Android/Linux applications on baseband processor
1205
1206 - Re-use existing legacy modem software stack with its RTOS (no
1207   changes)
1208
1209 - Support of Linux at a minimal development cost
1210
1211 - Operating System independence for future evolutions
1212
1213 - Security & Protection through OS isolation
1214
1215 ::
1216
1217   HMI: Human-Machine-Interface
1218   PIM: Personal Information
1219
1220 Virtualization in Embedded Systems (1)
1221 --------------------------------------
1222
1223 - Support for heterogeneous OS's environments
1224
1225 - Real-time OS
1226
1227   - Legacy software
1228   - Dedicated applications whose real-time constraints cannot be
1229     achieved by General-Purpose systems
1230   - Licence issues (« GPL contamination »)
1231
1232 - General Purpose OS
1233
1234   - Openness
1235   - HMI
1236
1237 Virtualization in Embedded Systems (2)
1238 --------------------------------------
1239
1240 - Concurrent execution of RTOS and GP-OS on the same CPU
1241
1242 - Reduces cost (Bill Of Material)
1243
1244 - Requires the underlying VMM to provide
1245
1246   - Memory isolation between OS's
1247   - CPU scheduling among OS's, with higher priority to the RTOS
1248   - Device partitionning
1249   - Communication mechanism between OS's
1250
1251 Virtualization in Embedded Systems (3)
1252 --------------------------------------
1253
1254 - Leverage multi-cores support with virtual machine abstraction
1255
1256 - 1 core per OS => no need for CPU scheduling
1257
1258 - 2 low-performance cores consume less power than a single high
1259   performance CPU => simplify power management
1260
1261 - New model of software distribution, shipping application with its own OS
1262
1263   - No OS configuration/version incoherency
1264
1265 Security Through Virtualization
1266 -------------------------------
1267
1268 - Notion of Trusted Computing Base (TCB)
1269
1270   - Part of the system that provides security foundations
1271   - Should only include hardware and VMM
1272   - May also include RTOS, for performance/legacy reasons
1273
1274 - Run GP OS in an isolated Virtual Machine
1275
1276   - Avoid damaged GP OS to compromise the secure parts (data,
1277     services) of the system
1278
1279 Embedded + Virtualization Challenges (1)
1280 ----------------------------------------
1281
1282 - Full isolation of VM's does not fit cooperation requirements between OS's
1283
1284 - Efficient communication mechanisms between VM's
1285
1286 - Global scheduling, with interleaved priorities
1287
1288 - Global Energy Management
1289
1290 Embedded + Virtualization Challenges (2)
1291 ----------------------------------------
1292
1293 - Efficient communication mechanisms between VM's
1294
1295   - Virtual Ethernet device not adapted
1296   - Need VMM-controlled shared memory transfers
1297
1298 - Example: Video streaming on a Smartphone
1299
1300   - Video data received via the baseband managed by RTOS
1301   - Video data displayed by a Media Player running on GPOS
1302   - Avoid copy of video data transfered between the 2 OS's !
1303
1304 Task Scheduling Issues
1305 ----------------------
1306
1307 - Standard server-oriented Virtualization model
1308
1309   - The VMM schedules VM's on the CPU
1310   - The OS on each VM runs its own scheduler
1311
1312 - Interleaved priorities in Embedded Systems
1313
1314   - Baseband task of RTOS with a high priority
1315   - But GPOS Media-Player must have a higher priority than some
1316     low-priority tasks of RTOS
1317   - Enable a VM to yield the CPU
1318
1319     - Use a RT task as a proxy of GP OS application, and make it yield
1320       the CPU
1321
1322 Multi-Users Devices
1323 -------------------
1324
1325 - Mobile phone has 3 types of users, each with specific private data
1326   to protect from the others
1327
1328   - The person owning the device, with address book, emails,
1329     documents, etc.
1330   - Different wireless providers, for example private and
1331     professionnal: network access properly authenticated, ensure
1332     correct billing !
1333   - Third-party service providers, for instance multimedia providers.
1334
1335 - Owner and third-parties must be granted secure financial
1336   transactions
1337
1338 Virtualization in Hardware
1339 --------------------------
1340
1341 - Only way to build a real TCB
1342
1343   - Without penalizing performances
1344
1345 - Should include support for
1346
1347   - Memory Partitionning
1348   - Physical Memory / Machine Memory mapping
1349   - Coupled with multi-cores
1350   - Device Partitioning
1351
1352     - Interrupt routing
1353     - I/O DMA coupled with memory partitioning & Physical Memory /
1354       Machine Memory mapping
1355
1356 Conclusion / Evolution of Virtualization
1357 ========================================
1358
1359 Conclusion
1360 ----------
1361
1362 - Emulation : slow, multi-arch, simulates ISA (full machine) or ABI
1363   (process level)
1364 - Accelerated emulation : faster, code is executed natively, overhead
1365   for privilegied actions
1366 - Virtual servers : fast and scalable, but same OS and one kernel
1367 - Paravirtualization : fast, needs a modified OS
1368 - HW-assisted virtualization : solves most of the issues
1369
1370 Evolutions of Virtualization
1371 ----------------------------
1372
1373 - Cloud computing
1374
1375   - Big amount of data
1376   - Virtualization brings flexibility to data center
1377
1378 - Operating systems in browsers ?
1379
1380   - State of OS is stored remotely
1381
1382 - Virtualization on desktops and small devices
1383
1384   - Security (isolates work and personal area)