Invalid TSS exception of which I can't see the origin

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
aramya
Posts: 2
Joined: Wed Oct 26, 2022 5:49 am
Libera.chat IRC: aramya

Invalid TSS exception of which I can't see the origin

Post by aramya »

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?
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: Invalid TSS exception of which I can't see the origin

Post by Octocontrabass »

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: Select all

asm( "ltr %w0" : : "r"(0x28) );
MichaelPetch
Member
Member
Posts: 797
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: Invalid TSS exception of which I can't see the origin

Post by MichaelPetch »

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: Select all

        tss.ss0  = 0x10;
        tss.esp0 = 0x200000;
        tss.iopb = 104;

        memset(&tss, 0, 104); 
aramya
Posts: 2
Joined: Wed Oct 26, 2022 5:49 am
Libera.chat IRC: aramya

Re: Invalid TSS exception of which I can't see the origin

Post by aramya »

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: Select all

        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.
Post Reply