Cannot find page table entry

0

I cannot find records in the page table/page directory for address 0xB8000. It works correct and when I put some symbols into this memory region display shows it.

I’m in the protected mode, and paging is enabled. I’m using bochs.

cr0 is 0xe0000011 or 1110 0000 0000 0000 0000 0000 0001 0001b, cr3 is 0x1000

enter image description here

0xB8000 is equal 1011 1000 0000 0000 0000b, so 10111000b is index of page table, it's equal 184, index of page directory is 0, offset is zero.

I go to 0x1000 of physical memory and I get first (index 0) item: enter image description here

It is 0x2027 or 10 0000 0010 0111b so the physical address of the page table is 10b or 2. I need a content of 184th entry so I need to go to 184 * 4 + 2 = 738 = 0x2E2, but it's empty: enter image description here

Btw I have three memory descriptors (memory from 0x0 to 0xFFFFFFFF):

null:
    0
code: 
    dw 0FFFFh           ; limit low
    dw 0                ; base low
    db 0                ; base middle
    db 10011010b        ; access
    db 11001111b        ; granularity
    db 0                ; base high

data:
    dw 0FFFFh           ; limit low (Same as code)
    dw 0                ; base low
    db 0                ; base middle
    db 10010010b        ; access
    db 11001111b        ; granularity
    db 0                ; base high
assembly
memory-management
x86
operating-system
page-tables
asked on Stack Overflow Nov 5, 2020 by daniil_ • edited Nov 5, 2020 by Peter Cordes

1 Answer

3

It is 0x2027 or 10 0000 0010 0111b so the physical address of the page table is 10b or 2. I need a content of 184th entry so I need to go to 184 * 4 + 2 = 738 = 0x2E2, but it's empty:

It's 0x2027, so the physical address of the page table is 0x2000 (not 2). The 185th entry (entry number 184) will be at offset 0x2E0 in the page table and will have the physical address 0x22E0.

Note: You could shift the page directory entry (0x2027) to the right 12 places and say "it's physical page number 2", then multiply the page number by the size of a page (or shift it left 12 places) to find the physical address of the page. It's easier/faster to just mask off the lowest 12 bits instead (e.g. physical_address_of_page_table = page_directory_entry & 0xFFFFF000;), especially when doing it in your head with hexadecimal values (where you can just assume the last 3 digits are zeros).

answered on Stack Overflow Nov 5, 2020 by Brendan • edited Nov 5, 2020 by Brendan

User contributions licensed under CC BY-SA 3.0