I've been writing my silly OS project for some time and I've finally managed to setup Long-mode, but it only works in Bosch and Qemu. VirtualBox on my Core2Duo in Windows XP host hangs when I try to enable paging after I've set up everything else. Full source can be found here, but the code snippet I teared down that hangs is here (in bbp/boot/boot.asm):
Code: Select all
; Setup long mode.
mov eax, cr0 ; read from CR0
and eax, 0x7FFFFFFF ; clear paging bit
mov cr0, eax ; write to CR0
lgdt [gdt64_ptr] ; load 64bit GDT pointer
mov eax, cr4 ; read from CR4
or eax, 0x000000A0 ; set the PAE and PGE bit
mov cr4, eax ; write to CR4
mov eax, [pml4_ptr32] ; point eax to PML4 pointer location
or eax, 0x00000008 ; enable Page write-through
mov cr3, eax ; save PML4 pointer into CR3
mov ecx, 0xC0000080 ; read from the EFER MSR
rdmsr ; read MSR
or eax, 0x00000101 ; set the LME and SYSCALL/SYSRET bits
wrmsr ; write MSR
mov eax, cr0 ; read from CR0
or eax,0x80000000 ; set paging bit
; Here it stops, right after I write into CR0
mov cr0, eax ; write to CR0
jmp 0x08:start64 ; do the magic jump to Long Mode
I can't find any references to which version of Intel's CPUs started to support PML4, could this be the issue or is it that I'm using a 32bit OS as the host? I know that I should probably do a proper CPUID check, but some "feature reference tables" would be nice to have here on OSDev Wiki.