
Address Spaces and Virtual Memory Specification, Implementation, and Correctness Dissertation zur Erlangung des Grades Doktor der Ingenieurswissenschaften (Dr.-Ing.) der Naturwissenschaftlich-Technischen Fakult¨at I der Universit¨at des Saarlandes Mark Hillebrand [email protected] Saarbruck¨ en, Juni 2005 ii Tag des Kolloquiums: 13. Juni 2005 Dekan: Prof. Dr. Jor¨ g Eschmeier Vorsitzender des Prufungsausschusses:¨ Prof. Dr.-Ing. Philipp Slusallek 1. Berichterstatter: Prof. Dr. Wolfgang J. Paul 2. Berichterstatter: Prof. Dr. Peter-Michael Seidel 3. Berichterstatter: Prof. Dr. Kurt Mehlhorn akademischer Mitarbeiter: Dr. Sven Beyer Hiermit erklare¨ ich, dass ich die vorliegende Arbeit ohne unzulassige¨ Hilfe Dritter und ohne Benutzung anderer als der angegebenen Hilfsmittel angefertigt habe. Die aus anderen Quellen oder indirekt ubernommenen¨ Daten und Konzepte sind unter Angabe der Quelle gekennzeichnet. Die Arbeit wurde bisher weder im In- noch im Ausland in gleicher oder ahnlicher¨ Form in anderen Prufungsv¨ erfahren vorgelegt. Saarbruck¨ en, im Juni 2005 iii iv “Pretend that you're Hercule Poirot: Examine all clues, and deduce the truth by order and method.” (Donald Knuth. TEX: The Program; Section 1283) Danksagung An dieser Stelle mochte¨ ich allen danken, die zum Gelingen der vorliegenden Arbeit beigetragen haben. Mein Dank gilt zunachst¨ meinen Eltern, die mich wahrend¨ der gesamten Zeit meiner Ausbildung gefordert¨ haben. Herrn Prof. Wolfgang Paul danke ich fur¨ die wissenschaftliche Unterstutzung¨ bei meiner Promotion und die Moglichk¨ eit, meine Arbeit an so interessanter Stelle im Verisoft-Projekt fortsetzen und vertiefen zu konnen.¨ Herrn Wolfgang Pihan und Herrn Dr. Jor¨ g Walter danke ich fur¨ die großzugige¨ Unterstutzung¨ durch IBM, sowie, zusammen mit Frau Dr. Silvia Muller¨ , fur¨ die ursprungliche¨ Idee zu dieser Arbeit. Meiner Freundin Evelyn Becker danke ich fur¨ das aufmerksame und hilfreiche Korrekturlesen dieser fur¨ sie (moglicherweise)¨ sinnfreien Arbeit und fur¨ standige¨ Ermutigung und Ermunterung wahrend¨ der vergangenen Jahre. Danken mochte¨ ich auch meinen (ehemaligen und derzeitigen) Arbeitskollegen, zugleich Freunden, bei der IBM in Boblingen¨ und am Lehrstuhl von Prof. Paul in Saarbruck¨ en. Stellvertretend nenne ich hier meine Zimmerkollegen Markus Braun, Sven Beyer und Thomas In der Rieden. Nicht zuletzt danke ich meinen Freunden Tom Crecelius und Sebastian Schoning,¨ bei denen ich stets Aufnahme und frisch zubereiteten, heißen Tee fand. Die vorliegende Arbeit wurde teilweise von der IBM Entwicklung GmbH (Boblingen)¨ und im Rahmen des Verbundvorhabens Verisoft vom Bundesministerium fur¨ Bildung, Wissenschaft, Forschung und Technologie (BMBF) unter dem Forderk¨ ennzeichen 01 IS C38 gefordert.¨ Die Verantwortung fur¨ den Inhalt dieser Arbeit liegt bei mir. v vi Abstract In modern operating systems tasks operate concurrently on a logical memory. Address spaces control access rights to and the sharing of that memory. They are associated with tasks and manipulated dynamically by memory management operations of the operating system. For cost reasons, logical memory and address spaces are not implemented directly but simulated. The contents of the logical memory are placed in two different mem- ories, the main and the swap memory. Tasks access their address space by using an architecturally defined address translation mechanism, which is implemented by the memory management unit (MMU) and optimized with a translation look-aside buffer (TLB). This mechanism either redirects a memory access to some main memory loca- tion or generates a page fault exception resulting in a call to the page fault handler, a low-level operating system procedure. This construction is correct iff it is transparent to the tasks, so that they behave as if they would operate directly on the logical memory under control of their address spaces. We call the formalization of this correctness criterion a virtual memory simu- lation theorem. In our thesis we formulate and prove such a theorem for an abstract multiprocessor. We apply the theorem to a concrete implementation, a VAMP [BJK+03] with a single- level address translation mechanism and an exemplary page fault handler. We show how to extend the architecture and proofs to support TLBs, multi-level translation, and multiprocessing. Kurzzusammenfassung In modernen Betriebssystemen operieren Programme nebenlaufig¨ auf einem logischen Speicher. Der Zugriff auf diesen Speicher und seine gemeinsame Nutzung wird durch Adressraume¨ geregelt. Diese sind den Programmen zugeordnet und konnen¨ durch Spei- cherverwaltungsoperationen des Betriebssystems dynamisch manipuliert werden. Logischer Speicher und Adressraume¨ werden aus Kostengrunden¨ nicht direkt im- plementiert sondern simuliert. Hierbei verteilen sich die Inhalte des logischen Spei- chers auf zwei verschiedene Speicher, den Haupt- und den Auslagerungsspeicher. Zu- griff auf ihren Adressraum wird den Programmen nur unter Nutzung eines durch die Rechnerarchitektur definierten Adressubersetzungsmechanismus'¨ gewahrt,¨ der durch die Memory Management Unit (MMU) und den Translation Look-Aside Buffer (TLB) implementiert wird. Dieser Mechanismus lenkt einen Zugriff entweder auf eine Haupt- speicheradresse um, oder er erzeugt einen Seitenfehler, der den Aufruf der Seitenfeh- lerbehandlung, eines hardware-nahen Betriebssystemteils, einleitet. Diese Konstruktion ist korrekt, wenn sie fur¨ die Programme transparent ist, das heißt, wenn diese sich mit ihr so verhalten, als griffen sie direkt auf den logischen Speicher unter Kontrolle ihrer Adressraume¨ zu. Die Formalisierung dieser Korrekt- heitsaussage heißt Simulationssatz fur¨ virtuellen Speicher. In der vorliegenden Arbeit formulieren und beweisen wir einen derartigen Satz fur¨ ein abstraktes Mehrprozessorsystem. Wir wenden ihn auf eine konkrete Implementie- rung an, den VAMP [BJK+03] mit einem einstufigen Adressubersetzungsmechanismus¨ und einer exemplarischen Seitenfehlerbehandlung. Wir zeigen, wie Rechnerarchitektur und Korrektheitsbeweise fur¨ die Unterstutzung¨ von TLBs, mehrstufiger Ubersetzung¨ und Mehrprozessorbetrieb erweitert werden konnen.¨ vii Extended Abstract The overall goal of this thesis is to formalize memory and address space models pro- vided by operating systems today and to justify their implementations based on demand paging. This work is divided into two parts. In the first part, we propose a formal, abstract approach to the problem. We develop a model for multitasking with sharing called the relocated memory machine (RMM). In this model, tasks execute concurrently with arbitrary, fair scheduling. Their compu- tation is based on an underlying virtual processor with which they can perform local computation steps and operations on a shared abstract memory. The logical memory, one of its components, serves as a principal data storage. It can be accessed through regular memory operations. These are, however, relocated: the virtual address sup- plied by a task is mapped to a logical address before the operation is performed. Relo- cation thus allows to introduce sharing; two virtual addresses (of two tasks) are shared if their logical addresses are equal. Although relocation already provides simple mem- ory protection, a more fine-grained access control over shared memory regions is de- sirable. Thus, regular memory operations are also subject to a rights check: a memory operation may only be performed (and is then called legal) if it is member of a rights set associated with the virtual address and the task. Collectively, all relocations and rights sets of a certain task are known as its address space. Address spaces form sep- arate components of the shared abstract memory and can be configured dynamically by complex memory operations also called (operating) system calls. To the best of our knowledge, all common address space models and operations can be specified within this model. For cost reasons, the RMM is not implemented directly but simulated. The virtual memory machine (VMM) places the contents of the abstract shared memory in two memories, the main and the swap memory. Its processors run in two different modes. In user mode, a memory operation is subject to address translation: it is either redirected to some main memory location or generates a page fault exception, which makes the processor enter supervisor mode and execute the page fault handler. In the former case, we call the memory operation attached, in the latter detached. While certainly a detached memory operation may be illegal, the typical reason for detachment is that the requested data is stored in swap memory. Hence, the page fault handler loads it to the main memory, updates the address translation accordingly, and returns to user mode where the operation is retried. This strategy is called demand paging [Den70]; it works efficiently if the working sets (locations accessed in a certain time interval) of the user programs fit into the main memory. For the proof of correctness, we proceed in three steps. First, we define a projec- tion function that maps VMM to RMM configurations; it determines the encoding of the logical memory and address spaces. Second, we derive four access conditions; if these hold for an attached and legal memory operation, it is performed equivalently in the VMM and the RMM under the projection function. This result is called step lemma. Third, we derive the runtime conditions that regulate when to attach opera- tions and when not to detach them. For instance: any legal operation,
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages224 Page
-
File Size-