Skip to content

Instantly share code, notes, and snippets.

@doug65536
Created June 3, 2021 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doug65536/74d4987f066dc2d6c5c2204f3127a2dd to your computer and use it in GitHub Desktop.
Save doug65536/74d4987f066dc2d6c5c2204f3127a2dd to your computer and use it in GitHub Desktop.
(qemu) info tlb -f -4 $cr3
Parsing 4-level page tables
[ CR3] : 205000 CR3 ->
[ 205000] : 206000 ----A---W PML4[0] ->
[ 206000] 0: 0 --P-----W UC PAT=WB MTRR=UC
[ 206008] 40000000: 40000000 --P-----W UC PAT=WB MTRR=UC
[ 206010] 80000000: 80000000 --P-----W UC PAT=WB MTRR=UC
[ 206018] c0000000: c0000000 --PDA---W UC PAT=WB MTRR=UC
[ 206020] 100000000: 0 --PDA---W UC PAT=WB MTRR=UC
.code32
.section .text, "ax", @progbits
init_page_tables:
// Write present and writable entry pointing to PDPT
mov $ UNRELOCATED(page_tables + 4096 + PTE_PRESENT + PTE_WRITABLE),%ecx
mov %ecx,UNRELOCATED(page_tables)
mov $ UNRELOCATED(page_tables + 4096),%edx
mov $ 1 << 30,%eax
mov $ PTE_PRESENT + PTE_WRITABLE + PTE_PAGESIZE,%ecx
mov %ecx,(%edx)
mov %ecx,4*8(%edx)
add %eax,%ecx
mov %ecx,1*8(%edx)
add %eax,%ecx
mov %ecx,2*8(%edx)
add %eax,%ecx
mov %ecx,3*8(%edx)
mov $ UNRELOCATED(page_tables),%eax
mov %eax,%cr3
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment