• Windows 2000 Page Based Memory Management


     

    Author: JIURL

                   Home: http://jiurl.yeah.net

        Date: 2005-06-02


    1 Basic Concept

    Windows 2000 uses a page-based virtual memory management. In windows 2000 system, for 32-bit CPU, every process has its own 4GB address space. All addresses used in process are all virtual address.

    Virtual address is a address in process's address space. All addresses used in program are all virtual address. Physical address is the address which is placed on the address bus to address the physical memory. The addresses used by accessing physical memory are all physical addresses. Virtual address is not physical address. Executing a accessing ( read, write, execute ) memory instruction, according to paging mechanism, CPU will automatically translate the virtual address to physical address, and complete the accessing to physical memory.

    For example:

    00401028 nop 
    00401029 mov eax,[GlobalVar1 (00427e34)]

    The address of the instruction "nop" is 00401028, is a virtual address.
    The address of the instruction "mov eax,[GlobalVar1 (00427e34)]" is 00401029, is a virtual address.
    In instruction "mov eax,[GlobalVar1 (00427e34)]", the address of "GlobalVar1" is 00427e34, is a virtual address.

    When these instructions are executed by CPU, CPU will automatically translate the virtual address to physical address, access the physical memory, get instruction or data, to execute the instruction.

    In windows 2000 system, for 32-bit CPU, no matter how much physical memory have, every process has its own 4GB address space, 0x00000000-0xFFFFFFFF. Basing paging mechanism, in 4GB address space, some parts are mapped to physical memory, some parts are mapped to files on the disk, some parts are mapped to nothing.

    In process's 4GB address space, 0x00000000-0x7FFFFFFF, lower 2GB address space is used by the process, is called "user address space", 0x80000000-0xFFFFFFFF, higher 2GB address space is used by system, is called "system address space". Every process is only able to access its own user address space, and is not able to access the other process's user address space. The content of every process's user address space is not same, but the vast majority of the content of every process's system address space is same. User mode code can not access the system address space, kernel mode code can access the system address space.

    2 Valid Page - Hardware Part

    We only discuss the x86 architecture case.

    2.1 X86 Paging Mechanism

    For x86 CPU, bit 31 of register CR0 is Paging flag bit, when set, CPU will treat all addresses as virtual address, and automatically complete the translation from virtual address to physical address. Operating system will set the Paging flag bit during system initialization. In initialized windows 2000, we can see the Paging flag bit has been 1.

    When paging is used, the processor divides the 4GB address space and physical memory into fixed-size pages. A page in address space is possibly mapped into a physical page in physical memory, or possibly mapped into files on disk, or mapped into nothing. For 32-bit CPU, the page ( page in address space, physical page ) size is 4KB.

    2.2 Page Directory, Page Table

    The information which is used by CPU to translate the virtual address to physical address, is stored in structures called page table, page directory.

    The size of a physical page is 4KB, so the lower 12 bits of physical address of a physical page are all 0, so to address a physical page only needs the higher 20 bits. The higher 20 bits of physical address of page N in physical memory, is N, so Windows 2000 call the higher 20 bits of physical address of a physical page "physical frame number". For example, the physical address of page 0 in physical memory is 0x00000000, the physical address of page 1 in physical memory is 0x00001000.

    Page table, the size of a page table is 4KB, is hold in a physical page. Page table consists of 1024 4-byte page table entries. The size of a page table entry is 4 bytes, 32 bits, so a page table have 1024 page table entries. For mapped to a physical page case, the higher 20 bits of a page table entry holds a physical frame number of a physical page, the lower 12 bits holds some flags.

    Page directory, the size of a page directory is 4KB, is hold in a physical page. Page directory consists of 1024 4-byte page directory entries. The size of a page directory entry is 4 bytes, 32 bits, so a page directory have 1024 page directory entries. For mapped to a physical page case, the higher 20 bits of a page directory entry holds a physical frame number of a physical page, the lower 12 bits holds some flags.

    The physical address of page directory is hold in CPU's register CR3.

    2.3 CPU Translate Virtual Address to Physical Address

    A virtual address is 4 bytes ( 32 bits ) long, containing the information to find the physical address, is divided into 3 parts: bit31-bit22 this 10 bits is the index in page directory, bit21-bit12 this 10 bits is the index in page table, bit11-bit0 this 12 bits is the offset in page. When CPU translate a virtual address to physical address, first according to the value of CR3, find the physical page where page directory is in. Then using the 10 bits's value of bit31-bit22 of virtual address as index, find the corresponding page directory entry in page directory, the page directory entry holds the physical address of the physical page where the virtual address corresponding page talbe is in. According to the physical address of the page table, find the page table. Then using the 10 bits's value of bit21-bit12 of virtual address as index, find the corresponding page table entry in page table, the page table entry holds the physical address of the virtual address corresponding physical page. Finally using the 12 bits's value of bit11-bit0 of virtual address as offset, add the offset to the physical address of the virtual address corresponding physical page, and get the virtual address corresponding physical address.

    A page directory has 1024 entries, the bit31-bit22 of virtual address is 10 bits, can just index the 1024 entries ( 2^10=1024 ). A page table has 1024 entries, the bit21-bit12 of virtual address is 10 bits, can just index the 1024 entries ( 2^10=1024 ). Bit11-bit0 this 12 bits of virtual address ( 2^12=4096 ), is used as offset, can just index 4KB, every byte in a physical page.

    Virtual address is 32 bits long, can address 0x00000000-0xFFFFFFFF, 4GB size. That means that a 32-bit virtual address can address every byte in the entire 4GB address space. A page table entry maps 4KB address space to physical memory, a page table has 1024 entries, so a page talbe maps 1024*4KB=4MB address space. A page directory entry corresponds a page table. A page directory has 1024 entries, corresponds 1024 page tables. A page talbe maps 4MB address space, 1024 page tables map 1024*4MB=4GB address space. A process has a page directory. So using page as the unit, page directory and page tables can ensure the mapping of every page in 4GB address space to physical memory.

    2.4 Valid Page Directory Entry and Valid Page Table Entry

    The structure of page table entry and page directory entry is defined by CPU and operating system. First CPU defines some bits, CPU will interpret these bits according to this definition. Operating system can not use these bits which have been defined by CPU for other purpose. The bits which have not been defined by CPU are defined by operating system, operating system will interpret these bits according to this definition.

    CPU judges whether a page is mapped to physical memory by the lowest bit, bit0, of page directory entry and page table entry. The lowest bit is 1, is called Valid, means the page is mapped to physical memory. The most bits in a valid page table entry are defined by CPU, a little bits are defined by system. Only bit0, valid flag bit, in an invalid page table entry is defined by CPU, the other bits are all defined by system. We introduce the structure definition of valid page table entry ( page directory entry ) here, and the structure definition of invalid page table entry ( page directory entry ) later.

    Page directory entry and page table entry, 4 bytes long, 32 bits, have the same structure definition. 

    Valid PTE ( Page Table Entry ) structure definition:

    bits0 Valid
    bits1 Write
    bits2 Owner
    bits3 WriteThrough
    bits4 CacheDisable
    bits5 Accessed
    bits6 Dirty
    bits7 LargePage
    bits8 Global
    bits9 CopyOnWrite
    bits10-10 Prototype
    bits11-11 reserved
    bits12-31 PageFrameNumber

    bits12-31 PageFrameNumber:
    Defined by CPU.
    PageFrameNumber, 20 bits long, can address every physical page in 4GB physical memory. For a page directory entry, the founded physical page holds a page table.

    bits0-0 Valid: 
    Defined by CPU.
    Indicates whether the corresponding page is mapped to physical memory. When 0, is called "invalid", the corresponding page is not mapped to physical memory. When 1, is called "valid", the corresponding page is mapped to physical memory.

    bits1-1 Write:
    Defined by CPU.
    Specifies the read-write privileges. When 0, the page is read only. When 1, the page is read/write.

    bits2-2 Owner:
    Defined by CPU.
    Accessing privilege. When 0, only kernel mode code ( x86's ring0 privilege ) can access. When 1, user mode code ( x86's ring3 privilege ) and kernel mode code both can access.

    bits3-3 WriteThrough:
    Defined by CPU.
    Controls the caching policy of relative page.

    bits4-4 CacheDisable:
    Defined by CPU.
    Specifies whether disable the caching of the page.

    bits5-5 Accessed:
    Defined by CPU.
    Indicates whether the page has been accessed (read from or written to). When 0, the page has not been accessed. When 1, the page has been accessed.

    bits6-6 Dirty:
    Defined by CPU.
    Indicates whether the page has been written to. When 0, the page has not been written to. When 1, the page has been written to.

    bits7-7 LargePage:
    Defined by CPU.
    Determines the page size. When 0, the page size is 4KB. When 1, the page size is 4MB.

    bits8-8 Global:
    Defined by CPU.
    Indicates whether the page is a global page. When 0, the page is not a global page. When 1, the page is a global page.

    bits9-9 CopyOnWrite:
    Defined by system.
    Used for Copy-on-Write mechanism.

    bits10-10 Prototype:
    Defined by system.
    Used for prototype pte.

    bits11-11 reserved:
    Defined by system.
    Reserved.

    3 Valid Page - Software Part

    3.1 The Position of Process's Page Directory and Page Tables in Address Space

    During translation from virtual address to physical address, CPU doesn't need the virtual address of page directory and page tables. But a process's page directory and page tables are created and maintained by system, system need access page directory and page tables, all addresses used by system are virtual address, so system must map page directory and page tables into address space. The 1024 page tables which are used to map 4GB address space are orderly mapped to 0xC0000000-0xC0400000 this 4MB address space. The page table which used to map the first 4MB address space, locates in the first 4KB address space beginning from 0xC0000000. The page table which used to map the second 4MB address space, locates in the second 4KB address space beginning from 0xC0000000, and so on. The page directory is mapped to the 4KB address space beginning from 0xC0300000. The page directory and page tables are all in system address space, so the user mode code can not access.

    3.2 The Large Page Part in Address Space

    Operating system's kernel is often used, for improving system performance, windows 2000 places the system kernel ( hal.dll and ntoskrnl.exe ) in large pages. Using large page can reduce TLB misses and save TLB cache, to improve system performance. The size of large page is 4MB.

    Observing page directory, we can see that the LargePage flag bit of 0xC0300800-0xC03009FC the 128 page directory entries is set, that means the 128 page directory entries point to 128 large page. The 128 page directory entries corresponding address space is 0x80000000 - 0xA0000000, 0x20000000 B = 512 MB.

    LargePage page directory entry, doesn't point to a page table physical page, directly points to a 4MB physical page. The size of page is 4MB, so bit21-bit12 this 10 bits is 0. During translation from virtual address to physical address, CPU use the bit31-bit22 this 10 bits of virtual address as index, find the corresponding page directory entry in page directory, find the page directory entry's LargePage flag bit is set, so get the physical address of the 4MB physical page. Then using the bit21-bit0 this 22 bits of virtual address as offset, add the offset to the physical address of the 4MB physical page, and get the virtual address corresponding phyiscal address.

    Observing the 128 LargePage page directory entries, we can find the address space 80000000-9FFFFFFF maps to physical memory 00000000-1FFFFFFF. That means the lower 512 MB of physical memory is mapped to address space 80000000-9FFFFFFF. We can also find the 128 LargePage page directory entries are always valid. If physical memory is less than 512MB, then some part of the LargePage address space can not map to actual physical memory, but the corresponding LargePage page directory entries are still valid, if read from these address space, the read out content are all 0xFF.

    3.3 Page Directory, Page Table Examples

    A notepad process's page directory:

    c0300000: 05f5b067 058ae067 067b5067 00eae067
    c0300010: 03bfa067 00000000 00000000 00000000
    c0300020: 00000000 00000000 00000000 00000000
    c0300030: 00000000 00000000 00000000 00000000
    c0300040: 00000000 00000000 00000000 00000000
    c0300050: 00000000 00000000 00000000 00000000
    c0300060: 00000000 00000000 00000000 00000000
    c0300070: 00000000 00000000 00000000 00000000
    c0300080: 00000000 00000000 00000000 00000000
    c0300090: 00000000 00000000 00000000 00000000
    c03000a0: 00000000 00000000 00000000 00000000
    c03000b0: 00000000 00000000 00000000 00000000
    c03000c0: 00000000 00000000 00000000 00000000
    c03000d0: 00000000 00000000 00000000 00000000
    c03000e0: 00000000 00000000 00000000 00000000
    c03000f0: 00000000 00000000 00000000 00000000
    c0300100: 043b1067 00000000 00000000 00000000
    c0300110: 00000000 00000000 00000000 00000000
    c0300120: 00000000 00000000 00000000 00000000
    c0300130: 00000000 00000000 00000000 00000000
    c0300140: 00000000 00000000 00000000 00000000
    c0300150: 00000000 00000000 00000000 00000000
    c0300160: 00000000 00000000 00000000 00000000
    c0300170: 00000000 00000000 00000000 00000000
    c0300180: 00000000 00000000 00000000 00000000
    c0300190: 00000000 00000000 00000000 00000000
    c03001a0: 00000000 00000000 00000000 00000000
    c03001b0: 00000000 00000000 00000000 00000000
    c03001c0: 00000000 00000000 00000000 00000000
    c03001d0: 00000000 00000000 00000000 00000000
    c03001e0: 00000000 00000000 00000000 00000000
    c03001f0: 00000000 00000000 00000000 00000000
    c0300200: 00000000 00000000 00000000 00000000
    c0300210: 00000000 00000000 00000000 00000000
    c0300220: 00000000 00000000 00000000 00000000
    c0300230: 00000000 00000000 00000000 00000000
    c0300240: 00000000 00000000 00000000 00000000
    c0300250: 00000000 00000000 00000000 00000000
    c0300260: 00000000 00000000 00000000 00000000
    c0300270: 00000000 00000000 00000000 00000000
    c0300280: 00000000 00000000 00000000 00000000
    c0300290: 00000000 00000000 00000000 00000000
    c03002a0: 00000000 00000000 00000000 00000000
    c03002b0: 00000000 00000000 00000000 00000000
    c03002c0: 00000000 00000000 00000000 00000000
    c03002d0: 00000000 00000000 00000000 00000000
    c03002e0: 00000000 00000000 00000000 00000000
    c03002f0: 00000000 00000000 00000000 00000000
    c0300300: 00000000 00000000 00000000 00000000
    c0300310: 00000000 00000000 00000000 00000000
    c0300320: 00000000 00000000 00000000 00000000
    c0300330: 00000000 00000000 00000000 00000000
    c0300340: 00000000 00000000 00000000 00000000
    c0300350: 00000000 00000000 00000000 00000000
    c0300360: 00000000 00000000 00000000 00000000
    c0300370: 00000000 00000000 00000000 00000000
    c0300380: 00000000 00000000 00000000 00000000
    c0300390: 00000000 00000000 00000000 00000000
    c03003a0: 00000000 00000000 00000000 00000000
    c03003b0: 00000000 00000000 00000000 00000000
    c03003c0: 00000000 00000000 00000000 00000000
    c03003d0: 00000000 00000000 00000000 00000000
    c03003e0: 00000000 00000000 00000000 00000000
    c03003f0: 00000000 00000000 00000000 00000000
    c0300400: 00000000 00000000 00000000 00000000
    c0300410: 00000000 00000000 00000000 00000000
    c0300420: 00000000 00000000 00000000 00000000
    c0300430: 00000000 00000000 00000000 00000000
    c0300440: 00000000 00000000 00000000 00000000
    c0300450: 00000000 00000000 00000000 00000000
    c0300460: 00000000 00000000 00000000 00000000
    c0300470: 00000000 00000000 00000000 00000000
    c0300480: 00000000 00000000 00000000 00000000
    c0300490: 00000000 00000000 00000000 00000000
    c03004a0: 00000000 00000000 00000000 00000000
    c03004b0: 00000000 00000000 00000000 00000000
    c03004c0: 00000000 00000000 00000000 00000000
    c03004d0: 00000000 00000000 00000000 00000000
    c03004e0: 00000000 00000000 00000000 00000000
    c03004f0: 00000000 00000000 00000000 00000000
    c0300500: 00000000 00000000 00000000 00000000
    c0300510: 00000000 00000000 00000000 00000000
    c0300520: 00000000 00000000 00000000 00000000
    c0300530: 00000000 00000000 00000000 00000000
    c0300540: 00000000 00000000 00000000 00000000
    c0300550: 00000000 00000000 00000000 00000000
    c0300560: 00000000 00000000 00000000 00000000
    c0300570: 00000000 00000000 00000000 00000000
    c0300580: 00000000 00000000 00000000 00000000
    c0300590: 00000000 00000000 00000000 00000000
    c03005a0: 00000000 00000000 00000000 00000000
    c03005b0: 00000000 00000000 00000000 00000000
    c03005c0: 00000000 00000000 00000000 00000000
    c03005d0: 00000000 00000000 00000000 00000000
    c03005e0: 00000000 00000000 00000000 00000000
    c03005f0: 00000000 00000000 00000000 00000000
    c0300600: 00000000 00000000 00000000 00000000
    c0300610: 00000000 00000000 00000000 00000000
    c0300620: 00000000 00000000 00000000 00000000
    c0300630: 00000000 00000000 00000000 00000000
    c0300640: 00000000 00000000 00000000 00000000
    c0300650: 00000000 00000000 00000000 00000000
    c0300660: 00000000 00000000 00000000 00000000
    c0300670: 00000000 00000000 00000000 00000000
    c0300680: 00000000 00000000 00000000 00000000
    c0300690: 00000000 00000000 00000000 00000000
    c03006a0: 00000000 00000000 00000000 00000000
    c03006b0: 00000000 00000000 00000000 00000000
    c03006c0: 00000000 00000000 00000000 00000000
    c03006d0: 00000000 00000000 00000000 0423a067
    c03006e0: 00000000 00000000 00000000 00000000
    c03006f0: 00000000 00000000 00000000 00000000
    c0300700: 00000000 00000000 00000000 00000000
    c0300710: 00000000 00000000 00000000 00000000
    c0300720: 00000000 00000000 00000000 00000000
    c0300730: 00000000 00000000 00000000 00000000
    c0300740: 00000000 00000000 00000000 00000000
    c0300750: 00000000 00000000 00000000 0154b067
    c0300760: 00000000 00000000 01fa4067 00000000
    c0300770: 00000000 03946067 06825067 00d00067
    c0300780: 01cc7067 00000000 00000000 00000000
    c0300790: 00000000 00000000 00000000 00000000
    c03007a0: 00000000 00000000 00000000 00000000
    c03007b0: 00000000 00000000 00000000 00000000
    c03007c0: 00000000 00000000 00000000 00000000
    c03007d0: 00000000 00000000 00000000 00000000
    c03007e0: 00000000 00000000 00000000 00000000
    c03007f0: 00000000 02869067 00000000 07b98067
    c0300800: 000001e3 004001e3 008001e3 00c001e3
    c0300810: 010001e3 014001e3 018001e3 01c001e3
    c0300820: 020001e3 024001e3 028001e3 02c001e3
    c0300830: 030001e3 034001e3 038001e3 03c001e3
    c0300840: 040001e3 044001e3 048001e3 04c001e3
    c0300850: 050001e3 054001e3 058001e3 05c001e3
    c0300860: 060001e3 064001e3 068001e3 06c001e3
    c0300870: 070001e3 074001e3 078001e3 07c001e3
    c0300880: 080001e3 084001e3 088001e3 08c001e3
    c0300890: 090001e3 094001e3 098001e3 09c001e3
    c03008a0: 0a0001e3 0a4001e3 0a8001e3 0ac001e3
    c03008b0: 0b0001e3 0b4001e3 0b8001e3 0bc001e3
    c03008c0: 0c0001e3 0c4001e3 0c8001e3 0cc001e3
    c03008d0: 0d0001e3 0d4001e3 0d8001e3 0dc001e3
    c03008e0: 0e0001e3 0e4001e3 0e8001e3 0ec001e3
    c03008f0: 0f0001e3 0f4001e3 0f8001e3 0fc001e3
    c0300900: 100001e3 104001e3 108001e3 10c001e3
    c0300910: 110001e3 114001e3 118001e3 11c001e3
    c0300920: 120001e3 124001e3 128001e3 12c001e3
    c0300930: 130001e3 134001e3 138001e3 13c001e3
    c0300940: 140001e3 144001e3 148001e3 14c001e3
    c0300950: 150001e3 154001e3 158001e3 15c001e3
    c0300960: 160001e3 164001e3 168001e3 16c001e3
    c0300970: 170001e3 174001e3 178001e3 17c001e3
    c0300980: 180001e3 184001e3 188001e3 18c001e3
    c0300990: 190001e3 194001e3 198001e3 19c001e3
    c03009a0: 1a0001e3 1a4001e3 1a8001e3 1ac001e3
    c03009b0: 1b0001e3 1b4001e3 1b8001e3 1bc001e3
    c03009c0: 1c0001e3 1c4001e3 1c8001e3 1cc001e3
    c03009d0: 1d0001e3 1d4001e3 1d8001e3 1dc001e3
    c03009e0: 1e0001e3 1e4001e3 1e8001e3 1ec001e3
    c03009f0: 1f0001e3 1f4001e3 1f8001e3 1fc001e3
    c0300a00: 06470163 00000000 00000000 00000000
    c0300a10: 00000000 00000000 00000000 00000000
    c0300a20: 00000000 00000000 00000000 00000000
    c0300a30: 00000000 00000000 00000000 00000000
    c0300a40: 016f1163 016f2163 016f3163 016f4163
    c0300a50: 016f5163 016f6163 016d7163 016d8163
    c0300a60: 016d9163 016da163 016db163 016dc163
    c0300a70: 016dd163 016de163 016df163 01740163
    c0300a80: 01701163 01702163 01703163 01704163
    c0300a90: 01705163 01706163 01707163 01708163
    c0300aa0: 01709163 0170a163 0170b163 0170c163
    c0300ab0: 0170d163 0170e163 0170f163 01710163
    c0300ac0: 01711163 01712163 01713163 01714163
    c0300ad0: 01715163 01716163 016f7163 016f8163
    c0300ae0: 016f9163 016fa163 016fb163 016fc163
    c0300af0: 016fd163 016fe163 016ff163 01760163
    c0300b00: 01721163 01722163 01723163 01724163
    c0300b10: 01725163 01726163 01727163 01728163
    c0300b20: 01729163 0172a163 0172b163 0172c163
    c0300b30: 0172d163 0172e163 0172f163 01730163
    c0300b40: 01731163 01732163 01733163 01734163
    c0300b50: 01735163 01736163 01717163 01718163
    c0300b60: 01719163 0171a163 0171b163 0171c163
    c0300b70: 0171d163 0171e163 0171f163 01780163
    c0300b80: 01741163 01742163 01743163 01744163
    c0300b90: 01745163 01746163 01747163 01748163
    c0300ba0: 01749163 0174a163 0174b163 0174c163
    c0300bb0: 0174d163 0174e163 0174f163 01750163
    c0300bc0: 01751163 01752163 01753163 01754163
    c0300bd0: 01755163 01756163 01737163 01738163
    c0300be0: 01739163 0173a163 0173b163 0173c163
    c0300bf0: 0173d163 0173e163 0173f163 017a0163
    c0300c00: 05cf0063 04a11063 00000000 01670163
    c0300c10: 01671163 01672163 01673163 01674163
    c0300c20: 01675163 01676163 01657163 01658163
    c0300c30: 01659163 0165a163 0165b163 0165c163
    c0300c40: 0165d163 0165e163 0165f163 016c0163
    c0300c50: 01681163 01682163 01683163 01684163
    c0300c60: 01685163 01686163 01687163 01688163
    c0300c70: 01689163 0168a163 0168b163 0168c163
    c0300c80: 0168d163 0168e163 0168f163 01690163
    c0300c90: 01691163 01692163 01693163 01694163
    c0300ca0: 01695163 01696163 01677163 01678163
    c0300cb0: 01679163 0167a163 0167b163 0167c163
    c0300cc0: 0167d163 0167e163 0167f163 016e0163
    c0300cd0: 016a1163 016a2163 016a3163 016a4163
    c0300ce0: 016a5163 016a6163 016a7163 016a8163
    c0300cf0: 016a9163 016aa163 016ab163 016ac163
    c0300d00: 016ad163 016ae163 016af163 016b0163
    c0300d10: 016b1163 016b2163 016b3163 016b4163
    c0300d20: 016b5163 016b6163 01697163 01698163
    c0300d30: 01699163 0169a163 0169b163 0169c163
    c0300d40: 0169d163 0169e163 0169f163 01700163
    c0300d50: 016c1163 016c2163 016c3163 016c4163
    c0300d60: 016c5163 016c6163 016c7163 016c8163
    c0300d70: 016c9163 016ca163 016cb163 016cc163
    c0300d80: 016cd163 016ce163 016cf163 016d0163
    c0300d90: 016d1163 016d2163 016d3163 016d4163
    c0300da0: 016d5163 016d6163 016b7163 016b8163
    c0300db0: 016b9163 016ba163 016bb163 016bc163
    c0300dc0: 016bd163 016be163 016bf163 01720163
    c0300dd0: 016e1163 016e2163 016e3163 016e4163
    c0300de0: 016e5163 016e6163 016e7163 016e8163
    c0300df0: 016e9163 016ea163 016eb163 016ec163
    c0300e00: 016ed163 016ee163 016ef163 016f0163
    c0300e10: 01765163 026f6163 05189163 055ab163
    c0300e20: 00000000 0740f163 05a71163 05f43163
    c0300e30: 0090a163 0297e163 04867163 00000000
    c0300e40: 00000000 00000000 00000000 00000000
    c0300e50: 00000000 00000000 00000000 00000000
    c0300e60: 00000000 00000000 00000000 00000000
    c0300e70: 00000000 00000000 01768163 01769163
    c0300e80: 0176a163 0176b163 0176c163 0176d163
    c0300e90: 0176e163 0176f163 01770163 01771163
    c0300ea0: 01772163 01773163 01774163 01775163
    c0300eb0: 01776163 01757163 01758163 01759163
    c0300ec0: 0175a163 0175b163 0175c163 0175d163
    c0300ed0: 0175e163 0175f163 017c0163 01781163
    c0300ee0: 01782163 01783163 01784163 01785163
    c0300ef0: 01786163 01787163 01788163 01789163
    c0300f00: 0178a163 01000163 01001163 01002163
    c0300f10: 01003163 01004163 01005163 01006163
    c0300f20: 01007163 01008163 01009163 0100a163
    c0300f30: 0100b163 0100c163 0100d163 0100e163
    c0300f40: 0100f163 01010163 01011163 01012163
    c0300f50: 01013163 01014163 01015163 01016163
    c0300f60: 01017163 01018163 01019163 0101a163
    c0300f70: 0101b163 0101c163 0101d163 0101e163
    c0300f80: 0101f163 01020163 01021163 01022163
    c0300f90: 01023163 01024163 01025163 01026163
    c0300fa0: 01027163 01028163 01029163 0102a163
    c0300fb0: 0102b163 0102c163 0102d163 0102e163
    c0300fc0: 0102f163 01030163 01031163 01032163
    c0300fd0: 01033163 01034163 01035163 01036163
    c0300fe0: 01037163 01038163 01039163 0103a163
    c0300ff0: 0103b163 0103c163 0103d163 00031163

    4GB address space, lower 2GB is user address space, front 512 PDEs are used for the translation of the 2GB address space. Higher 2GB is system address space, hind 512 PDEs are used for the translation of the 2GB address space. PDE is 0x00000000, means that no corresponding page table, corresponding 4MB address space mapped nothing. In the 512 PDEs of this example, we see that large numbers of PDEs are 0x00000000, that means large numbers of user address space mapped nothing.

    System process's page directory:

    c0300000: 01860067 00000000 00000000 00000000
    c0300010: 00000000 00000000 00000000 00000000
    c0300020: 00000000 00000000 00000000 00000000
    c0300030: 00000000 00000000 00000000 00000000
    c0300040: 00000000 00000000 00000000 00000000
    c0300050: 00000000 00000000 00000000 00000000
    c0300060: 00000000 00000000 00000000 00000000
    c0300070: 00000000 00000000 00000000 00000000
    c0300080: 00000000 00000000 00000000 00000000
    c0300090: 00000000 00000000 00000000 00000000
    c03000a0: 00000000 00000000 00000000 00000000
    c03000b0: 00000000 00000000 00000000 00000000
    c03000c0: 00000000 00000000 00000000 00000000
    c03000d0: 00000000 00000000 00000000 00000000
    c03000e0: 00000000 00000000 00000000 00000000
    c03000f0: 00000000 00000000 00000000 00000000
    c0300100: 00000000 00000000 00000000 00000000
    c0300110: 00000000 00000000 00000000 00000000
    c0300120: 00000000 00000000 00000000 00000000
    c0300130: 00000000 00000000 00000000 00000000
    c0300140: 00000000 00000000 00000000 00000000
    c0300150: 00000000 00000000 00000000 00000000
    c0300160: 00000000 00000000 00000000 00000000
    c0300170: 00000000 00000000 00000000 00000000
    c0300180: 00000000 00000000 00000000 00000000
    c0300190: 00000000 00000000 00000000 00000000
    c03001a0: 00000000 00000000 00000000 00000000
    c03001b0: 00000000 00000000 00000000 00000000
    c03001c0: 00000000 00000000 00000000 00000000
    c03001d0: 00000000 00000000 00000000 00000000
    c03001e0: 00000000 00000000 00000000 00000000
    c03001f0: 00000000 00000000 00000000 00000000
    c0300200: 00000000 00000000 00000000 00000000
    c0300210: 00000000 00000000 00000000 00000000
    c0300220: 00000000 00000000 00000000 00000000
    c0300230: 00000000 00000000 00000000 00000000
    c0300240: 00000000 00000000 00000000 00000000
    c0300250: 00000000 00000000 00000000 00000000
    c0300260: 00000000 00000000 00000000 00000000
    c0300270: 00000000 00000000 00000000 00000000
    c0300280: 00000000 00000000 00000000 00000000
    c0300290: 00000000 00000000 00000000 00000000
    c03002a0: 00000000 00000000 00000000 00000000
    c03002b0: 00000000 00000000 00000000 00000000
    c03002c0: 00000000 00000000 00000000 00000000
    c03002d0: 00000000 00000000 00000000 00000000
    c03002e0: 00000000 00000000 00000000 00000000
    c03002f0: 00000000 00000000 00000000 00000000
    c0300300: 00000000 00000000 00000000 00000000
    c0300310: 00000000 00000000 00000000 00000000
    c0300320: 00000000 00000000 00000000 00000000
    c0300330: 00000000 00000000 00000000 00000000
    c0300340: 00000000 00000000 00000000 00000000
    c0300350: 00000000 00000000 00000000 00000000
    c0300360: 00000000 00000000 00000000 00000000
    c0300370: 00000000 00000000 00000000 00000000
    c0300380: 00000000 00000000 00000000 00000000
    c0300390: 00000000 00000000 00000000 00000000
    c03003a0: 00000000 00000000 00000000 00000000
    c03003b0: 00000000 00000000 00000000 00000000
    c03003c0: 00000000 00000000 00000000 00000000
    c03003d0: 00000000 00000000 00000000 00000000
    c03003e0: 00000000 00000000 00000000 00000000
    c03003f0: 00000000 00000000 00000000 00000000
    c0300400: 00000000 00000000 00000000 00000000
    c0300410: 00000000 00000000 00000000 00000000
    c0300420: 00000000 00000000 00000000 00000000
    c0300430: 00000000 00000000 00000000 00000000
    c0300440: 00000000 00000000 00000000 00000000
    c0300450: 00000000 00000000 00000000 00000000
    c0300460: 00000000 00000000 00000000 00000000
    c0300470: 00000000 00000000 00000000 00000000
    c0300480: 00000000 00000000 00000000 00000000
    c0300490: 00000000 00000000 00000000 00000000
    c03004a0: 00000000 00000000 00000000 00000000
    c03004b0: 00000000 00000000 00000000 00000000
    c03004c0: 00000000 00000000 00000000 00000000
    c03004d0: 00000000 00000000 00000000 00000000
    c03004e0: 00000000 00000000 00000000 00000000
    c03004f0: 00000000 00000000 00000000 00000000
    c0300500: 00000000 00000000 00000000 00000000
    c0300510: 00000000 00000000 00000000 00000000
    c0300520: 00000000 00000000 00000000 00000000
    c0300530: 00000000 00000000 00000000 00000000
    c0300540: 00000000 00000000 00000000 00000000
    c0300550: 00000000 00000000 00000000 00000000
    c0300560: 00000000 00000000 00000000 00000000
    c0300570: 00000000 00000000 00000000 00000000
    c0300580: 00000000 00000000 00000000 00000000
    c0300590: 00000000 00000000 00000000 00000000
    c03005a0: 00000000 00000000 00000000 00000000
    c03005b0: 00000000 00000000 00000000 00000000
    c03005c0: 00000000 00000000 00000000 00000000
    c03005d0: 00000000 00000000 00000000 00000000
    c03005e0: 00000000 00000000 00000000 00000000
    c03005f0: 00000000 00000000 00000000 00000000
    c0300600: 00000000 00000000 00000000 00000000
    c0300610: 00000000 00000000 00000000 00000000
    c0300620: 00000000 00000000 00000000 00000000
    c0300630: 00000000 00000000 00000000 00000000
    c0300640: 00000000 00000000 00000000 00000000
    c0300650: 00000000 00000000 00000000 00000000
    c0300660: 00000000 00000000 00000000 00000000
    c0300670: 00000000 00000000 00000000 00000000
    c0300680: 00000000 00000000 00000000 00000000
    c0300690: 00000000 00000000 00000000 00000000
    c03006a0: 00000000 00000000 00000000 00000000
    c03006b0: 00000000 00000000 00000000 00000000
    c03006c0: 00000000 00000000 00000000 00000000
    c03006d0: 00000000 00000000 00000000 00000000
    c03006e0: 00000000 00000000 00000000 00000000
    c03006f0: 00000000 00000000 00000000 00000000
    c0300700: 00000000 00000000 00000000 00000000
    c0300710: 00000000 00000000 00000000 00000000
    c0300720: 00000000 00000000 00000000 00000000
    c0300730: 00000000 00000000 00000000 00000000
    c0300740: 00000000 00000000 00000000 00000000
    c0300750: 00000000 00000000 00000000 00000000
    c0300760: 00000000 00000000 00000000 00000000
    c0300770: 00000000 00000000 00000000 02119067
    c0300780: 00000000 00000000 00000000 00000000
    c0300790: 00000000 00000000 00000000 00000000
    c03007a0: 00000000 00000000 00000000 00000000
    c03007b0: 00000000 00000000 00000000 00000000
    c03007c0: 00000000 00000000 00000000 00000000
    c03007d0: 00000000 00000000 00000000 00000000
    c03007e0: 00000000 00000000 00000000 00000000
    c03007f0: 00000000 00000000 00000000 02138067
    c0300800: 000001e3 004001e3 008001e3 00c001e3
    c0300810: 010001e3 014001e3 018001e3 01c001e3
    c0300820: 020001e3 024001e3 028001e3 02c001e3
    c0300830: 030001e3 034001e3 038001e3 03c001e3
    c0300840: 040001e3 044001e3 048001e3 04c001e3
    c0300850: 050001e3 054001e3 058001e3 05c001e3
    c0300860: 060001e3 064001e3 068001e3 06c001e3
    c0300870: 070001e3 074001e3 078001e3 07c001e3
    c0300880: 080001e3 084001e3 088001e3 08c001e3
    c0300890: 090001e3 094001e3 098001e3 09c001e3
    c03008a0: 0a0001e3 0a4001e3 0a8001e3 0ac001e3
    c03008b0: 0b0001e3 0b4001e3 0b8001e3 0bc001e3
    c03008c0: 0c0001e3 0c4001e3 0c8001e3 0cc001e3
    c03008d0: 0d0001e3 0d4001e3 0d8001e3 0dc001e3
    c03008e0: 0e0001e3 0e4001e3 0e8001e3 0ec001e3
    c03008f0: 0f0001e3 0f4001e3 0f8001e3 0fc001e3
    c0300900: 100001e3 104001e3 108001e3 10c001e3
    c0300910: 110001e3 114001e3 118001e3 11c001e3
    c0300920: 120001e3 124001e3 128001e3 12c001e3
    c0300930: 130001e3 134001e3 138001e3 13c001e3
    c0300940: 140001e3 144001e3 148001e3 14c001e3
    c0300950: 150001e3 154001e3 158001e3 15c001e3
    c0300960: 160001e3 164001e3 168001e3 16c001e3
    c0300970: 170001e3 174001e3 178001e3 17c001e3
    c0300980: 180001e3 184001e3 188001e3 18c001e3
    c0300990: 190001e3 194001e3 198001e3 19c001e3
    c03009a0: 1a0001e3 1a4001e3 1a8001e3 1ac001e3
    c03009b0: 1b0001e3 1b4001e3 1b8001e3 1bc001e3
    c03009c0: 1c0001e3 1c4001e3 1c8001e3 1cc001e3
    c03009d0: 1d0001e3 1d4001e3 1d8001e3 1dc001e3
    c03009e0: 1e0001e3 1e4001e3 1e8001e3 1ec001e3
    c03009f0: 1f0001e3 1f4001e3 1f8001e3 1fc001e3
    c0300a00: 06470163 06f15163 00000000 00000000
    c0300a10: 00000000 00000000 00000000 00000000
    c0300a20: 00000000 00000000 00000000 00000000
    c0300a30: 00000000 00000000 00000000 00000000
    c0300a40: 016f1163 016f2163 016f3163 016f4163
    c0300a50: 016f5163 016f6163 016d7163 016d8163
    c0300a60: 016d9163 016da163 016db163 016dc163
    c0300a70: 016dd163 016de163 016df163 01740163
    c0300a80: 01701163 01702163 01703163 01704163
    c0300a90: 01705163 01706163 01707163 01708163
    c0300aa0: 01709163 0170a163 0170b163 0170c163
    c0300ab0: 0170d163 0170e163 0170f163 01710163
    c0300ac0: 01711163 01712163 01713163 01714163
    c0300ad0: 01715163 01716163 016f7163 016f8163
    c0300ae0: 016f9163 016fa163 016fb163 016fc163
    c0300af0: 016fd163 016fe163 016ff163 01760163
    c0300b00: 01721163 01722163 01723163 01724163
    c0300b10: 01725163 01726163 01727163 01728163
    c0300b20: 01729163 0172a163 0172b163 0172c163
    c0300b30: 0172d163 0172e163 0172f163 01730163
    c0300b40: 01731163 01732163 01733163 01734163
    c0300b50: 01735163 01736163 01717163 01718163
    c0300b60: 01719163 0171a163 0171b163 0171c163
    c0300b70: 0171d163 0171e163 0171f163 01780163
    c0300b80: 01741163 01742163 01743163 01744163
    c0300b90: 01745163 01746163 01747163 01748163
    c0300ba0: 01749163 0174a163 0174b163 0174c163
    c0300bb0: 0174d163 0174e163 0174f163 01750163
    c0300bc0: 01751163 01752163 01753163 01754163
    c0300bd0: 01755163 01756163 01737163 01738163
    c0300be0: 01739163 0173a163 0173b163 0173c163
    c0300bf0: 0173d163 0173e163 0173f163 017a0163
    c0300c00: 00030067 01520063 00000000 01670163
    c0300c10: 01671163 01672163 01673163 01674163
    c0300c20: 01675163 01676163 01657163 01658163
    c0300c30: 01659163 0165a163 0165b163 0165c163
    c0300c40: 0165d163 0165e163 0165f163 016c0163
    c0300c50: 01681163 01682163 01683163 01684163
    c0300c60: 01685163 01686163 01687163 01688163
    c0300c70: 01689163 0168a163 0168b163 0168c163
    c0300c80: 0168d163 0168e163 0168f163 01690163
    c0300c90: 01691163 01692163 01693163 01694163
    c0300ca0: 01695163 01696163 01677163 01678163
    c0300cb0: 01679163 0167a163 0167b163 0167c163
    c0300cc0: 0167d163 0167e163 0167f163 016e0163
    c0300cd0: 016a1163 016a2163 016a3163 016a4163
    c0300ce0: 016a5163 016a6163 016a7163 016a8163
    c0300cf0: 016a9163 016aa163 016ab163 016ac163
    c0300d00: 016ad163 016ae163 016af163 016b0163
    c0300d10: 016b1163 016b2163 016b3163 016b4163
    c0300d20: 016b5163 016b6163 01697163 01698163
    c0300d30: 01699163 0169a163 0169b163 0169c163
    c0300d40: 0169d163 0169e163 0169f163 01700163
    c0300d50: 016c1163 016c2163 016c3163 016c4163
    c0300d60: 016c5163 016c6163 016c7163 016c8163
    c0300d70: 016c9163 016ca163 016cb163 016cc163
    c0300d80: 016cd163 016ce163 016cf163 016d0163
    c0300d90: 016d1163 016d2163 016d3163 016d4163
    c0300da0: 016d5163 016d6163 016b7163 016b8163
    c0300db0: 016b9163 016ba163 016bb163 016bc163
    c0300dc0: 016bd163 016be163 016bf163 01720163
    c0300dd0: 016e1163 016e2163 016e3163 016e4163
    c0300de0: 016e5163 016e6163 016e7163 016e8163
    c0300df0: 016e9163 016ea163 016eb163 016ec163
    c0300e00: 016ed163 016ee163 016ef163 016f0163
    c0300e10: 01765163 026f6163 05189163 055ab163
    c0300e20: 059ad163 0740f163 05a71163 05f43163
    c0300e30: 0090a163 0297e163 04867163 034ae163
    c0300e40: 00000300 00000300 00000300 00000300
    c0300e50: 00000300 00000300 00000300 00000300
    c0300e60: 00000300 00000300 00000300 00000300
    c0300e70: 00000300 00000300 01768163 01769163
    c0300e80: 0176a163 0176b163 0176c163 0176d163
    c0300e90: 0176e163 0176f163 01770163 01771163
    c0300ea0: 01772163 01773163 01774163 01775163
    c0300eb0: 01776163 01757163 01758163 01759163
    c0300ec0: 0175a163 0175b163 0175c163 0175d163
    c0300ed0: 0175e163 0175f163 017c0163 01781163
    c0300ee0: 01782163 01783163 01784163 01785163
    c0300ef0: 01786163 01787163 01788163 01789163
    c0300f00: 0178a163 01000163 01001163 01002163
    c0300f10: 01003163 01004163 01005163 01006163
    c0300f20: 01007163 01008163 01009163 0100a163
    c0300f30: 0100b163 0100c163 0100d163 0100e163
    c0300f40: 0100f163 01010163 01011163 01012163
    c0300f50: 01013163 01014163 01015163 01016163
    c0300f60: 01017163 01018163 01019163 0101a163
    c0300f70: 0101b163 0101c163 0101d163 0101e163
    c0300f80: 0101f163 01020163 01021163 01022163
    c0300f90: 01023163 01024163 01025163 01026163
    c0300fa0: 01027163 01028163 01029163 0102a163
    c0300fb0: 0102b163 0102c163 0102d163 0102e163
    c0300fc0: 0102f163 01030163 01031163 01032163
    c0300fd0: 01033163 01034163 01035163 01036163
    c0300fe0: 01037163 01038163 01039163 0103a163
    c0300ff0: 0103b163 0103c163 0103d163 00031163

    Compare the page directory of system process and the page directory of previous example. We can find the user address space corresponding PDEs ( front 512 PDEs ) of two processes are all not same, that means every process has its own independent user address space, each one maps to different physical memory. We can find the overwhelming majority of system address space corresponding PDEs ( hind 512 PDEs ) are same. Same PDE points to a same physical page, so the PDE corresponding page table is same, so the corresponding address space maps to same content. That means the overwhelming majority content of the two processes in system address space are same.

    A notepad process's a page table:

    c0001000: 00000000 00000000 00000000 00000000
    c0001010: 00000000 00000000 00000000 00000000
    c0001020: 00000000 00000000 00000000 00000000
    c0001030: 00000000 00000000 0464f025 046dd025
    c0001040: 00000000 00000000 00000000 00000000
    c0001050: 00000000 00000000 00000000 00000000
    c0001060: 00000000 00000000 00000000 00000000
    c0001070: 00000000 00000000 00000000 00000000
    c0001080: 00000000 00000000 00000000 00000000
    c0001090: 00000000 00000000 00000000 00000000
    c00010a0: 00000000 00000000 00000000 00000000
    c00010b0: 00000000 00000000 00000000 00000000
    c00010c0: 00000000 00000000 00000000 00000000
    c00010d0: 00000000 00000000 00000000 00000000
    c00010e0: 00000000 00000000 00000000 00000000
    c00010f0: 00000000 00000000 00000000 00000000
    c0001100: 00000000 00000000 00000000 00000000
    c0001110: 00000000 00000000 00000000 00000000
    c0001120: 00000000 00000000 00000000 00000000
    c0001130: 00000000 00000000 00000000 00000000
    c0001140: 00000000 00000000 00000000 00000000
    c0001150: 00000000 00000000 00000000 00000000
    c0001160: 00000000 00000000 00000000 00000000
    c0001170: 00000000 00000000 00000000 00000000
    c0001180: 00000000 00000000 00000000 00000000
    c0001190: 00000000 00000000 00000000 00000000
    c00011a0: 00000000 00000000 00000000 00000000
    c00011b0: 00000000 00000000 00000000 00000000
    c00011c0: 00000000 00000000 00000000 00000000
    c00011d0: 00000000 00000000 00000000 00000000
    c00011e0: 00000000 00000000 00000000 00000000
    c00011f0: 00000000 00000000 00000000 00000000
    c0001200: 00000000 00000000 00000000 00000000
    c0001210: 00000000 00000000 00000000 00000000
    c0001220: 00000000 00000000 00000000 00000000
    c0001230: 00000000 00000000 00000000 00000000
    c0001240: 00000000 00000000 00000000 00000000
    c0001250: 00000000 00000000 00000000 00000000
    c0001260: 00000000 00000000 00000000 00000000
    c0001270: 00000000 00000000 00000000 00000000
    c0001280: 00000000 00000000 00000000 00000000
    c0001290: 00000000 00000000 00000000 00000000
    c00012a0: 00000000 00000000 00000000 00000000
    c00012b0: 00000000 00000000 00000000 00000000
    c00012c0: 00000000 00000000 00000000 00000000
    c00012d0: 00000000 00000000 00000000 00000000
    c00012e0: 00000000 00000000 00000000 00000000
    c00012f0: 00000000 00000000 00000000 00000000
    c0001300: 00000000 00000000 00000000 00000000
    c0001310: 00000000 00000000 00000000 00000000
    c0001320: 00000000 00000000 00000000 00000000
    c0001330: 00000000 00000000 00000000 00000000
    c0001340: 00000000 00000000 00000000 00000000
    c0001350: 00000000 00000000 00000000 00000000
    c0001360: 00000000 00000000 00000000 00000000
    c0001370: 00000000 00000000 00000000 00000000
    c0001380: 00000000 00000000 00000000 00000000
    c0001390: 00000000 00000000 00000000 00000000
    c00013a0: 00000000 00000000 00000000 00000000
    c00013b0: 00000000 00000000 00000000 00000000
    c00013c0: 00000000 00000000 00000000 00000000
    c00013d0: 00000000 00000000 00000000 00000000
    c00013e0: 00000000 00000000 00000000 00000000
    c00013f0: 00000000 00000000 00000000 00000000
    c0001400: 00000000 00000000 00000000 00000000
    c0001410: 00000000 00000000 00000000 00000000
    c0001420: 00000000 00000000 00000000 00000000
    c0001430: 00000000 00000000 00000000 00000000
    c0001440: 00000000 00000000 00000000 00000000
    c0001450: 00000000 00000000 00000000 00000000
    c0001460: 00000000 00000000 00000000 00000000
    c0001470: 00000000 00000000 00000000 00000000
    c0001480: 00000000 00000000 00000000 00000000
    c0001490: 00000000 00000000 00000000 00000000
    c00014a0: 00000000 00000000 00000000 00000000
    c00014b0: 00000000 00000000 00000000 00000000
    c00014c0: 00000000 00000000 00000000 00000000
    c00014d0: 00000000 00000000 00000000 00000000
    c00014e0: 00000000 00000000 00000000 00000000
    c00014f0: 00000000 00000000 00000000 00000000
    c0001500: 00000000 00000000 00000000 00000000
    c0001510: 00000000 00000000 00000000 00000000
    c0001520: 00000000 00000000 00000000 00000000
    c0001530: 00000000 00000000 00000000 00000000
    c0001540: 00000000 00000000 00000000 00000000
    c0001550: 00000000 00000000 00000000 00000000
    c0001560: 00000000 00000000 00000000 00000000
    c0001570: 00000000 00000000 00000000 00000000
    c0001580: 00000000 00000000 00000000 00000000
    c0001590: 00000000 00000000 00000000 00000000
    c00015a0: 00000000 00000000 00000000 00000000
    c00015b0: 00000000 00000000 00000000 00000000
    c00015c0: 00000000 00000000 00000000 00000000
    c00015d0: 00000000 00000000 00000000 00000000
    c00015e0: 00000000 00000000 00000000 00000000
    c00015f0: 00000000 00000000 00000000 00000000
    c0001600: 00000000 00000000 00000000 00000000
    c0001610: 00000000 00000000 00000000 00000000
    c0001620: 00000000 00000000 00000000 00000000
    c0001630: 00000000 00000000 00000000 00000000
    c0001640: 00000000 00000000 00000000 00000000
    c0001650: 00000000 00000000 00000000 00000000
    c0001660: 00000000 00000000 00000000 00000000
    c0001670: 00000000 00000000 00000000 00000000
    c0001680: 00000000 00000000 00000000 00000000
    c0001690: 00000000 00000000 00000000 00000000
    c00016a0: 00000000 00000000 00000000 00000000
    c00016b0: 00000000 00000000 00000000 00000000
    c00016c0: 00000000 00000000 00000000 00000000
    c00016d0: 00000000 00000000 00000000 00000000
    c00016e0: 00000000 00000000 00000000 00000000
    c00016f0: 00000000 00000000 00000000 00000000
    c0001700: 00000000 00000000 00000000 00000000
    c0001710: 00000000 00000000 00000000 00000000
    c0001720: 00000000 00000000 00000000 00000000
    c0001730: 00000000 00000000 00000000 00000000
    c0001740: 00000000 00000000 00000000 00000000
    c0001750: 00000000 00000000 00000000 00000000
    c0001760: 00000000 00000000 00000000 00000000
    c0001770: 00000000 00000000 00000000 00000000
    c0001780: 00000000 00000000 00000000 00000000
    c0001790: 00000000 00000000 00000000 00000000
    c00017a0: 00000000 00000000 00000000 00000000
    c00017b0: 00000000 00000000 00000000 00000000
    c00017c0: 00000000 00000000 00000000 00000000
    c00017d0: 00000000 00000000 00000000 00000000
    c00017e0: 00000000 00000000 00000000 00000000
    c00017f0: 00000000 00000000 00000000 00000000
    c0001800: 00000000 00000000 00000000 00000000
    c0001810: 00000000 00000000 00000000 00000000
    c0001820: 00000000 00000000 00000000 00000000
    c0001830: 00000000 00000000 00000000 00000000
    c0001840: 00000000 00000000 00000000 00000000
    c0001850: 00000000 00000000 00000000 00000000
    c0001860: 00000000 00000000 00000000 00000000
    c0001870: 00000000 00000000 00000000 00000000
    c0001880: 00000000 00000000 00000000 00000000
    c0001890: 00000000 00000000 00000000 00000000
    c00018a0: 00000000 00000000 00000000 00000000
    c00018b0: 00000000 00000000 00000000 00000000
    c00018c0: 00000000 00000000 00000000 00000000
    c00018d0: 00000000 00000000 00000000 00000000
    c00018e0: 00000000 00000000 00000000 00000000
    c00018f0: 00000000 00000000 00000000 00000000
    c0001900: 00000000 00000000 00000000 00000000
    c0001910: 00000000 00000000 00000000 00000000
    c0001920: 00000000 00000000 00000000 00000000
    c0001930: 00000000 00000000 00000000 00000000
    c0001940: 00000000 00000000 00000000 00000000
    c0001950: 00000000 00000000 00000000 00000000
    c0001960: 00000000 00000000 00000000 00000000
    c0001970: 00000000 00000000 00000000 00000000
    c0001980: 00000000 00000000 00000000 00000000
    c0001990: 00000000 00000000 00000000 00000000
    c00019a0: 00000000 00000000 00000000 00000000
    c00019b0: 00000000 00000000 00000000 00000000
    c00019c0: 00000000 00000000 00000000 00000000
    c00019d0: 00000000 00000000 00000000 00000000
    c00019e0: 00000000 00000000 00000000 00000000
    c00019f0: 00000000 00000000 00000000 00000000
    c0001a00: 00000000 00000000 00000000 00000000
    c0001a10: 00000000 00000000 00000000 00000000
    c0001a20: 00000000 00000000 00000000 00000000
    c0001a30: 00000000 00000000 00000000 00000000
    c0001a40: 00000000 00000000 00000000 00000000
    c0001a50: 00000000 00000000 00000000 00000000
    c0001a60: 00000000 00000000 00000000 00000000
    c0001a70: 00000000 00000000 00000000 00000000
    c0001a80: 01fd8067 00000000 00000000 00000000
    c0001a90: 00000000 00000000 00000000 00000000
    c0001aa0: 00000000 00000000 00000000 00000000
    c0001ab0: 00000000 00000000 00000000 00000000
    c0001ac0: 02ed9047 00000000 00000000 00000000
    c0001ad0: 00000000 00000000 00000000 00000000
    c0001ae0: 00000000 00000000 00000000 00000000
    c0001af0: 00000000 00000000 00000000 00000000
    c0001b00: 05d3c047 0243d047 006de047 0217f047
    c0001b10: 04f39047 0695a047 01c5b047 00000000
    c0001b20: 00000000 00000000 00000000 00000000
    c0001b30: 00000000 00000000 00000000 00000000
    c0001b40: 07596005 07597005 00000000 00000000
    c0001b50: 00000000 00000000 00000000 00000000
    c0001b60: 00000000 00000000 00000000 00000000
    c0001b70: 00000000 00000000 00000000 00000000
    c0001b80: 0272a047 00000000 00000000 00000000
    c0001b90: 00000000 00000000 00000000 00000000
    c0001ba0: 00000000 00000000 00000000 00000000
    c0001bb0: 00000000 00000000 00000000 00000000
    c0001bc0: 06825047 00000000 00000000 00000000
    c0001bd0: 00000000 00000000 00000000 00000000
    c0001be0: 00000000 00000000 00000000 00000000
    c0001bf0: 00000000 00000000 00000000 00000000
    c0001c00: 00000000 00000000 00000000 00000000
    c0001c10: 00000000 00000000 00000000 00000000
    c0001c20: 00000000 00000000 00000000 00000000
    c0001c30: 00000000 00000000 00000000 00000000
    c0001c40: 00000000 00000000 00000000 00000000
    c0001c50: 00000000 00000000 00000000 00000000
    c0001c60: 00000000 00000000 00000000 00000000
    c0001c70: 00000000 00000000 00000000 00000000
    c0001c80: 00000000 00000000 00000000 00000000
    c0001c90: 00000000 00000000 00000000 00000000
    c0001ca0: 00000000 00000000 00000000 00000000
    c0001cb0: 00000000 00000000 00000000 00000000
    c0001cc0: 00000000 00000000 00000000 00000000
    c0001cd0: 00000000 00000000 00000000 00000000
    c0001ce0: 00000000 00000000 00000000 00000000
    c0001cf0: 00000000 00000000 00000000 00000000
    c0001d00: 00000000 00000000 00000000 00000000
    c0001d10: 00000000 00000000 00000000 00000000
    c0001d20: 00000000 00000000 00000000 00000000
    c0001d30: 00000000 00000000 00000000 00000000
    c0001d40: 00000000 00000000 00000000 00000000
    c0001d50: 00000000 00000000 00000000 00000000
    c0001d60: 00000000 00000000 00000000 00000000
    c0001d70: 00000000 00000000 00000000 00000000
    c0001d80: 00000000 00000000 00000000 00000000
    c0001d90: 00000000 00000000 00000000 00000000
    c0001da0: 00000000 00000000 00000000 00000000
    c0001db0: 00000000 00000000 00000000 00000000
    c0001dc0: 04daf047 03c90047 05ba1047 03de2047
    c0001dd0: 00000000 00000000 00000000 00000000
    c0001de0: 00000000 00000000 00000000 00000000
    c0001df0: 00000000 00000000 00000000 00000000
    c0001e00: 00ef1047 052d2047 05573047 065f4047
    c0001e10: 01c55047 03a56047 03457047 045b8047
    c0001e20: 076d9047 037ba047 04f3b047 0347c047
    c0001e30: 033dd047 05a1e047 01dbf047 02220047
    c0001e40: 00000000 00000000 00000000 00000000
    c0001e50: 00000000 00000000 00000000 00000000
    c0001e60: 00000000 00000000 00000000 00000000
    c0001e70: 00000000 00000000 00000000 00000000
    c0001e80: 00000000 00000000 00000000 00000000
    c0001e90: 00000000 00000000 00000000 00000000
    c0001ea0: 00000000 00000000 00000000 00000000
    c0001eb0: 00000000 00000000 00000000 00000000
    c0001ec0: 00000000 00000000 00000000 00000000
    c0001ed0: 00000000 00000000 00000000 00000000
    c0001ee0: 00000000 00000000 00000000 00000000
    c0001ef0: 00000000 00000000 00000000 00000000
    c0001f00: 00000000 00000000 00000000 00000000
    c0001f10: 00000000 00000000 00000000 00000000
    c0001f20: 00000000 00000000 00000000 00000000
    c0001f30: 00000000 00000000 00000000 00000000
    c0001f40: 00000000 00000000 00000000 00000000
    c0001f50: 00000000 00000000 00000000 00000000
    c0001f60: 00000000 00000000 00000000 00000000
    c0001f70: 00000000 00000000 00000000 00000000
    c0001f80: 00000000 00000000 00000000 00000000
    c0001f90: 00000000 00000000 00000000 00000000
    c0001fa0: 00000000 00000000 00000000 00000000
    c0001fb0: 00000000 00000000 00000000 00000000
    c0001fc0: 00000000 00000000 00000000 00000000
    c0001fd0: 00000000 00000000 00000000 00000000
    c0001fe0: 00000000 00000000 00000000 00000000
    c0001ff0: 00000000 00000000 00000000 00000000

    PTE is 0x00000000, means that corresponding 4KB address space mapped nothing.

    3.4 7 Kinds of Conversion

    We can do 7 kinds of conversion as following.

    1 virtual address -> virtual address of the virtual address corresponding PDE
    Using bit31-bit22 this 10 bits of virtual address as index, find the virtual address of the corresponding PDE in page directory. The base address of page directory is 0xC0300000, the size of PDE is 4B.

    PdeVa = ( Va >> 22 )*4 + 0xC0300000

    2 virtual address -> virtual address of the virtual address corresponding PTE
    Page tables are orderly mapped in address space, so using bit31-bit22 this 10 bits of virtual address as index, find the virtual address of the corresponding page table in page tables. Using bit21-bit12 this 10 bits of virtual address as index, find the virtual address of the corresponding PTE in the page table. The base address of page tables is 0xC0000000, the size of PTE is 4B.

    PteVa = ( Va >> 12 )*4 + 0xC0000000

    3 virtual address -> physical address
    If virtual address above or equal to 0x80000000 and below 0xa0000000, that means the virtual address is in LargePage part, then virtual addres minus 0x80000000 is the physical address.
    Otherwise, calculate the corresponding virtual address of PDE and PTE, get the corresponding PDE and PTE, if corresponding PDE and PTE are both valid, then use the corresponding PTE's bit31-bit12 this 20 bits as physical address's bit31-bit12 this 20 bits, use the virtual address's bit11-bit0 this 12 bits as physical address's bit11-bit0 this 12 bits, so we get the corresponding physical address.

    4 virtual address of PDE -> PDE corresponding address space range
    A PDE corresponding address space range is 4MB.

    VaStart = ( ( PdeVa - 0xC0300000 )/4 )<<22
    VaEnd = VaStart + 0x00400000

    5 virtual address of PTE -> PTE corresponding address space range
    a PTE corresponding address space range is 4KB.

    VaStart = ( ( PteVa - 0xC0000000 )/4 )<<12
    VaEnd = VaStart + 0x00001000

    6 virtual address of PTE -> virtual address of corresponding PDE
    According to the virtual address of PTE, we can calculate corresponding address space range, according to any virtual addres in the range, we can calculate the virtual address of the virtual address corresponding PDE.

    7 virtual address of PDE -> virtual address range of corresponding PTEs
    According to the virtual address of PDE, we can calculate corresponding address space range, according to the range, we can calculate the virtual address range of corresponding PTEs.

    4 Invalid Page - Hardware Part

    4.1 Page-Fault Exception

    Accessing a virtual address, the virtual address corresponding PDE, PTE are all valid, according to the corresponding PDE PTE, CPU automatically translates the virtual address to physical address, and completes the accessing. Accessing a virtual address, the virtual address corresponding PDE or PTE is invalid, will generate a Page-Fault exception. CPU directs to execute the exception handler procedure, the exception handler procedure does corresponding disposal, such as, for the page of accessing virtual address is in a file on disk, load the page in file into a physical page, make the corresponding PTE point to the physical page, and set the corresponding PTE valid. When execution of the exception handler is complete, CPU re-executes the instruction that generated the exception, and this time the virtual address that the instruction accessed has mapped to physical memory, and corresponding PDE, PTE are all valid, the instruction can be completed.

    Exception is a interrupt called "exception". When a exception occurs, using the exception corresponding interrupt vector, CPU finds the corresponding interrupt descriptor in interrupt descriptor table. The interrupt descriptor holds the entry address of exception handler procedure. CPU automatically save some registers on the stack, including EIP where stored the address of the faulting instruction, then directs to the exception handler procedure. The execution of the exception handler is complete with a IRET instruction. When the IRET instruction is executed, CPU will re-execute the faulting instruction according to the faulting instruction address which is saved on the stack. The main difference between exception and interrupt called "interrupt" is: when a exception occurs, a error code will be pushed on the stack, when a interrupt occurs, no error code will be pushed on the stack. CPU can distinguish between exception or interrupt by examining the high 4-byte's bit10-bit8 this 3 bits of interrupt descriptor, this 3 bits of a interrupt is 110, this 3 bits of a exception is 111.

    The interrupt vector of Page-Fault exception is 0xe (0n14). It is defined by CPU that the interrupt vector of Page-Fault exception is 0xe, for x86 cpu, interrupt vector 0-31, this 32 interrupts are defined by CPU. When a Page-Fault exception occurs, a error code will be saved on the stack, bit0 of error code indicates the fault is caused by an invalid page 
    or by a page-level protection violation, bit1 of error code indicates the access causing the fault is a read or a write. The EIP saved on the stack is the faulting instruction address. The content of the CR2 register is the virtual address that generated the exception. 

    5 Invalid Page - Software Part

    5.1 Page-Fault Handler

    A PTE is valid, the corresponding page address space is mapped to a physical page, access in the page of address space, won't cause a Page-Fault exception. A PTE is invalid, the corresponding page address space are 4 cases, the content of the page is in a transition physical page, the content of the page is in a mapped file, the content of the page is in a pagefile swap file, the content of the page is nothing, access in the page address space, will cause a Page-Fault exception. For different cases, PTE has different structure definition.

    The content of page is in a transition state physical page, the content of the page can be out swapped from physical page into file and hasn't been out swapped, it is in a transition state. The higher 20 bits of the invalid PTE is still a physical frame number, the physical page is just the physical page that was pointed by the PTE when PTE was valid, and the content of the physical page has not been modified, is still the content when the PTE was valid. For this case Page-Fault exception handler, only need set the corresponding invalid PTE valid.

    The content of page is in a mapped file, the corresponding content in mapped file is the backup of the corresponding page in address space. There are two kinds of mapped file, one is called "ImageFileMap", one is called "DataFileMap". ImageFileMap include mapping of process's .exe executable file, mapping of process's loaded .dll dynamic link library file. DataFileMap, mapping that call CreateFileMapping API to load the file into memory. Every process loads process's .exe executable file and process's .dll dynamic link library files to memory by ImageFileMap. Invalid PTE contains the information to find the corresponding content in file, every file-mapping has a set of relative structures, which keeps some relative information, such as file's handle, structures to implement sharing between processes. The corresponding content in the file can be found by invalid PTE and relative structures of file-mapping. For this case Page-Fault exception handler, according to invalid PTE and relative structures of file-mapping, find the content of a corresponding page in the corresponding file, read the content of the page into a physical page, and set the corresponding invalid PTE to point to the physical page and valid.

    The content of page is in a PageFile swap file, process's some data pages which are out swapped from physical memory, are backed in PageFile swap file. In windows 2000, file "pagefile.sys" is the PageFile swap file. Many pages may be out swapped into PageFile, such as, thread's kernel mode stack, pages in user address space except for file-mapping, process's page tables, pages in PagedPool in system address space, etc. Pages in user address space except for file-mapping, such as, process's heap, thread's user mode stack, process environment block, thread environment block, etc. Invalid PTE contains the information to find a certain page in a certain PageFile swap file, every PageFile swap file has a set of relative structures ( note, relative structures of PageFile are utterly different from relative structures of file-mapping ), which keeps some relative information, such as which pages in PageFile have been used, which pages haven't been used. The out swapped content in PageFile can be found by invalid PTE and relative structures of PageFile. For this case Page-Fault exception handler, according to invalid PTE and relative structures of PageFile, find the content of a corresponding page in a certain PageFile, read the content of the page into a physical page, and set the corresponding invalid PTE to point to the physical page and valid.

    All bits of a PTE are 0, means that there's nothing in this page address space.

    5.2 Difference between Different Type Invalid PTE

    The bit10 of invalid PTE is Prototype flag bit. For Prototype flag bit is equal to 0 case, bit11 is Transition flag bit.

    Prototype flag bit is equal to 1, invalid PTE is Prototype PTE, is used for the content of the page is in a mapped file case.

    Prototype flag bit is equal to 0, Transition flag bit is equal to 0, invalid PTE is used for the content of the page is in a PageFile swap file case.

    Prototype flag bit is equal to 0, Transition flag bit is equal to 1, invalid PTE is used for the content of the page is in a transition state physical page case.

    6 Some Answers

    6.1 why the size of address space is 4GB?

    32-bit CPU determines that the size of address (pointer) which used very ofen in codes is 32-bit. 32-bit address (pointer) can address 0x00000000-0xFFFFFFFF, the addressing unit is byte, so the size of address space is 4GB.

    6.2 efficiency of address translation

    When using paging, all address of memory operation are virtual address, CPU will automatically translate it to physical address, you can image that there would be huge amounts of address translation, to translate a single virtual address, CPU need to read page directory, read page table, at last read or write in physical page. So for improving speed and efficiency of address translation, Windows 2000 puts some PDE and PTE in cache. A on-chip cache called TLB (Translation Look-Aside Buffer) is used to store most recently used PDE and PTE, it reduces huge amounts of reading page directory and page table from physical memory in address translation.

    6.3 WHY the address of page directory is 0xC0300000, WHY 1 page directory and 1024 page tables only use 1024*4KB address space?

    To map the entire 4GB address space, needing 1024 page tables and 1 page directory, every one is 4KB, 1024*4KB+1*4KB = 4MB+4KB. But in fact Windows 2000 maps every process's page directory and page tables into 0xC0000000-0xC03FFFFF, this 4MB address space ( page directory is in the 4KB address space beginning from 0xC0300000 ).

    1024 page tables and 1 page directory should need (1024+1)*4KB address space, why Windows 2000 only use 1024*4KB address space?

    The reason is page tables are mapped into process's address space.

    If page tables and page directory haven't been mapped in process's address space and a process's 4GB address space are all mapped to physical memory, then do need 1024 physical pages to hold page tables and another 1 physical page to hold page directory, that needs (1024+1)*4KB physical memory. But page tables are mapped in process's address space, this results in the content of a page table and the content of page directory being completely same, just this completely same causes that 1024 page tables and 1 page directory only need 1024*4KB address space, one of page tables and page directory is completely overlap.

    A page table has 1024 entries, every entry maps 4KB address space, a page table maps 4MB address space. 1024 page tables maps entire 4GB address space. 1024 page tables are mapped in 0xC0000000-0xC03FFFFF this 4MB address space. This 4MB address space is mapped by a page table. The page table to map 0xC0000000-0xC03FFFFF this 4MB address space, has 1024 PTEs to map every page in 0xC0000000-0xC03FFFFF this 4MB address space, every page in 0xC0000000-0xC03FFFFF this 4MB address space is a page table, so every PTE of that page table is PDE, and that page table is page directory. Mapping 1024 page tables into address space, results in one of page tables and page directory being completely overlap, it is page directory and also page table. So 1 page directory and 1024 page tables only need 1024*4KB address space.

    Where the page tables are mapped in address space, is decided by the operating system's designers. They will think about various problems and make the last decision. But if the address of page tables are determined, then the address of page directory has been determined, unless they intend to use one more page address space to keep the same content of one current page.

    In windows 2000, page tables are mapped into 0xC0000000-0xC03FFFFF this 4MB address space, let's calculate the address of this 4MB address space corresponding page table, which is the page table overlapped with page directory. 0xC0000000 is obviously mapped by the first PTE of that page table. PteVa = ( Va >> 12 )*4 + 0xC0000000, (0xC0000000>>12)*4+0xC0000000 = 0xC0000*4+0xC0000000 = 0x300000+0xC0000000 = 0xC0300000, it's right the virtual address of page directory.

    We can also see, the physical frame number of the 4 bytes at 0xC0300C00 is equal to the physical frame number of register CR3.

    0xC0300000-0xC0300FFF this 4KB as a normal page, the corresponding PTE, PteVa = ( Va >> 12 )*4 + 0xC0000000, is 0xC0300C00. That means the 4 bytes at 0xC0300C00 as a PTE, contains the physical frame number of 0xC0300000-0xC0300FFF this page mapped physical page.

    0xC0300000-0xC0300FFF this 4KB as a page table, the corresponding PDE, PdeVa = ( Va >> 22 )*4 + 0xC0300000, is 0xC0300C00. That means the 4 bytes at 0xC0300C00 as a PDE, contains the physical frame number of 0xC0300000-0xC0300FFF this page table mapped physical page.

    0xC0300000-0xC0300FFF this 4KB as a page directory, CR3 contains the physical address of the physical page.

    So the physical frame number of the 4 bytes at 0xC0300C00 is equal to the physical frame number of register CR3.

    6.4 Physical Memory Needed by Process's Page Directory and Page Tables

    Process need physical pages to hold page directory and page tables, if there are 1024 page tables, then need 1024*4KB=4MB physical memory. Does every process need 4MB physical memory to keep just page table information? It really doesn't. If the valid flag bit of a PDE is 0, then the corresponding page table doesn't exist, then the physical page to hold this page table doesn't need. The user address space corresponding 512 PDEs, commonly have many invalid PDEs. The every procees's system address space corresponding 512 PDEs, are mainly same. That means, page tables in user address space are not very many, most page tables of every procees in system space are same, actually not too much physical memory are needed to keep a process's page tables.

    That's why to use a 2 level address translation. If only 1 level, only page tables, then every process's 1024 page tables must all be in physical memory, every process does need 4MB physical memory to keep page tables, the price is too high for now. Using 2 level address translation, one more step, although the speed of translation will be a little slower, but physical memory is saved, it's a balance between speed and memory.

    END.

    Comments: guestbook
    Homepage: http://jiurl.nease.net Email: microjiurl@163.com

  • 相关阅读:
    关于java中final变量的小问题
    你在努力工作吗?
    Google Android系统中侵犯Oracle的专利说明
    应用系统之间数据传输的几种方式
    Java内存模型jsr133规范介绍
    程序员40岁之后怎么办?
    eaby技术架构变迁
    缓存使用的一些注意事项
    java对象初始化顺序
    Ubuntu安装Fcitx(小企鹅五笔输入法)
  • 原文地址:https://www.cnblogs.com/stone/p/240465.html
Copyright © 2020-2023  润新知