Page 1 of 1

Long mode code works in QEMU, but not Virtualbox

Posted: Tue Aug 25, 2020 11:42 am
by nexos
Hello,
I was testing out my Long mode initialization code on Virtualbox and real hardware, but it fails to work. It triple faults. It is pretty lengthy, so I have posted a link to it. It can be found at
https://github.com/Nexware-Project/NexO ... 4/boot.asm.
Thanks,
nexos

Re: Long mode code works in QEMU, but not Virtualbox

Posted: Tue Aug 25, 2020 1:33 pm
by iansjack
You've almost certainly made some assumption about uninitialized variables being zero, the value of the df flag, or something similar.

Re: Long mode code works in QEMU, but not Virtualbox

Posted: Tue Aug 25, 2020 1:58 pm
by Octocontrabass
Is that a 1G page I see? Did you check for 1G pages before using it?

VirtualBox can log the triple fault. You should be able to narrow down the cause a bit from that.

Also, rather than storing the multiboot magic and address in memory, why not just move them directly to ESI and EDI before jumping to long mode? (You can store them in the wrong registers and do "xchg esi, edi" after jumping to long mode to clear the upper bits.)

Re: Long mode code works in QEMU, but not Virtualbox

Posted: Tue Aug 25, 2020 2:11 pm
by sj95126
It looks like you're mapping the lowest 1GB page to its equivalent physical page, which is a good place to start.

But, have you verified that your environments support 1GB pages? It's not automatic with 4-level paging. There's a CPUID flag for it.

Re: Long mode code works in QEMU, but not Virtualbox

Posted: Tue Aug 25, 2020 2:22 pm
by nexos
Yes, that was the problem. I have fixed that, but now the basic video driver triple faults. I will go fix that, and come back here if i have troubles.