OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 5:03 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: General Fault when handling interrupt in long mode
PostPosted: Sun Jan 08, 2023 7:43 am 
Offline

Joined: Sun Jan 08, 2023 7:22 am
Posts: 5
Hello,
I would like some advice on my code about implementing IDT in long mode. It keeps triggering General Protection Fault when execute iretq. I know it triggers GPF because I have messed up with the stack, but I don't know where did I go wrong. Can anyone help me?
Here is my code https://github.com/NeonLightions/susOS.
The asm file when running QEMU with -d in_asm is in qemu.log. I only show the code after I execute 'sti' in there because all of the file would be very long. Need some helps.


Top
 Profile  
 
 Post subject: Re: General Fault when handling interrupt in long mode
PostPosted: Sun Jan 08, 2023 8:30 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
passerby wrote:
The asm file when running QEMU with -d in_asm is in qemu.log.

The log from "-d int" is typically more useful for diagnosing this kind of problem.

My crystal ball says you didn't load your new code segment selector into CS after setting up your GDT, so the interrupt pushes the wrong CS selector on the stack. The fault occurs when IRETQ pops that bad selector.


Top
 Profile  
 
 Post subject: Re: General Fault when handling interrupt in long mode
PostPosted: Sun Jan 08, 2023 11:44 pm 
Offline

Joined: Sun Jan 08, 2023 7:22 am
Posts: 5
Octocontrabass wrote:
passerby wrote:
The asm file when running QEMU with -d in_asm is in qemu.log.

The log from "-d int" is typically more useful for diagnosing this kind of problem.

My crystal ball says you didn't load your new code segment selector into CS after setting up your GDT, so the interrupt pushes the wrong CS selector on the stack. The fault occurs when IRETQ pops that bad selector.

Thank you so much, it solved my problem! This is so awkward :oops:


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: Bing [Bot], DotBot [Bot] and 66 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