IA32 Paging Scheme Introduction to the Pentium’s support for “virtual” memory.

Slides:



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

Memory Management: Overlays and Virtual Memory
Memory Management Unit
Using VMX within Linux We explore the feasibility of executing ROM-BIOS code within the Linux x86_64 kernel.
Paging Hardware With TLB
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.
Linux ‘Demand-Paging’
IA32 Paging Scheme Introduction to the Pentium’s support for “virtual” memory.
Introduction to the Intel x86’s support for “virtual” memory
Misc Exercise 2 updated with Part III.  Due on next Tuesday 12:30pm. Project 2 (Suggestion)  Write a small test for each call.  Start from file system.
IA32 Paging Scheme Introduction to the Intel x86’s support for “virtual” memory.
Linux Memory Issues An introduction to some low-level and some high-level memory management concepts.
UQC152H3 Advanced OS Memory Management under Linux.
A look at memory issues Data-transfers must occur between system memory and the network interface controller.
Standard C Libraries Application Programmming Interface to System-Calls.
X86 segmentation, page tables, and interrupts 3/17/08 Frans Kaashoek MIT
Memory Management (II)
Linux Vs. Windows NT Memory Management Hitesh Kumar
IA32 Paging Scheme Introduction to the Pentium’s support for “virtual” memory.
“Virtual” Memory How does the OS kernel provide “private” and “shared” memory areas to multiple concurrent processes?
CE6105 Linux 作業系統 Linux Operating System 許 富 皓. Chapter 2 Memory Addressing.
Informationsteknologi Friday, November 16, 2007Computer Architecture I - Class 121 Today’s class Operating System Machine Level.
Linux Memory Issues Introduction. Some Architecture History 8080 (late-1970s) 16-bit address (64-KB) 8086 (early-1980s) 20-bit address (1-MB) (mid-’80s)
The kernel’s task list Introduction to process descriptors and their related data-structures for Linux kernel version
Managing physical memory
Rapid prototyping of LKMs Configuring our Linux systems for the quick creation and use of loadable kernel modules.
Venturing into 64-bit mode Examining the steps needed to take the processor into IA-32e mode -- and then back out again.
Looking at kernel objects How a character-mode Linux device driver can be useful in viewing a ‘net_device’ structure.
A device-driver for Video Memory Introduction to basic principles of the PC’s graphics display.
Access to High Memory Introduction to the kernel functions ‘kmap()’ and ‘kunmap()
Introduction to the Intel x86’s support for “virtual” memory
Linux Memory Management How does the Linux kernel keep track of the Virtual Memory Areas that each process uses?
The ‘zero-copy’ initiative A look at the ‘zero-copy’ concept and an x86 Linux implementation for the case of outgoing packets.
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
Memory Management in Windows and Linux &. Windows Memory Management Virtual memory manager (VMM) –Executive component responsible for managing memory.
Memory Management Ch.8.
Address Translation Mechanism of 80386
Memory Addressing in Linux  Logical Address machine language instruction location  Linear address (virtual address) a single 32 but unsigned integer.
CSNB334 Advanced Operating Systems 5. Memory Management
Linux Virtual Memory for Intel Processor
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.
Laface Operating System Design Booting a PC to run a kernel from Low memory VGA display.
1 Linux Operating System 許 富 皓. 2 Memory Addressing.
Memory Addressing in Linux (Chap. 2, Understanding the Linux Kernel) J. H. Wang Oct. 20, 2008.
Computer Architecture 2011 – VM x86 1 Computer Architecture Virtual Memory (VM) – x86 By Dan Tsafrir, 30/5/2011 Presentation based on slides by Lihu Rappoport.
Topic 2d High-Level languages and Systems Software
Paging Example What is the data corresponding to the logical address below:
Computer Structure 2012 – VM 1 Computer Structure X86 Virtual Memory and TLB Franck Sala Slides from Lihu and Adi’s Lecture.
1 Memory Management (b). 2 Paging  Logical address space of a process can be noncontiguous; process is allocated physical memory whenever the latter.
1 Virtual Memory Main memory can act as a cache for the secondary storage (disk) Advantages: –illusion of having more physical memory –program relocation.
80386DX.
Introduction: Memory Management 2 Ideally programmers want memory that is large fast non volatile Memory hierarchy small amount of fast, expensive memory.
Memory Management: Overlays and Virtual Memory. Agenda Overview of Virtual Memory –Review material based on Computer Architecture and OS concepts Credits.
10. Epilogue ENGI 3655 Lab Sessions.  We took control of the computer as early as possible, right after the end of the BIOS  Our multi-stage bootloader.
Lecture 14 PA2. Lab 2: Demand Paging Implement the following syscalls xmmap, xmunmap, vcreate, vgetmem/vfreemem, srpolicy Deadline: November , 10:00.
Silberschatz, Galvin and Gagne  Operating System Concepts Paging Logical address space of a process can be noncontiguous; process is allocated.
Microprocessor system architectures – IA32 paging Jakub Yaghob.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 4.
Linux Boot Process on the Raspberry Pi 2 1 David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis,
8.1 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Example: The Intel 32 and 64-bit Architectures Dominant industry chips.
Chapter 2: The Linux System Part 4
COMBINED PAGING AND SEGMENTATION
Address Translation Mechanism of 80386
Introduction to the Intel x86’s support for “virtual” memory
Introduction to the Pentium’s support for “virtual” memory
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Computer System Structures
Assembly Language for Intel-Based Computers, 5th Edition
Presentation transcript:

IA32 Paging Scheme Introduction to the Pentium’s support for “virtual” memory

A quick review We’ve learned how to create ‘/proc’ files We wrote a simple device-driver: ‘dram.c’ We displayed a task’s page-directory We looked at Linux’s ‘mem_map[]’ array Now we want to understand the ‘kmap()’ function, used by modules to get a virtual address for any physical page-frame

‘Traditional’ Linux User space Virtual addresses Kernel space NORMAL MEMORY HIGH MEMORY Physical addresses 0x x (896MB) Most of the kernel’s 1GB address-space is directly mapped to physical RAM at all times 1G 3G But mappings to the ‘high memory’ page-frames are, by definition, only temporarily available and are not mapped according to a predictable rule

How ‘mappings’ work There are two aspects to consider: –the Pentium’s address-translation mechanism –the policies Linux applies to CPU capabilities Example of this distinction: –The ‘page-directory’ array is a Pentium object –The ‘mem_map’ array is a Linux data-object

Control Register PAEPAE PSEPSE 45 This register consists of bits that enable various architectural extensions to the standard features of the Pentium processor, including two that affect virtual-to-physical memory mapping. Legend: PSE = Page-Size Extensions (1=enabled, 0=disabled) PAE = Page-Address Extensions (1=enabled, 0=disabled) Recall that we saw our classroom workstations had CR4 = D0

Two-Level Translation Scheme PAGE DIRECTORY CR3 PAGE TABLES PAGE FRAMES

Control Register 3 PWTPWT PCDPCD Page-directory base-address PWT = Page Write-Through (1=yes, 0 = no) PCD = Page Cache-Disable (1 = yes, 0 = no) The ‘page-directory base-address’ field holds the upper 20 address-bits of a physical page-frame that contains the current task’s page-directory entries; the lower 12 address-bits of any page-frame are zeros, of course, so can be used by the processor for other purposes (i.e., PCD [bit 4] and PWT [bit 3]:

Your ‘/proc/cr3’ pseudo-file Recall that you created a kernel module (named ‘cr3.c’) which allows applications to obtain the current value in register CR3 This CR3 value gives the physical address for the current task’s page-directory, if the ‘traditional’ 3G/1G user-kernel mapping is employed (but not with the 4G/4G “patch”) Using ‘fileview’ you saw a page-directory!

Format of a Page-Directory entry PAGE-TABLE BASE ADDRESSPWU PWTPWT PCDPCD A0 PSPS G AVAIL LEGEND P = Present (1=yes, 0=no) W = Writable (1 = yes, 0 = no) U = User (1 = yes, 0 = no) A = Accessed (1 = yes, 0 = no) G = Global (1 = yes, 0 = no) PWT = Page Write-Through (1=yes, 0 = no) PCD = Page Cache-Disable (1 = yes, 0 = no) PS = Page-Size (0=4KB, 1 = 4MB)

Format of a Page-Table entry PAGE-FRAME BASE ADDRESSPWU PWTPWT PCDPCD AD0G AVAIL LEGEND P = Present (1=yes, 0=no) W = Writable (1 = yes, 0 = no) U = User (1 = yes, 0 = no) A = Accessed (1 = yes, 0 = no) D = Dirty (1 = yes, 0 = no) G = Global (1 = yes, 0 = no) PWT = Page Write-Through (1=yes, 0 = no) PCD = Page Cache-Disable (1 = yes, 0 = no)

kernel mappings The ‘kmap()’ function is used by modules to obtain the virtual address for a physical page-frame: void * kmap( struct page * page ); On systems with 1GB of installed memory, the majority of physical page-frames are permanently mapped to kernel addresses, but page-frames in ‘high’ memory can only be ‘temporarily’ mapped into kernel space

Normal page-mapping For a virtual address in kernel space that is below the high-memory start-address, the corresponding physical address can be gotten by a simple subtraction: phys_addr = virt_addr – PAGE_OFFSET Recall: PAGE_OFFSET = 0xC

Mapping ‘high’ memory For addresses in kernel space in the range from 0xF to 0xFFFFFFFF there might be no current mapping to ram So the action of the ‘kmap()’ function must be more complex in these cases (i.e., it’s necessary to create a temporary mapping if it happens one does not already exist)

A limited number of kmaps In kernel 2.6 there is only one page-table that is reserved for ‘kmap()’ to use when temporary mappings into high-memory need to be created This is called the ‘kmap_page_table’ Its page-table entries are forever changing as kernel code calls the functions ‘kmap()’ and ‘kunmap()’

PKMAP_BASE We can watch the ‘kmap_page_table’ as it undergoes these dynamic changes – if we know where to find it in physical memory We can do a ‘page-table walk’ to locate it There are 1024 virtual page-frames used for temporary ‘kmap()’ addresses, starting with the virtual address PKMAP_BASE

In-class exercise #1 Use the ‘init_mm.c’ module to locate the page-directory belonging to the ‘init’ task Use ‘fileview’ to see these directory entries Determine the value of PKMAP_BASE Which directory-entry contains the address of the ‘pkmap_page_table’? (It’s the entry that ‘maps’ virtual-address PKMAP_BASE to a page-frame in physical memory)

In-class exercise #2 Use the result from your ‘page-table walk’ to assign the correct value to ‘zone_base’ in our ‘kmapsnow.cpp’ demo-program Run the ‘kmapsnow’ in one window while you execute some other commands from inside a different window, to view changes in the set of currently active kmaps Log in remotely from an adjacent station