Problem with x86-64 paging in qemu
Posted: Tue May 22, 2012 7:06 am
For most time, I had been testing my code in Bochs only - and it worked without any problem. But today, I tried in QEMU - and it failed. I found the piece of code that caused triple fault - it happened on "jmp rax", where rax = 0xffffffff80000020. I checked the paging setup, using info mem:
Note the last entry, starting at 0xffff80000000 - it should be 0xffffffff80000000, of course, as 0xffff80000000 isn't canonical address. I confirmed that my code used to setup paging structures is right using some simple prints in bootloader's memory mapping code; I'm only touching 510th and 511th entries of 511th PML4 entry. Bochs works fine with jumping to 0xffffffff80000000.
Does anyone have any idea what to do to make this work?
Paging at the moment when QEMU fails is set by functions called from here; the code that fails is:
Code: Select all
(qemu) info mem
0000000000000000-0000000004000000 0000000004000000 -rw
0000000008000000-0000000008006000 0000000000006000 -rw
00000000f0000000-00000000f00eb000 00000000000eb000 -rw
0000ffff80000000-0000ffff810d4000 00000000010d4000 -rw
Does anyone have any idea what to do to make this work?
Paging at the moment when QEMU fails is set by functions called from here; the code that fails is:
Code: Select all
bits 64
global entry
extern kernel_main
entry:
mov rax, qword 0xFFFFFFFF80000000
add rax, byte 32
jmp rax
times 32 - ($-$$) db 0
highmemory:
hlt