Virtual Memory on x86. Virtual Memory Refresher Problems with using raw memory: – Isolation Protect system and programs from other programs Two programs.

Slides:



Advertisements
Similar presentations
Project 5: Virtual Memory
Advertisements

Memory Management Unit
1 Overview Assignment 4: hints Memory management Assignment 3: solution.
SE-292: High Performance Computing
Virtual Memory In this lecture, slides from lecture 16 from the course Computer Architecture ECE 201 by Professor Mike Schulte are used with permission.
1 Memory hierarchy and paging Electronic Computers M.
16.317: Microprocessor System Design I
4/14/2017 Discussed Earlier segmentation - the process address space is divided into logical pieces called segments. The following are the example of types.
Lecture 34: Chapter 5 Today’s topic –Virtual Memories 1.
OS Memory Addressing.
Memory/Storage Architecture Lab Computer Architecture Virtual Memory.
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
Memory Management (II)
Computer ArchitectureFall 2008 © November 10, 2007 Nael Abu-Ghazaleh Lecture 23 Virtual.
Computer ArchitectureFall 2007 © November 21, 2007 Karem A. Sakallah Lecture 23 Virtual Memory (2) CS : Computer Architecture.
CE6105 Linux 作業系統 Linux Operating System 許 富 皓. Chapter 2 Memory Addressing.
Translation Buffers (TLB’s)
Virtual Memory. Why do we need VM? Program address space: 0 – 2^32 bytes –4GB of space Physical memory available –256MB or so Multiprogramming systems.
Virtual Memory and Paging J. Nelson Amaral. Large Data Sets Size of address space: – 32-bit machines: 2 32 = 4 GB – 64-bit machines: 2 64 = a huge number.
©UCB CS 161 Ch 7: Memory Hierarchy LECTURE 24 Instructor: L.N. Bhuyan
11/10/2005Comp 120 Fall November 10 8 classes to go! questions to me –Topics you would like covered –Things you don’t understand –Suggestions.
Virtual Memory By: Dinouje Fahih. Definition of Virtual Memory Virtual memory is a concept that, allows a computer and its operating system, to use a.
Virtual Memory Main Memory Magnetic Disk Upper level Lower level.
80386DX.
Operating Systems Chapter 8
8.4 paging Paging is a memory-management scheme that permits the physical address space of a process to be non-contiguous. The basic method for implementation.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
1 Linux Operating System 許 富 皓. 2 Memory Addressing.
1 Virtual Memory Main memory can act as a cache for the secondary storage (disk) Advantages: –illusion of having more physical memory –program relocation.
Review °Apply Principle of Locality Recursively °Manage memory to disk? Treat as cache Included protection as bonus, now critical Use Page Table of mappings.
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
Virtual Memory Ch. 8 & 9 Silberschatz Operating Systems Book.
CHAPTER 3-3: PAGE MAPPING MEMORY MANAGEMENT. VIRTUAL MEMORY Key Idea Disassociate addresses referenced in a running process from addresses available in.
Virtual Memory Review Goal: give illusion of a large memory Allow many processes to share single memory Strategy Break physical memory up into blocks (pages)
LECTURE 12 Virtual Memory. VIRTUAL MEMORY Just as a cache can provide fast, easy access to recently-used code and data, main memory acts as a “cache”
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
OS Memory Addressing. Architecture CPU – Processing units – Caches – Interrupt controllers – MMU Memory Interconnect North bridge South bridge PCI, etc.
The Memory Hierarchy Lecture 31 20/07/2009Lecture 31_CA&O_Engr. Umbreen Sabir.
Computer Architecture Lecture 12: Virtual Memory I
CS161 – Design and Architecture of Computer
Memory Hierarchy Ideal memory is fast, large, and inexpensive
Memory Management Virtual Memory.
CS161 – Design and Architecture of Computer
Lecture 12 Virtual Memory.
Modeling Page Replacement Algorithms
Virtual Memory Use main memory as a “cache” for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs share main.
Address Translation Mechanism of 80386
Morgan Kaufmann Publishers
CSE 153 Design of Operating Systems Winter 2018
Lecture 28: Virtual Memory-Address Translation
Virtual Memory 4 classes to go! Today: Virtual Memory.
Module IV Memory Organization.
Main Memory Background Swapping Contiguous Allocation Paging
CS399 New Beginnings Jonathan Walpole.
Modeling Page Replacement Algorithms
Introduction to the Intel x86’s support for “virtual” memory
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
CSE 451: Operating Systems Autumn 2005 Memory Management
Translation Buffers (TLB’s)
CSE451 Virtual Memory Paging Autumn 2002
Translation Buffers (TLB’s)
Computer Architecture
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CSE 471 Autumn 1998 Virtual memory
CSE 153 Design of Operating Systems Winter 2019
Translation Buffers (TLBs)
Review What are the advantages/disadvantages of pages versus segments?
Lecture Topics: 11/20 HW 7 What happens on a memory reference Traps
Virtual Memory 1 1.
Presentation transcript:

Virtual Memory on x86

Virtual Memory Refresher Problems with using raw memory: – Isolation Protect system and programs from other programs Two programs want to write to the same address – Programs need more memory than was available Solutions – Segmentation – Paging

Segmentation Divides memory into segments Can offer isolation between segments – Protects system and programs from external access – Raises hardware exception on invalid access: segmentation fault

Paging Disk can be used to extend memory beyond physical memory capacity Virtual Addresses fake addresses which translate to physical addresses Requires translation: page tables are needed Provides unique translations for each program Image from Wikipedia

Page Tables Provide translation from virtual to physical memory addresses Register points to base of current programs table Part of the virtual address is used to index the table, which has the following for each entry: – Various bits representing access and usage – Index of another table or physical memory pages

Page Fault What happens when a program attempts to access a virtual address when the corresponding physical page is not present in memory? – Trap and attempt to make the physical address available Find a free page Replace an old page with the new page What if the page isnt found? – Trap again Invalid page fault Code usually terminated

Memory on x86 Modern x86 supports 3 memory models: – Allows use of paging – supports 4KB and 4MB page sizes – Segmentation – Flat Model – direct mapping (no virtual memory) x86_64 – Did away with segmentation (mostly) – Extended the virtual memory space from 4GB (ignoring PAE) to 16EB (exa-bytes) – Added another level of page tables

Paging Specifics for x86 x86 has a 3 level paging hierarchy: – Page directory – the topmost table – Page table – the intermediate table (when using 4KB pages) – Pages – 4KB or 4MB contiguous blocks of memory x86_64 supports additional modes: – Long mode includes a 4 level hierarchy Supports additional physical memory space – Additional control bits – such as No Execute

4kb Paging on x86 Image from Wikipedia

Paging Registers CR0 controls various aspects, such as enabling or disabling paging, caching, write-through and more. CR2 contains the virtual address responsible for a page fault The upper 20 bits of the CR3 register become the Page Directory Base Register (PDBR), which stores the address of the first page directory entry.

x86 Page Directory Entries x86s top level table 4MB mode – 10 most significant bits for indexing pages – Next 10 bits reserved – Remaining 12 bits set permissions and functionality as well as marking accesses and dirtiness 4KB mode – 20 most significant bits for indexing the page table – Remaining 12 bits set permissions and functionality as well as marking accesses

x86 Page Table Entries Used only in x86s 4KB paging 20 most significant bits for indexing pages Remaining 12 bits set permissions and functionality as well as marking accesses and dirtiness

Page Faults on x86 Page faults will throw an interrupt Handled like all procedure calls, exceptions, and interrupts – Push relevant registers to stack, push error code – Load/clear relevant registers – Run handler

PAE Feature allowing x86 to handle up to 36-bit physical addresses – Allows for up to 64GB of virtual memory – Still only uses 32-bit virtual addresses, so individual processes can only use 4GB of memory Due to additional addresses in the page directory and page table, CR3 must point to a higher level table, which contains 4 page directory tables.

X86 Resources nces/IA32-ref-manual-vol-1.pdf nces/IA32-ref-manual-vol-2a.pdf nces/IA32-ref-manual-vol-2b.pdf nces/IA32-ref-manual-vol-3.pdf