Triple Fault on Far Jump To Long Mode

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
User avatar
K3achas
Posts: 22
Joined: Sat May 26, 2018 5:32 pm

Triple Fault on Far Jump To Long Mode

Post by K3achas »

Whenever I run the following code to switch to long mode in qemu, it triple faults (by way of #GP). I've tried changing the GDT entry for the code segment, but I haven't had success so far. Any ideas would be much appreciated.

Links to file for the code to switch from the 32-bit environment grub loads the bootstrapper in to 64-bit long mode (fault is on the far jump), the gdt, and the overall repository.
The maker of Foxtrot microkernels. Currently just Greyhound, which is currently smaller than 3 KiB.
Also working on osmkVII.
OmeletHopper
Posts: 4
Joined: Mon Jun 04, 2018 6:37 am

Re: Triple Fault on Far Jump To Long Mode

Post by OmeletHopper »

This (most likely) won't fix your triple fault, but just a quick look at your early.asm and I noticed you've labeled (and set up) your stack backwards. Remember: On x86 The stack grows downwards. From the wiki:

Code: Select all

	To set up a stack, we set the esp register to point to the top of our
	stack (as it grows downwards on x86 systems). This is necessarily done
	in assembly as languages such as C cannot function without a stack.
Although written for 32 bit protected mode, it should apply to you. I could also be completely wrong, because I am new to OSDev, but being proven wrong is an opportunity to learn :D

EDIT: Sorry, I goofed. I misread your code and had a dyslexic moment. Your stack is set up properly.
"You’re free to praise Microsoft Windows on your own if you want, but please don’t do this in GNU packages." - GNU C Portability Standards
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Triple Fault on Far Jump To Long Mode

Post by iansjack »

1. Perhaps I'm missing something, but I couldn't see a long jump in your code.

2. You don't appear to set up a page table.
Post Reply