OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 3:26 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Privileged intruction in user mode leads to triple fault.
PostPosted: Fri Jul 09, 2021 10:43 am 
Offline
Member
Member

Joined: Sun May 24, 2020 9:11 am
Posts: 61
Location: /dev/null
I have successfully implemented scheduler in my OS. Now I'm able to run programs in ring 3. However, executing any privileged instruction in user mode leads to triple fault.

I don't know why. I have handlers for all exceptions and they work in kernel mode.

I thought that maybe it's the problem with my TSS. I set it as follows:

Code:
memset(&tss_entry, 0, sizeof(tss_entry));
tss_entry.rsp0 = (uint64_t) &kernel_stack + 0x4000;
   
GDT.tss.limit_low = limit & 0xFFFF;
GDT.tss.base_low = base & 0xFFFF;
GDT.tss.base_middle = (base >> 16) & 0xFF;
GDT.tss.access = 0xE9;
GDT.tss.granularity = (limit >> 16) & 0xF;
GDT.tss.base_high = (base >> 24) & 0xFF;
*((uint64_t*) &GDT.tssu) = (base >> 32);

flush_tss();


I have no other idea what might be causing this error.


Top
 Profile  
 
 Post subject: Re: Privileged intruction in user mode leads to triple fault
PostPosted: Fri Jul 09, 2021 10:53 am 
Offline
Member
Member

Joined: Sat Nov 21, 2009 5:11 pm
Posts: 852
(Edit: never mind, I don't know)


Top
 Profile  
 
 Post subject: Re: Privileged intruction in user mode leads to triple fault
PostPosted: Fri Jul 09, 2021 11:07 am 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 1071
Did you set SS in TSS?

_________________
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg


Top
 Profile  
 
 Post subject: Re: Privileged intruction in user mode leads to triple fault
PostPosted: Fri Jul 09, 2021 11:28 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
Have you tried running it in a VM that can log exceptions (such as QEMU with "-d int") to see exactly which exceptions are causing the triple fault?

(There's no SS in a 64-bit TSS.)


Top
 Profile  
 
 Post subject: Re: Privileged intruction in user mode leads to triple fault
PostPosted: Fri Jul 09, 2021 11:49 am 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 1071
Octocontrabass wrote:
(There's no SS in a 64-bit TSS.)

Oops, I forgot that. Its been a while since I worked in Long Mode.

_________________
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg


Top
 Profile  
 
 Post subject: Re: Privileged intruction in user mode leads to triple fault
PostPosted: Fri Jul 09, 2021 3:08 pm 
Offline
Member
Member

Joined: Sun May 24, 2020 9:11 am
Posts: 61
Location: /dev/null
Quote:
Have you tried running it in a VM that can log exceptions (such as QEMU with "-d int") to see exactly which exceptions are causing the triple fault?


1. General Protection Fault (as expected)
2. Page Fault
3. Double Fault

Thank you. I did not know about this flag. i tried multiply debugging opitons but haven't been able to check this. Now, with this information, it'll be much easier for me to track down this bug.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: 8infy, Bing [Bot], thewrongchristian and 71 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