PML4 Confusion
Posted: Wed Feb 20, 2008 6:55 pm
I'm having a little trouble with the PML4. I seem to be unable to RTFM an GTFI on the PML4. Can someone point me to some kind info on setting PML4 up?
PS. I STFW
PS. I STFW
Code: Select all
use32
PMode32:
mov eax, data_selector ;load 4GB data descriptor
xor ecx, ecx
mov ds, ax ;to almost all segment registers
mov es, ax
mov ss, ax
mov fs, cx
mov gs, cx
mov eax, cr4
or eax, 1 shl 5
mov cr4, eax ;enable PAE
;clear all 4 tables(PML4,PDP,PD,PT)
xor eax, eax
mov edi, 100000h
mov ecx, 512*8 ;512 entries in one table
rep stosd ;write dwords
;PML4 located at 100000h
;PDP located at 101000h
;Page-Directory at 102000h
;Page-table not required since we map 2MB pages
mov dword [100000h], 101000h + 111b ;1st PML4 Entry points to PDP table
mov dword [101000h], 102000h + 111b ;1st PDP Entry points to PD table
mov dword [102000h+8*0], 0h + 110000111b ;1st PD Entry points to 0MB
mov dword [102000h+8*1], 200000h + 110000011b ;2nd PD Entry points to 2MB
mov dword [102000h+8*2], 400000h + 110000011b ;3rd PD Entry points to 4MB
; addr + entry # memory(page) permissions
mov dword [102000h+8*3], 600000h + 110000011b
mov eax, 100000h
mov cr3, eax ;load PML4 base
mov ecx, 0C0000080h ;EFER MSR
rdmsr
or eax, 1 shl 8 ;enable long mode
wrmsr
mov eax, cr0
or eax, 1 shl 31 ;enable paging
mov cr0, eax
jmp code64_selector:LongMode
use64
LongMode:
I doubt such tutorial exists simply because pml4 follows same rules as other tables.os.hacker64 wrote: Can someone point me to some kind info on setting PML4 up?
PS. I STFW