OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 11:06 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Trouble Loading GDT
PostPosted: Sat Aug 05, 2017 12:30 pm 
Offline

Joined: Sat Aug 05, 2017 12:23 pm
Posts: 3
I've been working through creating a simple kernel and I'm loading my GDT now. I used GRUB as my bootloader.

My goal is to setup a flat memory model. However, I am having quite some trouble getting it to load. I am using QEMU and it is triple faulting.


I load the GDT from my kernel by calling the gdt_init() function.

I've discovered the problem lies with instruction in load_gdt(). Everything up to that point "works." I suspect this might be due to an error in setting up my GDT, but I'm not sure where I went wrong.

RESOLVED: The issue was me failing to pass the gdt pointer correctly on the stack when loading it.


Last edited by horizon on Sat Aug 05, 2017 3:05 pm, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: Trouble Loading GDT
PostPosted: Sat Aug 05, 2017 12:55 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5137
horizon wrote:
I suspect this might be due to an error in setting up my GDT, but I'm not sure where I went wrong.

Have you tried using a debugger? The problem you have now is most likely something simple, so it would be great practice. Popular choices include Bochs with its built-in debugger, and qemu with gdb. For this particular issue, I'd start by examining the contents of the GDT right after lgdt.

You might also be able to get some hints from the logs of your emulator or VM. In particular, look for the location and type of fault to narrow down the possibilities.

Unfortunately, I haven't spotted the bug with a quick look at your code.


Top
 Profile  
 
 Post subject: Re: Trouble Loading GDT
PostPosted: Sat Aug 05, 2017 2:12 pm 
Offline
Member
Member
User avatar

Joined: Thu Mar 10, 2016 7:35 am
Posts: 167
Location: Lancaster, England, Disunited Kingdom
Well the return instruction immediately after setting ss seems a possible problem to me :shock:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: SemrushBot [Bot] and 75 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group