Why after enable paging specific address is not available?

0

I just want to fully understand how paging works on practice. part of my code for paging:

  .section .bss
  .align 4096
p4_table:
    .skip 4096
p3_table:
    .skip 4096
p2_table:
    .skip 4096

and more code:

set_up_page_tables:

movl $p3_table, %eax
orl $0b11, %eax       // present + writable
mov %eax, (p4_table)
movl $0b10000011, (p3_table)


movl $1, %ebx
movl $0b10000011, %eax
movl %eax, p3_table(,%ebx,8)


movl $1, %ebx
movl p3_table, %eax
movl %eax, p4_table(,%ebx,8)

Here I fill two entries in p3_table(PDPT). And I fill two entries in p4_table(PML4). As I understand one entry in p3_table encodes 1g, and one entry in p4_table encodes 512g. Since I filled 2 entries in the p3_table with 0b10000011 it encodes addresses form 0x0 - 0x80000000(0-2g). And I place p3_table in second entry of p4_table it must encode addresses from 0x8000000000-0x8080000000(512g-514g). And if I run my program(kernel) 0-2g addresses is available, but why addresses from 0x8000000000-0x8080000000(512g-514g) not available and lead to crash?

full sources: https://github.com/JustVic/kernel_for_testing

assembly
x86
paging
att
osdev
asked on Stack Overflow Feb 11, 2021 by JustOneMan • edited Feb 11, 2021 by JustOneMan

1 Answer

0

Ok I just forget this line orl $0b11, %eax then fill second entry of p4_table. It must be like this:

movl $1, %ebx
movl p3_table, %eax
orl $0b11, %eax
movl %eax, p4_table(,%ebx,8)
answered on Stack Overflow Feb 11, 2021 by JustOneMan

User contributions licensed under CC BY-SA 3.0