Cl. Cl. ..., V, V, -I..., - QJ d.

Similar documents
Main Points. Address Transla+on Concept. Flexible Address Transla+on. Efficient Address Transla+on

Lecture 13: Address Translation

Page Tables. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

CIS Operating Systems Memory Management Address Translation for Paging. Professor Qiang Zeng Spring 2018

Virtual Memory Oct. 29, 2002

Virtual Memory. Samira Khan Apr 27, 2017

CSE 351. Virtual Memory

Address Translation. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

CS5460: Operating Systems Lecture 14: Memory Management (Chapter 8)

Memory Management Topics. CS 537 Lecture 11 Memory. Virtualizing Resources

Virtual Memory. Motivations for VM Address translation Accelerating translation with TLBs

Virtual Memory Nov 9, 2009"

Systems Programming and Computer Architecture ( ) Timothy Roscoe

virtual memory. March 23, Levels in Memory Hierarchy. DRAM vs. SRAM as a Cache. Page 1. Motivation #1: DRAM a Cache for Disk

Virtual to physical address translation

Virtual Memory. CS 351: Systems Programming Michael Saelee

COSC3330 Computer Architecture Lecture 20. Virtual Memory

18-447: Computer Architecture Lecture 18: Virtual Memory III. Yoongu Kim Carnegie Mellon University Spring 2013, 3/1

Virtual Memory. Motivation:

CISC 360. Virtual Memory Dec. 4, 2008

Chapter 8 Memory Management

Virtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. November 15, MIT Fall 2018 L20-1

Motivations for Virtual Memory Virtual Memory Oct. 29, Why VM Works? Motivation #1: DRAM a Cache for Disk

VIRTUAL MEMORY II. Jo, Heeseung

Computer Architecture Lecture 13: Virtual Memory II

CIS Operating Systems Memory Management Address Translation. Professor Qiang Zeng Fall 2017

P6/Linux Memory System Nov 11, 2009"

Main Memory: Address Translation

Multi-level Translation. CS 537 Lecture 9 Paging. Example two-level page table. Multi-level Translation Analysis

Memory: Page Table Structure. CSSE 332 Operating Systems Rose-Hulman Institute of Technology

Memory System Case Studies Oct. 13, 2008

Virtual Memory 2. q Handling bigger address spaces q Speeding translation

Lecture 13: Virtual Memory Management. CSC 469H1F Fall 2006 Angela Demke Brown

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 24

Learning Outcomes. An understanding of page-based virtual memory in depth. Including the R3000 s support for virtual memory.

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 13: Address Translation

Carnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

CS370 Operating Systems

Learning Outcomes. An understanding of page-based virtual memory in depth. Including the R3000 s support for virtual memory.

Virtual Memory 2. To do. q Handling bigger address spaces q Speeding translation

Virtual Memory: Systems

Chapter 5: Memory Management

Pentium/Linux Memory System March 17, 2005

Administrivia. Lab 1 due Friday 12pm. We give will give short extensions to groups that run into trouble. But us:

Paging. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Virtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. April 12, 2018 L16-1

Virtual Memory 2. Today. Handling bigger address spaces Speeding translation

Virtual Memory. Today. Handling bigger address spaces Speeding translation

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2015 Lecture 23

Chapter 8. Virtual Memory

Computer Systems. Virtual Memory. Han, Hwansoo

Computer Structure. X86 Virtual Memory and TLB

Address Translation. Tore Larsen Material developed by: Kai Li, Princeton University

CS162 Operating Systems and Systems Programming Lecture 12. Address Translation. Page 1

198:231 Intro to Computer Organization. 198:231 Introduction to Computer Organization Lecture 14

Virtual Memory II CSE 351 Spring

CS399 New Beginnings. Jonathan Walpole

Processes and Virtual Memory Concepts

Lecture 19: Virtual Memory: Concepts

PROCESS VIRTUAL MEMORY. CS124 Operating Systems Winter , Lecture 18

Virtual Memory I. Jo, Heeseung

EECS 482 Introduction to Operating Systems

CS162 - Operating Systems and Systems Programming. Address Translation => Paging"

Paging. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

COS 318: Operating Systems. Virtual Memory and Address Translation

Virtual memory Paging

Virtual Memory II. CSE 351 Autumn Instructor: Justin Hsia

Carnegie Mellon. 16 th Lecture, Mar. 20, Instructors: Todd C. Mowry & Anthony Rowe

Virtual Memory, Address Translation

Virtual Memory II. CSE 351 Autumn Instructor: Justin Hsia

Main Memory (Fig. 7.13) Main Memory

Computer Science 146. Computer Architecture

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Fast access ===> use map to find object. HW == SW ===> map is in HW or SW or combo. Extend range ===> longer, hierarchical names

ECE 571 Advanced Microprocessor-Based Design Lecture 12

1. With respect to space, linked lists are and arrays are.

Recap: Memory Management

Main Memory (Part II)

Virtual Memory, Address Translation

Virtual Memory. Kevin Webb Swarthmore College March 8, 2018

14 May 2012 Virtual Memory. Definition: A process is an instance of a running program

Memory Management. An expensive way to run multiple processes: Swapping. CPSC 410/611 : Operating Systems. Memory Management: Paging / Segmentation 1

Memory Management Part 1. Operating Systems in Depth XX 1 Copyright 2018 Thomas W. Doeppner. All rights reserved.

Introduction to Paging

Operating Systems. Paging... Memory Management 2 Overview. Lecture 6 Memory management 2. Paging (contd.)

Portland State University ECE 587/687. Virtual Memory and Virtualization

CS 333 Introduction to Operating Systems. Class 11 Virtual Memory (1) Jonathan Walpole Computer Science Portland State University

Recall: Address Space Map. 13: Memory Management. Let s be reasonable. Processes Address Space. Send it to disk. Freeing up System Memory

CS 4284 Systems Capstone. Virtual Memory Page Tables Godmar Back

CSE 153 Design of Operating Systems

ADRIAN PERRIG & TORSTEN HOEFLER Networks and Operating Systems ( ) Chapter 6: Demand Paging

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 23

How to create a process? What does process look like?

Simple idea 1: load-time linking. Our main questions. Some terminology. Simple idea 2: base + bound register. Protection mechanics.

Views of Memory. Real machines have limited amounts of memory. Programmer doesn t want to be bothered. 640KB? A few GB? (This laptop = 2GB)

Operating Systems (1DT020 & 1TT802) Lecture 9 Memory Management : Demand paging & page replacement. Léon Mugwaneza

Operating Systems. Operating Systems Sina Meraji U of T

Administrivia. - If you didn t get Second test of class mailing list, contact cs240c-staff. Clarification on double counting policy

Chapter 8 Virtual Memory

Virtual Memory. CS61, Lecture 15. Prof. Stephen Chong October 20, 2011

Transcription:

)> Cl. Cl...., m V, V, -I..., QJ :J V, - QJ d. 0 :J

Main Points Address Translation Concept - How do we convert a virtual address to a physical address? Flexible Address Translation I R. lz G.z: f1..t:?z:.mo/2_'-( ON.s OF V,I a.. TU AL - Segmentation --k_ LvMPL lz?< MF=f1 MGT - Paging _r= L}: NS Afl.. C ()\JJ- (la6 Sz. D ~ /J, DD f?_i;.ss (_ - i3ad {? 0 /l.. sfaflsr'z A()O/l~SS u~ag~ - Multilevel translation ~,f ~c~ Efficient Address Translation IS o,h - C & p '-( o/\j W/L 2 i ~ - Translation Lookaside Buffers 5 Z-AC:: I( G (l_o~t ~l - Virtually and physically addressed caches l. DA O ON i) G. MANO

Address Translation Concept Mrtu Virtual Address Processor l >I Translation I Invalid Raise. Exception ~ Valid Data "" ~ > Physical Address Physical Memory... Data

(_'[tj fz.arl p AC:. r-z Tl\ r'1 L fz S Beyond Paging: Sparse Address Spaces Might want many separate segments - Per-processor heaps - Per-thread stacks - Memory-mapped files - Dynamically linked libraries What if virtual address space is large? - 32-bits, 4KB pages=> SOOK page table entries - 64-bits => 4 quadrillion page table entries

Multi-level Translation Tree of translation tables - Paged segmentation - Multi-level page tables - Multi-level paged segmentation All have pages as lowest level; why?

Multilevel Translation with Pages at Lowest Level Efficient memory allocation (vs. segments) Efficient for sparse addresses (vs. 1 level paging) Efficient disk transfers (fixed size units) Easier to build translation lookaside buffers Efficient reverse lookup (from physical -> virtual) Variable granularity for protection/sharing Cc.)/t Si_ 11Af Except: see discussion of superpages

Paged Segmentation Process memory is segmented Segment table entry: - Pointer to page table - Page table length {# of pages in segment) - Access permissions Page table entry: - Page frame - Access permissions (~,,~t )(~ 6 -:1 '2... l:,,-._ x 8'b < r'-:-"-+1 ~ -z_ ( ~c,.,c. ( PT) Share memory or set access permissions at either page or segment-level

v: r+,_( -f,()o{l ----- ('11-.., I"'""-'-( t_. 5-f-i_c({ 1<~ ~' ~~~ -r~ ;,-,_ Processor )' ~( ~ ~'"3l. ~jl- ~~ -Z.- Si-s.-v.t- fe.,.. /"3 Implementation ; f--i Li-; ~ t..s Ct>~ (' t-,,..- --~\ Virtual, 1 Address J C ~ _., \ )..-p_.r It) c.f~r ~\ -- : \...----./---...----. I I :........ -.. ~ Segment/ Page Offset... - ( -:. L.......... ~...... > Exception... Segme~t Table Page Table c~... ~-............................................................... r::.. ':':I.... ~.s"~ Page Table Frame Access \ Read ' Size Access Read Physical... >... Read Address...... R/W R/W R/W... ""... ->I Frame I Offset 1........ > Physical Memory

Question With paged segmentation, what must be saved/restored across a process context switch? \

Multi-level or hierarchical page tables ~7 ~lv,x~b Ex: 2-level page table - Level 1 table: each PTE points to a page table - Level 2 table: each PTE. points to a page Can share/protect/page in/out at either level 1 or level 2 L4-"~( \ t~_,t.( 't. ½ (( ~ Level 1 Table. Level2 Tables?_H/3 I { 0 (0 O~'S ~+ ~-z_ ~,1 \ (.. ~' ~~

Implementation Physical Memory Processor Virtual Address >I Index 1 I Index 2 I Index 3 I Offset ] : Physical j Level 1 Address l Iii : ~ t-------1 Frame I Offset ]... ~ I I... Level 2 :. >.-------. : > -------1 Level 3 ---- > t---------1

x86 Multilevel Paging, Omit sub-tree if no valid addresses - Good for sparse address space 4KB pages Each level of page table fits in one page 32-bit: two level page table (per segment) 64-bit: four level page table (per segment)

x86-32 Paging 10 10 12 I VPN3 I VPN4 I VPO I -- -, _ - "',---", l i Virtual address Page Directory Page Table i ' ~ PDE ~ ~ PTE =... -- CR3 -,c=..... i.. 20 l 12 ' I PPN I PPO I cal address,.. - -

x86-64 Paging 16 9 l VPN1 --= - ". -- - 7 - i l - - -.. -,-;.. - -,..;c, 9 9 9 VPN2 I VPN3 I VPN4 I. - -,i' " ---- -------- - ----,------------- -----,-.,;-:-':...,,_ - -..,-.-...-; Page 12 VPO Virtual address --- " -------- ----;...C,.,,,.;.. -I Page Map Level4 Directory Pointer Table Page Directory Page Table l ' L\ '?5 b rt S o \ v-:, tu.j A O 0) R.~ ~<; CR3 ~ PM4LE.;... PDPE..... PDE.,... PTE. -- ' ---- --- ~ - -~ -- L...i s. I I:. TC3 s~...rv~ 8 I 36 i 12 PPN l PPO I cal address ~l < b ~ 0 <?- ~k, ~~~J 4\-O0aJiSS 7-S t 1 (s

Page table entries (x86 32 bit) f"'\o O L ri ~ Ji O 0 -: f?_ty A cce_ s<; ( tj.s ~ S \1-J Empty Ignored 0 4KB page Bits 31:12 of address of page frame lgn l GI O Pl Pl UR / /I 1 f '-Y? '\-r~---- 'l. t:i. l\~" ~re\ I ;Ave.(~& ~,e. ( S/o') Cc_ Cl, C. W i-+ ~ {_ I/0 ) "'r ~ ( s"7" s +~,...+ (LAM -ft.eo vs f \1/ us~ r / 5 u f<?...rv:sor \!') \ <!..... ll -w r,-{ ' d\ t"'e. ~~ - 01\. \y

Page directory e. 5 (x86 32 bit) \/fl '-1, 9 6 - us~ Q:.:rT G, Empty Ignored 0 4MB page Bits 31:22 of address of 4MB page frame 0 lgn Pl Pl UR / /I 1 Page table Bits 31:12 of address of page table cac\--\~~ 0 '1:,S A- ~LVZ- c_-r:.,/ o) lgn I ol g n ~)R c--------~= ------(---/ ~,)\,'{ w r~t e.. *(bu,~ [--s/o'> ~ e (t,,#., O r,1 v-z ~ ', ;,;_'r~ '7),, ~y \)',e.,( o 90~ Dr) (,v v

Small page translation CR3 register Address of page directory SBZ Virtual address PDE index PTEindex Offset Address of PDE Address of page directory PDE Page table base address Note: addresses in physical memory! Address of PTE Page table base address PTE Small page base address Access control 11 Physical address Small page base address Offset

Page table for small pages Base address 1024 entries 4kB 4kB page 1024 entries 4kB Translates VA[21:12] Page table 4kB page Page director VA[ll:O] = offset in page Translates VA[31:22] Page table

Question Write pseudo-code for translating a virtual address to a physical address for a system using 3-level paging, with 8 bits of address per level p TI) r ADt>«. '>'> ;lli J I p ( LA l)pe_ '> ">,~ g_ Ox~]

x86 Multilevel Paged Segmentation Global Descriptor Table (segment table) Each segment descriptor - Pointer to (multilevel) page table - Segment length - Segment access permissions Context switch - change global descriptor table register (GDTR), pointer to global descriptor table - Side effect: invalidates TLB

Multilevel Translation Pros: - Allocate/fill only page table entries that are in use - Simple memory allocation - Share at segment or page level Cons: - Space overhead: one pointer per virtual page - Multip le lookups per memory reference

Page Translation in the OS OS's need to keep their own data structures - List of memory objects (segments) - Virtual page-> physical page frame - Physical page frame-> set of virtual pages - Keep track of copy on write, load on demand,... Why not just use the hardware page tables?

Kernel Page Translation Kernel maintains its own page translation data structures - Portable, flexible - Copy changes down into hardware page tables Example: Inverted page table - Hash from virtual page-> physical page - Space proportional to# of physical pages Example: virtual/shadow page table - Linux kernel tables mirror x86 structure, even on ARM