Memory Addressing in Linux (Chap. 2, Understanding the Linux Kernel) J. H. Wang Oct. 20, 2008.

Slides:



Advertisements
Similar presentations
Memory Management Unit
Advertisements

Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU
Computer Organization and Assembly Languages Yung-Yu Chuang
FEATURES OF 80386: Two versions of are commonly available: 1) 80386DX
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.
Intel MP.
IA32 Paging Scheme Introduction to the Pentium’s support for “virtual” memory.
1 Linux Operating System 許 富 皓. 2 Sharing Process Address Space Reduce memory usage (e.g. editor.) Explicitly requested by processes (e.g. shared memory.
演算法在 Linux 作業系統上之應用 Algorithm Applications in Linux Operating System CE6100 許 富 皓.
UQC152H3 Advanced OS Memory Management under Linux.
IA-32 Processor Architecture
Vacuum tubes Transistor 1948 ICs 1960s Microprocessors 1970s.
1 Hardware and Software Architecture Chapter 2 n The Intel Processor Architecture n History of PC Memory Usage (Real Mode)
X86 segmentation, page tables, and interrupts 3/17/08 Frans Kaashoek MIT
Chapter 8.3: Memory Management
Memory Management (II)
CE6105 Linux 作業系統 Linux Operating System 許 富 皓. Chapter 2 Memory Addressing.
Vacuum tubes Transistor 1948 –Smaller, Cheaper, Less heat dissipation, Made from Silicon (Sand) –Invented at Bell Labs –Shockley, Brittain, Bardeen ICs.
CS2422 Assembly Language & System Programming September 22, 2005.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 2: 80386DX Internal Architecture & Data Organization.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Fall 2012 Lecture 15: Protected mode intro.
Protected Mode. Protected Mode (1 of 2) 4 GB addressable RAM –( to FFFFFFFFh) Each program assigned a memory partition which is protected from.
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.
UNIT 2 Memory Management Unit and Segment Description and Paging
Intel MP (32-bit microprocessor) Designed to overcome the limits of its predecessor while maintaining the software compatibility with the.
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.
Computer Architecture Lecture 5: Addressing modes Piotr Bilski.
The Pentium Processor.
The Pentium Processor Chapter 3 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
The Pentium Processor Chapter 3 S. Dandamudi.
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.
CS 6560 Operating System Design Lecture 8: Memory Management.
CSC 660: Advanced Operating SystemsSlide #1 CSC 660: Advanced OS Memory Addressing / Kernel Modules.
1 Linux Operating System 許 富 皓. 2 Memory Addressing.
Paging Example What is the data corresponding to the logical address below:
80386DX.
Memory Addressing in Linux (Chap. 2 in Understanding the Linux Kernel) J. H. Wang Oct. 15, 2009.
1 i386 Memory Management Professor Ching-Chi Hsu 1998 年 4 月.
The Microprocessor and Its Architecture A Course in Microprocessor Electrical Engineering Department University of Indonesia.
EFLAG Register of The The only new flag bit is the AC alignment check, used to indicate that the microprocessor has accessed a word at an odd.
Microprocessor system architectures – IA32 tasks Jakub Yaghob.
Memory Addressing 09 October 2015.
1 Linux Operating System Kernel 許 富 皓. 2 Sharing Process Address Space Reduce memory usage  e.g. editor. Explicitly requested by processes  e.g. shared.
1 Microprocessors CSE Protected Mode Memory Addressing Remember using real mode addressing we were previously able to address 1M Byte of memory.
Page Replacement Implementation Issues Text: –Tanenbaum ch. 4.7.
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.
Information Security - 2. Descriptor Tables There are two descriptor tables – Global Descriptor Tables – Local Descriptor Tables The global descriptor.
Information Security - 2. Descriptor Tables Descriptors are stored in three tables: – Global descriptor table (GDT) Maintains a list of most segments.
Microprocessor system architectures – IA32 paging Jakub Yaghob.
EEL 4709C Prof. Watson Herman Group 4 Ali Alshamma, Derek Montgomery, David Ortiz 11/11/2008.
Microprocessor Architecture
Lecture on Real Mode Memory Addressing
Descriptor Table & Register
16.317: Microprocessor System Design I
Microprocessor Systems Design I
Address Translation Mechanism of 80386
143A: Principles of Operating Systems Lecture 5: Address translation
x86 segmentation, page tables, and interrupts
Page Replacement Implementation Issues
Virtual Memory Partially Adapted from:
Operating Modes UQ: State and explain the operating modes of X86 family of processors. Show the mode transition diagram highlighting important features.(10.
Page Replacement Implementation Issues
Introduction to the Intel x86’s support for “virtual” memory
Linux 운영체제 및 응용 Lecture Note 2 Memory Addressing 오상규 정보통신대학원.
Introduction to the Pentium’s support for “virtual” memory
Linux 운영체제 및 응용 Lecture Note 2 Memory Addressing 오상규 정보통신대학원.
CS444/544 Operating Systems II Virtual Memory
Presentation transcript:

Memory Addressing in Linux (Chap. 2, Understanding the Linux Kernel) J. H. Wang Oct. 20, 2008

Outline Memory Addresses Segmentation in Hardware Segmentation in Linux Paging in Hardware Paging in Linux

Memory Addresses 3 kinds of addresses in 80x86 microprocessors – Logical address Included in the machine language instructions – Linear address ( virtual address ) A single 32-bit unsigned integer that can be used to address up to 4GB – Physical address (32-bit unsigned integers) Used to address memory cells in memory chips

Segmentation in Hardware Logical address –Segment id: 16-bit (Segment Selector) –Offset: 32-bit Segmentation registers –To hold segment selectors –cs: code segment –ss: stack segment –ds: data segment –es, fs, gs: general purpose

Segment descriptors: 8-byte –Stored either in GDT (global descriptor table) or in LDT (local descriptor table) –Processor registers gdtr, ldtr Fields in segment descriptor –base: 32-bit –G granularity flag: (segment size in bytes or 4KB) –Limit: 20-bit –S system flag: (system segment or not) –Type: 4-bit Code, Data, Task Sate (TSSD), Local Descriptor Table (LDTD)

–DPL (descriptor privilege level): 2-bit –Segment-present flag: (in memory or not) –D or B flag: (depending on code or data) –Reserved bit (bit 53): 0 –AVL flag: ignored by Linux

Segment Descriptor Format

Fast Access to Segment Descriptors For each of the six programmable segmentation registers, 80x86 provides an additional nonprogrammable register, which is loaded every time a segment selector is loaded in a segment register –Without accessing the GDT or LDT in memory

Segment Selector and Segment Descriptor

Segmentation Unit

Segmentation in Linux Limited Linux prefers paging to segmentation –Memory management is simpler –Portability to wide range of architectures such as RISC GDT: array gdt_table LDT: not used by the kernel –modify_ldt() system call

Segments used by Linux –Kernel code segment: __KERNEL_CS macro –Kernel data segment: __KERNEL_DS macro –User code segment: __USER_CS macro –User data segment: __USER_DS macro –Task state segment (TSS): init_tss array –A default LDT: default_ldt –4 segments: related to APM (Advanced Power Management) support

Paging in Hardware In 80x86 processors, paging is enabled by setting the PG flag of control register cr0 –4KM pages –Linear address: 32-bit Directory: 10 bits Table: 10 bits Offset: 12 bits

Paging by 80x86 Processors

Entries of page directories and page tables –Present flag: in memory –20-MSB of a page physical address –Accessed flag –Dirty flag: applies only to page table entries –Read/write flag –User/supervisor flag –PCD and PWT flag –Page size flag –Global flag

Extended Paging

Page size: 4MB Linear address: 32 bits –Directory: 10 bits –Offset: 22 bits Hardware protection scheme –Only two privilege levels: by usr/supervisor flag –Only two types of access rights: by read/write flag

An Example of Paging

Three-Level Paging For 64-bit architectures –Ex: Alpha architecture by HP Offset: 13 bits 21 MSB: bit fields

Physical Address Extension (PAE) Paging Mechanism Starting with Pentium Pro, the number of address pins are increased to 36 –Up to 64GB RAM –PAE is activated by setting the PAE flag in cr4 control register –(see p.51)

Hardware Cache (see p ) TLB: Translation Lookaside Buffers

Paging in Linux

When three-level paging is applied to Pentium, –Linux eliminates the Page Middle Directory field With PAE, –Page Global Directory: x86’s Page Directory Pointer Table –Page Middle Directory: x86’s Page Directory –Page Table: x86’s Page Table

Macros for simplifying page table handling: –PAGE_SHIFT, PMD_SHIFT, PGDIR_SHIFT, PTRS_PER_PTE, PTRS_PERPMD, PTRS_PER_PGD Data structures for page table handling –pte_t, pmd_t, pgd_t –pgprot_t Macros for page table handling: –Macros: __pte(), __pmd(), __pgd(), __pgprot() –Macros: pte_val(), pmd_val(), pgd_val(), pgprot_val()

–Pte_none(), pmd_none(), pgd_none() –Pte_present(), pmd_present(), pgd_present() –Pte_clear(), pmd_clear(), pgd_clear() –Macros: pmd_bad(), pgd_bad() –Functions: pte_read(), pte_write(), pte_exec(), pte_dirty(), pte_young(), –Functions: pte_wrprotect(), pte_rdprotect(), pte_exprotect(), pte_mkwrite(), pte_mkread(), pte_mkexec(), pte_mkdirty(), pte_mkclean(), pte_mkyound(), pte_mkold(), pte_modify(p,v), set_pte, set_pmd, set_pgd –… (see pp )