Hello,
since I started to work on an OS project of mine, called Carbon [1], I've always been using bochs for testing; now I wanted to try qemu first, before running on real hardware, but I ran into qemu crashing when setting the paging bit in CR0, after having loaded the PML4, in order to switch from protected to long mode in my loader (see loader/src/boot.s in the github repo).
To narrow down what could be causing the problem, I installed a IDT and several handlers and checked whether an interrupt is raised on enabling paging, but it wasn't.
As qemu is not as verbose as bochs on what is causing it to crash, I couldn't figure it out, yet. Would be nice, if someone checked the code.
Greeting,
Farok
[1] https://github.com/farok/Carbon
Qemu crashes when enabling paging
Qemu crashes when enabling paging
https://github.com/qero/Hydrogen (Loader for AMD64 kernels running on top of GRUB2)
Re: Qemu crashes when enabling paging
Code: Select all
mov eax, cr0 ; Enable paging
or eax, 1 << 31
mov cr0, eax
So, you should set both 0 and 31 bits (CR0.PE and CR0.PG) at the same time.
Also, why do you use so much calls? Why don't you keep you code simple? I don't know how is it nowadays but several years ago KolibriOS kernel code was (ok, many parts of the code) a good example of IA-32 assembly code. Ok, you use long mode, then it's better to look at the x86_64 linux kernel bootloader. AT&T mnemonics can lead (as for me) to eyes bleeding but the code is very concise, it won't take much time to understand.
Re: Qemu crashes when enabling paging
Its booted using multiboot directly into protected mode, which requires CR0.PE to be set; as I take the value of CR0, OR with CR0.PG and write it back again, CR0.PE remains set.
I actually find it much clearer when using the calls like this, having the details out of my sight, but that's how I think of it.
Edit: More extensive google studies gave the result that my probelm is an exact duplicate of http://forum.osdev.org/viewtopic.php?f=1&t=20439; choosing qemu-system-x86_64 over vanilla qemu did the thing
I actually find it much clearer when using the calls like this, having the details out of my sight, but that's how I think of it.
Edit: More extensive google studies gave the result that my probelm is an exact duplicate of http://forum.osdev.org/viewtopic.php?f=1&t=20439; choosing qemu-system-x86_64 over vanilla qemu did the thing
https://github.com/qero/Hydrogen (Loader for AMD64 kernels running on top of GRUB2)