Long mode code works in QEMU, but not Virtualbox

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Long mode code works in QEMU, but not Virtualbox

Post 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
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

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

Post by iansjack »

You've almost certainly made some assumption about uninitialized variables being zero, the value of the df flag, or something similar.
Octocontrabass
Member
Member
Posts: 5572
Joined: Mon Mar 25, 2013 7:01 pm

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

Post 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.)
sj95126
Member
Member
Posts: 151
Joined: Tue Aug 11, 2020 12:14 pm

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

Post 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.
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

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

Post 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.
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
Post Reply