Peter Lipp - Institute of Applied Information Processing and ...
Peter Lipp - Institute of Applied Information Processing and ...
Peter Lipp - Institute of Applied Information Processing and ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Everything is eventually virtual<br />
Virtualisierung<br />
VO Betriebssysteme<br />
WS 09/10<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
1
Überblick<br />
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
●<br />
●<br />
●<br />
●<br />
●<br />
●<br />
Was ist Virtualisierung<br />
Geschichte<br />
Moderne Virtualisierung<br />
Virtualisierung auf Intel-IA-32<br />
Virtual Memory – virtualisiert<br />
XEN<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
2
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Was ist Virtualisierung?<br />
Virtualisierung erlaubt es, Ressourcen eines<br />
Computers so darzustellen, dass sie einfach<br />
verwendet werden können, ohne die genauen<br />
Eigenschaften kennen zu müssen.<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
3
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Virtualisierung<br />
●<br />
●<br />
●<br />
Virtueller Speicher<br />
Virtuelle CPU<br />
Dateisysteme<br />
●<br />
…<br />
warum nicht auch Virtuelle Maschinen?<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
4
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Virtuelle Maschinen<br />
●<br />
●<br />
●<br />
Entkoppeln des Betriebssystems von der<br />
Hardware<br />
●<br />
●<br />
Computer im Computer, durch S<strong>of</strong>tware implementiert<br />
Inkl. Devices wie Netz, Sound, …<br />
Betriebssystem in VM sieht “seine” Hardware,<br />
unabhängig von der tatsächlich vorh<strong>and</strong>enen<br />
Hardware<br />
Weiß nicht, ob/dass HW auch von <strong>and</strong>erer VM<br />
verwendet wird<br />
● Wie “früher” für Prozesse ...<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
5
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Virtualisierung<br />
Virtualization Layer<br />
Nur eine “Box”<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
6
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Wozu Virtualisierung<br />
●<br />
●<br />
Auslastung vorh<strong>and</strong>erer Hardware<br />
●<br />
●<br />
●<br />
Durch günstige Preise: ein Server für eine Aufgabe<br />
Großteil der Server zu 90% idle<br />
Kostenfrage<br />
– Support und Wartung<br />
– Stromverbrauch (Betrieb, Klimatisierung)<br />
– Platzbedarf<br />
Virtualisierung und Konsolidierung<br />
●<br />
Zusammenfassung mehrer Server auf einem System<br />
● Reduktion der HW-Kosten um bis zu 60%<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
7
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Vorteile von Virtualisierung<br />
●<br />
●<br />
●<br />
●<br />
●<br />
Effizientere HW-Nutzung<br />
Geringere Administrationskosten<br />
Langfristiger Betrieb älterer Applikationen<br />
möglich<br />
Geringere Ausfallszeiten möglich<br />
Einfache Migration auf leistungsfähigere<br />
Hardware möglich<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
8
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Nachteile von Virtualisierung<br />
●<br />
●<br />
●<br />
I/O-lastige SW läuft langsamer (gemeinsame<br />
HW-Nutzung)<br />
Single Point <strong>of</strong> Failure: bei HW-Ausfall<br />
mehrere virtuelle Maschinen betr<strong>of</strong>fen →<br />
höhere Zuverlässigkeit der HW erforderlich<br />
Sicherheitsaspekte werden komplexer<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
9
Begriffe<br />
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
●<br />
●<br />
Host, host machine<br />
●<br />
●<br />
Rechner, auf dem Virtualisierungss<strong>of</strong>tware läuft<br />
Hat physische Ressourcen (Speicher, Disk, CPU, …)<br />
die von virtuellen Maschinen genutzt werden<br />
Virtuelle Maschinen, VM<br />
●<br />
●<br />
●<br />
●<br />
Virtualisierte Verkörperung einer phyischen Maschine<br />
Betrieben durch Virtualisierungss<strong>of</strong>tware<br />
Implementiert durch eine oder wenige Datei(en) auf<br />
dem Host-System<br />
Verhält sich, als ob sie auf echter HW laufen würde<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
10
Begriffe<br />
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
●<br />
●<br />
Virtualisierungss<strong>of</strong>tware<br />
●<br />
S<strong>of</strong>tware, mit deren Hilfe virtuelle Maschinen auf<br />
einem Rechner laufen können<br />
Virtual Machine Monitor (VMM)<br />
●<br />
●<br />
●<br />
S<strong>of</strong>tware, die in Zusammenarbeit mit dem host-OS<br />
Virtualisierung implementiert<br />
Virtualisiert HW-Ressourcen<br />
Erzeugt emulierte Geräte<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
11
Begriffe<br />
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
●<br />
Hypervisor<br />
●<br />
●<br />
Ähnlich VMM, läuft aber direkt auf Hardware ohne<br />
Hilfe eines host-OS<br />
Direkt für Betrieb von VMs auf der HW<br />
verantwortlich<br />
●<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
12
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
Aus: Lendert van Doorn, Hardware Virtualisation Trends, Vortragsfolien 2006<br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
13
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Klassische Virtualisierung<br />
●<br />
●<br />
●<br />
Virtualisierung ist nichts neues!<br />
Grundlegende Ideen bereits ~50 Jahre alt<br />
Begriff Virtuelle Maschine tritt erstmals beim<br />
Großrechner IBM M44/44X auf (1963)<br />
●<br />
●<br />
Ein “Hauptrechner”: IBM 7044 (M44)<br />
Mehrere Virtuelle Maschinen: M44X<br />
– Verwendeten gleiche HW/SW, virtuellen Speicher,<br />
Multiprogramming<br />
– Keine komplette Simulation der darunterliegenden HW<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
14
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Klassische Virtualisierung<br />
● IBM OS/360 (1967)<br />
●<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
●<br />
●<br />
Nicht kompatibel zu IBM 7070 (beliebte Maschine)<br />
7070-Emulator<br />
– Verhält sich wie alte Maschine<br />
– daher alte S<strong>of</strong>tware weiterverwendbar<br />
IBM OS/370: erste rekursive virtuelle<br />
Maschine<br />
●<br />
Verschiedene VMs<br />
gleichzeitig<br />
User Prog 1<br />
OS 1<br />
Virtual 370<br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
VM 370<br />
Hardware<br />
User Prog 2<br />
OS 2<br />
Virtual 370<br />
Title 09/10<br />
15
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
1980er und 1990er<br />
●<br />
●<br />
Billige HW senkt Bedarf<br />
In dieser Zeit keine hardware-level VMs<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
16
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Klassische Virtualisierung<br />
●<br />
●<br />
Java Virtual Machine<br />
● Veröffentlicht 1991<br />
●<br />
●<br />
●<br />
Arbeitet mit Java-Bytecode<br />
Muss auf einem Rechner emuliert werden<br />
Jedes Programm läuft in eigener VM<br />
Common Language Runtime (CLR)<br />
● C#<br />
●<br />
Micros<strong>of</strong>t .NET<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
17
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
S<strong>of</strong>tware-Virtualisierung<br />
●<br />
WABI (Windows Application Binary Interface)<br />
(1993)<br />
●<br />
●<br />
Hoher Marktanteil von Windows<br />
Wabi erlaubt es, Windows Programme auf SUN-<br />
Maschinen unter Solaris auszuführen<br />
– x86: Code direkt ausführbar<br />
– SPARC: x86-Emulator<br />
● WINE (1993)<br />
●<br />
●<br />
Ähnliches Konzept für Linux, aber nur auf x86<br />
Kein Emulator<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
18
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Moderne Virtualisierung<br />
●<br />
●<br />
●<br />
User Mode Linux, 1999: Patch für Linux von<br />
Jeff Dike erlaubt es, ein zweites System wie<br />
einen Prozess auszuführen. Seit 2001 in<br />
Kernel 2.4, gut zum Kernel-Testen.<br />
VMWare Workstation, 1999: komplette<br />
Virtualisierung eines x86-Computers auf x86-<br />
Host<br />
XEN <strong>and</strong> the Art <strong>of</strong> Virtualisation, 2003: man<br />
beginnt, über Emulation hinaus die HW zu<br />
nutzen.<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
19
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Moderne Virtualisierung<br />
●<br />
●<br />
●<br />
●<br />
Virtualisierung auf Betriebssystemebene<br />
Paravirtualisierung<br />
Vollständige Virtualisierung<br />
Hardwarebasierte Virtualisierung<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
20
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Virtualisierung auf OS-Ebene<br />
●<br />
●<br />
●<br />
Im Kernel des Hosts integriert<br />
Alle Anwendungsprogramme, die in virtuellen<br />
Umgebungen laufen sollen, erhalten strikt<br />
getrennte virtuelle Lauftzeitumgebungen<br />
(container, jails)<br />
Keine getrennten Kernel – nur Prozess-<br />
Virtualisierung<br />
● Kein Fremd-Betriebssystem virtualisierbar –<br />
für Isolation von Anwendungen geeignet<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
21
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Virtualisierung auf OS-Ebene<br />
Virtuelles<br />
System<br />
1<br />
Virtuelles<br />
System<br />
2<br />
Host-Kernel<br />
Hardware<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
22
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Virtualisierung auf OS-Ebene<br />
●<br />
●<br />
Beispiel: Parallels Virtuozzo Containers<br />
●<br />
Verwendung in Datacenter<br />
– Internet-Hosting<br />
– Application Service Providing<br />
● Geringe Leistungseinbußen (~2%)<br />
●<br />
●<br />
●<br />
Mehrere hundert virtuelle Server möglich<br />
Features: Live-Migration, Cloning, Web-GUI,<br />
Management Center zur Verwaltung<br />
Teuer<br />
OpenVZ: abgespeckte Open-Source-Variante<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
23
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
User-Mode-Linux (UML)<br />
●<br />
●<br />
●<br />
●<br />
●<br />
Kernel läuft als User-Prozess<br />
arch-Teilbaum für architekturabhängige Teile<br />
des Kernels<br />
In UML: User Mode ist eigene Architektur<br />
●<br />
●<br />
Hardwarespezifische Befehle durch SW emuliert<br />
Im Bedarfsfall Befehle an Host-Kernel<br />
durchreichen<br />
Keine Treiber für Peripherie nötig<br />
Keine root-Rechte nötig<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
24
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
UML<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
user-mode-linux.sourceforge.net<br />
Title 09/10<br />
25
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Syscalls in UML<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
user-mode-linux.sourceforge.net<br />
Title 09/10<br />
26
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Syscalls in UML<br />
●<br />
ptrace – debugfeature zum Abfangen der INT<br />
0x80 – Instruktionen<br />
●<br />
●<br />
●<br />
●<br />
●<br />
Prozess führt INT 0x80 aus<br />
tracing thread wird angeworfen<br />
annulliert syscall (ersetzt ihn durch harmlosen<br />
getpid-Syscall)<br />
tracing thread lässt syscall vom guest-kernel<br />
ausführen<br />
Ersetzt Rückgabewerte des dummy-syscall durch<br />
die des echten syscalls<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
27
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
UML<br />
●<br />
●<br />
Prozessverwaltung mit Host gekoppelt<br />
●<br />
Pro Prozess ein Prozess im Host-Kernel<br />
– Beschleunigt Context-Switch<br />
– Verkompliziert manches<br />
Virtueller Speicher<br />
●<br />
●<br />
●<br />
●<br />
File mit Größe des gewünschten “physischen” Speichers<br />
fmap in den Adressraum von UML<br />
Kernel-Adressraum ist Teil des Adressraums der<br />
Prozesse<br />
pages des Files werden in die Virtuellen Adressräume<br />
gemapped<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
28
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Paravirtualisierung<br />
●<br />
●<br />
●<br />
Virtualisierung in Zusammenarbeit mit guest-<br />
OS<br />
Guest muss modifiziert werden<br />
Nicht für closed-source-Systeme geeignet<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
29
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Vollständige Virtualisierung<br />
●<br />
●<br />
●<br />
●<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
Betriebssystem merkt idealerweise nichts davon,<br />
dass es nicht auf echter Hardware eingesetzt wird<br />
Gastsystem muss nicht angepasst werden<br />
●<br />
Beispielsweise bei proprietären OS<br />
Nachteil: Leistungseinbußen<br />
●<br />
Bis zu 25%<br />
Grund: HW muss vollständig virtualisiert werden<br />
●<br />
●<br />
Virtuelle Maschinen dürfen nicht auf physischen<br />
Komponenten zugreifen müssen<br />
Jede physisch vorh<strong>and</strong>ene Komponente ist zu<br />
virtualisieren und benötigt Treiber im Gast-OS<br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
30
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Binary Translation<br />
●<br />
●<br />
●<br />
●<br />
●<br />
Guest läuft nicht mehr in Ring 0 → Alle Teile<br />
des Guest, die Rechte von Ring 0 benötigen,<br />
funktionieren so nicht<br />
Daher: VMM ändert binaries des Guest-OS<br />
“on the fly”<br />
Mehr Betriebssysteme unterstützbar<br />
●<br />
Keine Notwendigkeit, source zu ändern<br />
Performance-Overhead hoch<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
31
VMWare<br />
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
●<br />
●<br />
●<br />
Erste Implementierung einer vollständigen<br />
Virtualisierung der x86-Architektor<br />
VMM liest parallel laufend den Programmcode<br />
der VM aus, bevor er ausgeführt wird<br />
(Prescan)<br />
Sucht nach relevanten Befehlen<br />
●<br />
●<br />
Änderung des Systemzust<strong>and</strong>es oder <strong>and</strong>ere, vom<br />
internen Prozessorzust<strong>and</strong> (z.B. Aktueller Ring)<br />
abhängige Befehle<br />
Breakpoint setzen, weiterlaufen lassen<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
32
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Probleme bei Intel IA-32<br />
●<br />
Welcher Ring?<br />
●<br />
Üblicherweise Anwendungs-SW in Ring 3, Kernel<br />
in Ring 0<br />
● VMM braucht höchstes Privileg – daher Ring 0<br />
●<br />
●<br />
Gast darf nicht in Ring 0 laufen, sonst könnte er<br />
VMM aushebeln<br />
Ring depriviledging – Gast muss in Ring > 0 laufen<br />
● Meist Ring 1 (0/1/3-Modell) oder Ring 3 (0/3/3)<br />
●<br />
0/1/3 macht VMM einfacher<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
33
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Ring aliasing<br />
●<br />
●<br />
●<br />
●<br />
Gast-OS muss in Ring laufen, für den es nicht<br />
entwickelt wurde<br />
Bestimmte Instruktionen enthalten privilege<br />
level im Ergebnis – z.B. PUSH CS.<br />
Guest-OS kann feststellen, in welchem Ring<br />
es läuft<br />
Kann zu diversen Problemen führen<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
34
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Address Space Compression<br />
●<br />
●<br />
●<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
Guest-OS erwartet, den gesamten virtuellen<br />
Adressraum zur Verfügung zu haben<br />
VMM benötigt Teil des Virtuellen Adressraums<br />
●<br />
●<br />
Kontrollstrukturen für Verwaltung der Wechsel<br />
Guest ↔ VMM<br />
Unter <strong>and</strong>erem: Interrupt-Descriptor-Table (IDT),<br />
Global-Descriptor-Table (GDT); die lineare Adressen<br />
enthalten<br />
Zugriff auf diese Bereiche durch guest nicht<br />
erlaubt → Wechsel in VMM, muss sie<br />
emulieren<br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
35
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Non-Faulting Access to Priv. State<br />
●<br />
●<br />
●<br />
Unprivilegierte SW darf auf gewisse Elemente<br />
des CPU-Status nicht zugreifen<br />
Zugriff durch guest → fault → VMM kann<br />
Instruktion des guest emulieren<br />
IA-32 hat Instruktionen, die keinen fault auslösen<br />
●<br />
Register GDTR, IDTR, LDTR, TR haben<br />
Auswirkungen auf CPU<br />
●<br />
Nur im Ring 0 modifizierbar (LGDT, LIDT … )<br />
●<br />
In jedem Ring ohne fault ausführbar (ohne Funktion)<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
36
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
SYSENTER / SYSEXIT<br />
●<br />
Spezielle Befehle für schnelle Syscalls<br />
● SYSENTER wechselt immer in Ring 0<br />
●<br />
●<br />
SYSEXIT darf nur in Ring 0 ausgeführt<br />
werden<br />
Ring 1 macht daher Probleme<br />
●<br />
●<br />
SYSENTER wechselt in VMM und nicht guest OS<br />
→ VMM muss das emulieren<br />
SYSEXIT des guest wechselt in VMM → emulieren<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
37
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Interrupt Virtualisierung<br />
●<br />
●<br />
●<br />
●<br />
●<br />
●<br />
Interrupts maskieren (treten nicht auf, wenn<br />
unerwünscht)<br />
Interrupt flag (IF) in EFLAGS-Register<br />
Interrupts aber von VMM gemanaged<br />
Änderung des IF → fault in VMM<br />
Betriebssysteme tun das sehr <strong>of</strong>t →<br />
Performance problem !<br />
Weiterreichen virtueller Interrupts muss IF-<br />
Flag berücksichtigen<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
38
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Versteckter Zust<strong>and</strong><br />
●<br />
●<br />
●<br />
Nicht alle Zust<strong>and</strong>sinformation ist über<br />
Register zugänglich<br />
z.B. Versteckte Caches für Deskriptoren, die<br />
beim Laden des Registers mitgeladen werden<br />
(GDT, LDT)<br />
Können beim Wechsel zwischen VMs nicht<br />
gesichert oder zurückgespielt werden<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
39
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Ring Compression<br />
●<br />
●<br />
●<br />
Speicherschutz über Segmente und paging<br />
64bit-Mode: keine Segmente<br />
Paging: Ring 0-2 wird bzgl. Zugriffsschutz<br />
nicht unterschieden<br />
● → guest muss in Ring 3 laufen (0/3/3)<br />
●<br />
→ kein Schutz vor guest Apps<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
40
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Intel Virtualization Architecture<br />
●<br />
Zwei neue Betriebsarten:<br />
●<br />
●<br />
VMX root operation<br />
– Für VMM<br />
– Ähnlich IA-32 ohne VT<br />
VMX non-root operation<br />
– Kontrolliert von VMM<br />
– Unterstützt VMs<br />
● Beide Modi haben Ring 0-3<br />
●<br />
Guest kann wieder in Ring 0 laufen<br />
● VMM läuft in “Ring -1”<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
41
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
VT-x<br />
●<br />
●<br />
●<br />
Zwei neue Übergänge<br />
●<br />
●<br />
VM entry: root operation → non-root operation<br />
VM exit: non-root operation → root operation<br />
VMCS – Virtual Machine Control Structure<br />
●<br />
●<br />
Guest-state area<br />
Host-state area<br />
Entry/Exit lädt/sichert in die jeweils passende<br />
area<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
42
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
VMCS – Guest State Area<br />
●<br />
●<br />
●<br />
●<br />
Enthält Elemente des Zust<strong>and</strong>es der virtuellen<br />
CPU einer VMCS<br />
Bei VM-exit müssen gewisse Register gleaden<br />
werden (wie Segmentregister, CR3, IDTR....)<br />
Felder für diese Register in der GSA<br />
Andere Felder, die nicht über Register<br />
ausgelesen werden können<br />
●<br />
z.B.: interuptability state: sind externe Interrupts<br />
erlaubt oder NMIs erlaubt (NMI wird gerade<br />
bearbeitet)<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
43
VMCS<br />
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
●<br />
●<br />
Steuerung der Unterstützung von Interrupt-<br />
Virtualisierung<br />
●<br />
●<br />
VM-exit bei allen externen Interrupts (nicht durch<br />
guest maskierbar)<br />
VM-exit, wenn guest-OS bereit für Interrupts<br />
(EFLAGS.IF=1)<br />
Unterstützung der Virtualisierung von CR0<br />
und CR4<br />
●<br />
●<br />
VM-exit bei Änderung durch guest-OS<br />
Einstellbar, bei welchen Bits<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
44
VMCS<br />
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
●<br />
●<br />
●<br />
●<br />
Wird über physische Adresse referenziert<br />
Muss daher nicht im Adressraum des Guests<br />
liegen<br />
VMM kann in <strong>and</strong>erem Adressraum laufen als<br />
guest (CR3 Teil des geladenen Zust<strong>and</strong>s)<br />
VM-exits hinterlassen im VMCS detaillierte<br />
<strong>Information</strong> über die Ursache des exits<br />
●<br />
●<br />
Exit reason<br />
Exit qualification<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
45
VMCS<br />
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
●<br />
●<br />
●<br />
Beispiel: MOV CR<br />
Exit reason: “control register access”<br />
Exit qualification:<br />
●<br />
●<br />
●<br />
Welches CR<br />
Welche Richtung (Rx → CR oder CR → Rx)<br />
Welches Register Rx war Quelle oder Ziel<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
46
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Lösungen für ursprünglichen Probleme<br />
●<br />
●<br />
●<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
Addr. Space Compression<br />
●<br />
●<br />
Bei jedem Übergang guest/VMM Wechsel des<br />
Adressraums möglich<br />
Guest hat vollen virtuellen Adressraum<br />
Ring Aliasing, Ring Compression<br />
●<br />
Guest SW kann im vorgesehenen Privilege-Level<br />
arbeiten<br />
Nonfaulting Access to Privileged State<br />
●<br />
●<br />
Zugriffe lösen fault in VMM aus<br />
Status für VMM nicht mehr so wichtig<br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
47
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Lösungen für ursprünglichen Probleme (2)<br />
●<br />
●<br />
●<br />
SYSENTER / SYSEXIT<br />
●<br />
Guest-OS läuft in Ring 0 – kein Problem mehr<br />
Interrupt Virtualisierung<br />
●<br />
●<br />
Guest hat keine Kontrolle über Interrupt-<br />
Maskierung<br />
Fault bei jedem Zugriff nicht mehr nötig<br />
Hidden State<br />
●<br />
In VMCS gesichert<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
48
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
VM und Virtual Memory<br />
●<br />
●<br />
●<br />
●<br />
VMM verwendet Virtuellen Speicher<br />
Guest-OS verwendet Virtuellen Speicher<br />
Hardware verwendet Pagetables<br />
Wie funktioniert das noch?<br />
●<br />
●<br />
Shadow Page Tables<br />
Hardware Assist<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
49
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Virtual Memory<br />
Guest virtual address<br />
Adressumsetzung<br />
Guest physical address<br />
Adressumsetzung<br />
Host physical address<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
50
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
All problems in computer science can be<br />
solved by another level <strong>of</strong> indirection.<br />
But that usually will create another problem.<br />
David Wheeler<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
51
Paging<br />
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
virtual<br />
adresspace<br />
physical<br />
adresspace<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
52
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Bekannt aus VO und KU....<br />
31 22<br />
PD<br />
21 12 11 0<br />
PT<br />
Offset<br />
Guest virtual address<br />
CR3<br />
PT<br />
+<br />
PD + PT +<br />
Guest physical address<br />
PT<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
53
64 bit<br />
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
47 3938 30<br />
L4<br />
L3<br />
29 21<br />
L2<br />
20 12 11 0<br />
L1<br />
Offset<br />
Guest virtual address<br />
CR3<br />
+ PML4 + PDP<br />
+<br />
PD + PT +<br />
Guest physical addres<br />
TLB<br />
PML4 … Page Map Level 4<br />
PDP … Page Directory Pointer<br />
PD … Page Directory<br />
PT … Page Table<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
54
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Paging<br />
process<br />
virtual<br />
adresspace<br />
guest<br />
physical<br />
adresspace<br />
host<br />
physical<br />
adresspace<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
55
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Shadow Page Table<br />
process<br />
virtual<br />
adresspace<br />
guest<br />
physical<br />
adresspace<br />
host<br />
physical<br />
adresspace<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
56
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Page tables …<br />
process<br />
virtual<br />
adresspace<br />
guest<br />
physical<br />
adresspace<br />
host<br />
physical<br />
adresspace<br />
Guest<br />
page<br />
table<br />
Host<br />
page<br />
table<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
57
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Shadow Page Table<br />
process<br />
virtual<br />
adresspace<br />
host<br />
physical<br />
adresspace<br />
shadow<br />
Page<br />
table<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
58
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Shadow page table<br />
●<br />
●<br />
●<br />
●<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
Kombiniert beide pagetables<br />
Guest verändert eigene pagetable<br />
●<br />
●<br />
VMM muss Zugriff abfangen<br />
Und Shadow pagetable aktualisieren<br />
Hardware verändert die shadow PT<br />
Aufwändig!<br />
●<br />
●<br />
●<br />
●<br />
Pagefaults vom VMM abgearbeitet<br />
Muss die guest PTs durchlaufen<br />
Accessed und Modified Bits für Guest emulieren<br />
Bis zu 3 pagefaults für einen guest-page-fault<br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
59
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
EPT<br />
Guest CR3<br />
EPT Base Pointer<br />
Guest lineare<br />
Adresse<br />
Guest page table<br />
Guest phys. Adresse<br />
EPT page table<br />
Host phys.<br />
Adresse<br />
TLB und Cache<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
60
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Nested PT (NPT, AMD)<br />
Extended PT (EPT, Intel)<br />
47 39<br />
L4<br />
38 30<br />
L3<br />
29 21<br />
L2<br />
20 12<br />
L1<br />
11 0<br />
Offset<br />
gCR3<br />
PML4<br />
+ +<br />
PDP<br />
+<br />
PD + PT +<br />
47 39<br />
L4<br />
38 30<br />
L3<br />
29 21<br />
L2<br />
20 12<br />
L1<br />
11 0<br />
Offset<br />
CR3<br />
PML4<br />
+ +<br />
PDP<br />
+<br />
PD + PT +<br />
“guest page walk”<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
61
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Guest page walk<br />
●<br />
●<br />
Viele Speicherzugriffe nötig...<br />
Wie viele?<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
62
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Guest page walk<br />
●<br />
●<br />
●<br />
Viele Speicherzugriffe nötig...<br />
Wie viele?<br />
Zuerst nur mal der Host:<br />
47 3938 30<br />
L4<br />
L3<br />
29 21<br />
L2<br />
20 12 11 0<br />
L1<br />
Offset<br />
+ PML4 + PDP<br />
+<br />
PD + PT +<br />
5<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
1 2 3 4<br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
63
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Guest page walk<br />
●<br />
●<br />
Jetzt auch der Guest...<br />
Wie viele Speicherzugriffe insgesamt?<br />
47 3938 30<br />
L4<br />
L3<br />
29 21<br />
L2<br />
20 12 11 0<br />
L1<br />
Offset<br />
+ PML4 + PDP<br />
+<br />
PD + PT +<br />
5<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
1 2 3 4<br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
64
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Guest page walk<br />
●<br />
●<br />
Jetzt auch der Guest...<br />
Wie viele Speicherzugriffe insgesamt?<br />
47 3938 30<br />
L4<br />
L3<br />
29 21<br />
L2<br />
20 12 11 0<br />
L1<br />
Offset<br />
25<br />
Speicherzugriffe!<br />
+ PML4 + PDP<br />
+<br />
PD + PT +<br />
C R 3<br />
4 7 3 8 3 9 2 9 3 0 2 0 2 1 1 1 1 2<br />
0<br />
L 4<br />
L 3<br />
L 2<br />
L 1 O ff s e t<br />
+ P M L 4 + P D P<br />
+<br />
P D + P T +<br />
4 7 3 8 3 9 2 9 3 0 2 0 2 1 1 1 1 2<br />
0<br />
L 4<br />
L 3<br />
L 2<br />
L 1 O ff s e t<br />
4 7 3 8 3 9 2 9 3 0 2 0 2 1 1 1 1 2<br />
0<br />
L 4<br />
L 3<br />
L 2<br />
L 1 O ff s e t<br />
4 7 3 8 3 9 2 9 3 0 2 0 2 1 1 1 1 2<br />
0<br />
L 4<br />
L 3<br />
L 2<br />
L 1 O ff s e t<br />
4 7 3 8 3 9 2 9 3 0 2 0 2 1 1 1 1 2<br />
0<br />
L 4<br />
L 3<br />
L 2<br />
L 1 O ff s e t<br />
C R 3<br />
+ P M L 4 + P D P<br />
+<br />
P D + P T +<br />
C R 3<br />
+ P M L 4 + P D P<br />
+<br />
P D + P T +<br />
C R 3<br />
+ P M L 4 + P D P<br />
+<br />
P D + P T +<br />
C R 3<br />
+ P M L 4 + P D P<br />
+<br />
P D + P T +<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
65
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Guest page walk<br />
Aus: Bhargava et. al., Accelerating Two-Dimensional PageWalks for Virtualized Systems, ASPLOS’08 March 1–5, 2008, Seattle, Washington, USA<br />
Copyright © 2008 ACM978-1-59593-958-6/08/03.<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
66
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Performance<br />
●<br />
●<br />
●<br />
Je nach Applikationstyp 3.9-4.6 mal so<br />
langsam<br />
AMD Opteron Translation Caching<br />
●<br />
●<br />
aka TLB<br />
Speichert Übersetzung virtuelle → physische<br />
Adresse<br />
Page Walk Cache (PWC)<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
67
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Page Walk Cache (PWC)<br />
●<br />
●<br />
●<br />
●<br />
Wie TLB: Assoziativspeicher, klein, schnell<br />
Speichert PTEs aller Ebenen außer L1 (TLB)<br />
Entries werden in L2-cache gecached<br />
●<br />
PWC-miss: PTE kann in L2 oder L3 cache sein<br />
18%-45% Verbesserung<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
68
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Features / Intel<br />
●<br />
●<br />
●<br />
EPT nur verwendet, wenn VM aktiv<br />
Übersetzungen werden im TLB mit EPTbasepointer<br />
getagged<br />
●<br />
●<br />
Caches verschiedener VMs unterscheidbar<br />
TLB-flush nur für bestimmten guest möglich<br />
VPID – virtual processor ID<br />
●<br />
●<br />
Eindeutiger Wert für jede VM<br />
Übersetzungen werden im TLB mit VPID getagged<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
69
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
XEN<br />
DOM 0<br />
XEN DM<br />
DOM U<br />
DOM U<br />
Hypervisor<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
Hardware<br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
70
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
XEN Hypervisor<br />
●<br />
●<br />
●<br />
●<br />
●<br />
●<br />
Erste Abstrahierungsschicht<br />
Sitzt direkt auf Hardware<br />
Unter allen Betriebssystememe<br />
Verantwortlich für<br />
●<br />
●<br />
CPU-Scheduling<br />
Speichermanagement<br />
Abstrahiert die HW für die Vms<br />
Kontrolliert die Execution der VMs<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
71
Domain 0<br />
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
●<br />
●<br />
●<br />
●<br />
●<br />
●<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
Modifizierter Linux-Kernel<br />
Hat spezielle Rechte<br />
Darf I/O-Ressourcen direkt verwenden<br />
Kann mit <strong>and</strong>eren VMs interagieren<br />
Zwei wichtige Driver in Dom0<br />
●<br />
●<br />
Network Backend Driver<br />
Block Backend Driver<br />
Führt Netzwerk- und Disk-Kommunikation im<br />
Auftrag von DOM-U-Domains durch<br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
72
Domain U<br />
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
●<br />
Paravirtualisierte oder voll virtualisierte guests<br />
●<br />
●<br />
Domain U PV guests<br />
– Linux<br />
– Solaris<br />
– FreeBSD<br />
Domain U HVM guests<br />
– Windows<br />
– Anderes unverändertes OS<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
73
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
PV versus HVM<br />
●<br />
●<br />
PV guest weiß, dass er in VM läuft<br />
PV guest hat PV Netzwerk- und Block-Driver<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
74
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
PV versus HVM<br />
●<br />
●<br />
●<br />
HVM guest weiß nicht, dass er in VM läuft<br />
HVM guest hat keinen PV Netzwerk- und<br />
Block-Driver<br />
●<br />
●<br />
Für jeden guest ein Dämon in DOM-0: Qemu-dm<br />
Unterstützt guest bei Netz- und Diskzugriffen<br />
Umgebung wie bei PC erforderlich<br />
●<br />
●<br />
Xen virtual firmware<br />
Simuliert BIOS<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
75
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Kommunikation Dom-0 ↔ Dom-U<br />
DOM 0<br />
PV Block<br />
backend driver<br />
Event Channel<br />
DOM U<br />
PV Block<br />
backend driver<br />
Hypervisor<br />
Shared Memory<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
76
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Kommunikation Dom-0 ↔ Dom-U<br />
●<br />
●<br />
●<br />
●<br />
●<br />
●<br />
●<br />
Guest PV block driver erhält Schreibrequest auf lokale<br />
Platte<br />
Schreibt Daten mit Hilfe des Xen hypervisor in einen mit<br />
Dom-0 geteilten Speicher<br />
Ein Event channel existiert zwischen Dom-0 und dem guest<br />
Kommunikation über asynchrone inter-domain interrupts im<br />
Xen hypervisor.<br />
Domain 0 erhält Interrupt<br />
Block Backend Driver liest Daten aus dem Dom-U PV<br />
Guest shared memory.<br />
Daten werden auf lokale Festplatte geschrieben<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
77
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
I/O Descriptor Ring<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
Aus: Xen <strong>and</strong> the Art <strong>of</strong> Virtualization, Barham et.al., SOSP'03,2003<br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
78
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Xen und Memory<br />
●<br />
●<br />
Xen VMM liegt in einem 64MB Bereich am<br />
oberen Ende eines Guest-Adressraums<br />
●<br />
Nicht vom Guest zugreifbar<br />
Guest kann pagetables verändern<br />
●<br />
●<br />
Über Hypercalls<br />
Xen validiert Requests<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
79
<strong>Institute</strong> for <strong>Applied</strong> <strong>Information</strong> <strong>Processing</strong> <strong>and</strong> Communications (IAIK) – Secure & Correct Systems<br />
Exceptions<br />
●<br />
●<br />
●<br />
●<br />
Häufig<br />
●<br />
●<br />
Syscalls<br />
Pagefaults<br />
Exceptionh<strong>and</strong>ler für syscalls registrierbar<br />
● Vermeidet Wechsel in Ring 0<br />
Funktioniert nicht für pagefaults<br />
Virtualisierte Interrupts<br />
●<br />
Event-delivery-Mechanismus, “leichtgewichtig”<br />
<strong>Peter</strong> <strong>Lipp</strong><br />
http://www.iaik.t<br />
ugraz.at Betriebssysteme<br />
Place, Date<br />
Title 09/10<br />
80