OSDev.org

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

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Invalid TSS exception of which I can't see the origin
PostPosted: Wed Oct 26, 2022 6:22 am 
Offline

Joined: Wed Oct 26, 2022 5:49 am
Posts: 2
My problem is specifically with the context switching that must be done when an interrupt arrives in usermode: -d int indicates to me that a 0xa exception is happening.

Yet, I am certain that my TSS is well-formed, and that the ESP I'm providing is a correct address that is mapped as kernel's. Moreover, my interrupts handling is correctly called if I try to STI while still in kernel mode, which suggest that the problem comes exclusively from my TSS.

I really don't know from where this could come. Here is where I am setting up a TSS entry: https://github.com/thamugadi/mel/blob/main/gdt/gdt.c

Here is a dump of -d int -M smm=off : https://pastebin.com/PpA2irNP
I notice that it keeps jumping for no reason to 0xefb51 after the reset following the Invalid TSS exception.

Does anyone have any idea what's going on?


Top
 Profile  
 
 Post subject: Re: Invalid TSS exception of which I can't see the origin
PostPosted: Wed Oct 26, 2022 8:02 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
I don't know if this is the problem, but your TSS DPL should be 0.

I don't think this is the problem , but this inline assembly is wrong. It should look like this:
Code:
asm( "ltr %w0" : : "r"(0x28) );


Top
 Profile  
 
 Post subject: Re: Invalid TSS exception of which I can't see the origin
PostPosted: Wed Oct 26, 2022 10:16 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
This looks suspicious unless I don't understand your memset. You set up the TSS by initializing members and then you set the whole thing to zero?
Code:
        tss.ss0  = 0x10;
        tss.esp0 = 0x200000;
        tss.iopb = 104;

        memset(&tss, 0, 104);


Top
 Profile  
 
 Post subject: Re: Invalid TSS exception of which I can't see the origin
PostPosted: Thu Oct 27, 2022 1:18 pm 
Offline

Joined: Wed Oct 26, 2022 5:49 am
Posts: 2
MichaelPetch wrote:
This looks suspicious unless I don't understand your memset. You set up the TSS by initializing members and then you set the whole thing to zero?
Code:
        tss.ss0  = 0x10;
        tss.esp0 = 0x200000;
        tss.iopb = 104;

        memset(&tss, 0, 104);


Sometimes I really don't pay attention to obvious things like that. Thank you very much for pointing this out: it solved the problem.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: SemrushBot [Bot] and 60 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