Page 1 of 1

Pentium III exception on PI

Posted: Thu Feb 13, 2003 4:29 pm
by Peter_Vigren
Hi, when I added exception handling (well, it prints the mnemonic and halts) to my protected mode thingy I noticed the weirdiest thing.

Exception 19 (13h), which is the Streaming SIMD Extensions fault that was added on the Pentium III, is halting my thingy. And this is on a Pentium I.

I don't understand why I get this exception... Any clues?

Re:Pentium III exception on PI

Posted: Fri Feb 14, 2003 4:08 am
by Pype.Clicker
uh ? maybe you should light a circle of candles and try to get the devil out of your motherboard ...

No clue to give ... i didn't even know about that "SIMD exception" ...
How do you know the exception number ? are you sure you're not mixing it with int 0x0D (13d) which is the General Protection Fault ?

Re:Pentium III exception on PI

Posted: Fri Feb 14, 2003 4:14 am
by Peter_Vigren
Pype.Clicker wrote: uh ? maybe you should light a circle of candles and try to get the devil out of your motherboard ...

No clue to give ... i didn't even know about that "SIMD exception" ...
How do you know the exception number ? are you sure you're not mixing it with int 0x0D (13d) which is the General Protection Fault ?
Yeah maybe... It's freaky...

I have reserved the first 19 exception and made a routine to print out their mnemonic (from that third Intel-pdf). XF is showing on the screen and that's the mnemonic (whatever that means) for exception 19 (13h).

Re:Pentium III exception on PI

Posted: Fri Feb 14, 2003 4:24 am
by Pype.Clicker
i would suggest you to print out that exception reporting function and to check with care it performs as it should ... among other things, check you didn't forget error codes, etc. and where the exception code come from ...

if it's not too large, you might attach the code ...

Re:Pentium III exception on PI

Posted: Fri Feb 14, 2003 8:14 am
by Peter_Vigren
Pype.Clicker wrote: i would suggest you to print out that exception reporting function and to check with care it performs as it should ... among other things, check you didn't forget error codes, etc. and where the exception code come from ...

if it's not too large, you might attach the code ...
I have extracted the exception handler and the IDT into the attached file. I can't find any programming error (not saying that there isn't one)...

[attachment deleted by admin]

Re:Pentium III exception on PI

Posted: Sun Feb 16, 2003 1:21 pm
by Peter_Vigren
I'm sooo stupid! You were right, Pype.Clicker. When I was looking through the code I saw that the IDT was wrong. It is the General Protection Fault that is triggered.

It occurs when I use a) ret or b) iret. Why does the return trigger a GPF??

Re:Pentium III exception on PI

Posted: Sun Feb 16, 2003 1:55 pm
by Therx
You need to save the registers before anything else in the ISR so that when you return to the program/kernel/whatever afterwards everything is the same. You can do this by pusha at the start and popa at the end. I'm not sure but you my also need to push and pop other registers. Here's my ISR code:-

Code: Select all

push gs                          ; Store all registers on stack
   push fs
   push es
   push ds
   pusha
   mov ax, GDT_DATA                 ; Set registers to known values
   mov ds, eax
   mov es, eax
   mov fs, eax
   mov gs, eax
   mov eax, %1
   push eax
   mov eax,_inthand
   call eax
   pop eax
   popa                             ; Restore all registers
   pop ds
   pop es
   pop fs
   pop gs
   iret

Re:Pentium III exception on PI

Posted: Sun Feb 16, 2003 2:03 pm
by Peter_Vigren
Therx wrote: You need to save the registers before anything else in the ISR so that when you return to the program/kernel/whatever afterwards everything is the same. You can do this by pusha at the start and popa at the end. I'm not sure but you my also need to push and pop other registers. Here's my ISR code:-

Code: Select all

push gs                          ; Store all registers on stack
   push fs
   push es
   push ds
   pusha
   mov ax, GDT_DATA                 ; Set registers to known values
   mov ds, eax
   mov es, eax
   mov fs, eax
   mov gs, eax
   mov eax, %1
   push eax
   mov eax,_inthand
   call eax
   pop eax
   popa                             ; Restore all registers
   pop ds
   pop es
   pop fs
   pop gs
   iret
But I push and pop the things I change already... and I do that in my routine that I call and try to return from too...

Re:Pentium III exception on PI

Posted: Sun Feb 16, 2003 2:26 pm
by Curufir
Peter_Vigren wrote: I'm sooo stupid! You were right, Pype.Clicker. When I was looking through the code I saw that the IDT was wrong. It is the General Protection Fault that is triggered.

It occurs when I use a) ret or b) iret. Why does the return trigger a GPF??
Most likely cause is an invalid code segment being popped off the stack. So it sounds like you've trashed the stack somewhere along the line.

Go check to make sure ESP and SS contain good values when the ret/iret occurs (Ie work through and count stack operations by hand).

Shot in the dark, but I don't see you popping the error codes certain interrupts push on the stack, so your stack pointer would end up being wrong when you reach the iret. Odd though, because those interrupts are quite rare.

Re:Pentium III exception on PI

Posted: Sun Feb 16, 2003 2:30 pm
by Peter_Vigren
Curufir wrote:
Peter_Vigren wrote: I'm sooo stupid! You were right, Pype.Clicker. When I was looking through the code I saw that the IDT was wrong. It is the General Protection Fault that is triggered.

It occurs when I use a) ret or b) iret. Why does the return trigger a GPF??
Most likely cause is an invalid code segment being popped off the stack. So it sounds like you've trashed the stack somewhere along the line.

Go check to make sure ESP and SS contain good values when the ret/iret occurs (Ie work through and count stack operations by hand).

Shot in the dark, but I don't see you popping the error codes certain interrupts push on the stack, so your stack pointer would end up being wrong when you reach the iret. Odd though, because those interrupts are quite rare.
I will check the code for some stack operation I might have missed...

The exception handler isn't supposed to try to save the system at this time, it will just halt the computer (will work out something better in the future) and then it doesn't need to pop any error codes...

Re:Pentium III exception on PI

Posted: Sun Feb 16, 2003 5:48 pm
by Peter_Vigren
Thanx for leading me right... It had to do with the fact that Esp hadn't been initialized... Now it works! *happy*