Page 1 of 2

interrupt(): SS selector null

Posted: Mon Feb 11, 2008 5:56 pm
by sancho1980
Hi

I have a ring3 task thats executing a pointless loop, just to try the privilege/task-switching mechanisms out.
I have given the task a level0-stack:

Code: Select all

	task1state: tss_t := tss_t:[
					0,
					0,
					$fffffffc,
					IDX_KERNELSTACK*@size(segdesc),
					0,
					0,
					0,
					0,
					0,
					0,
					0,
					0,
					&task1,
					$200,
					0,
					0,
					0,
					0,
					$fffffffc,
					0,
					0,
					0,
					IDX_PRIV3DATA*@size(segdesc) + 3,
					0,
					IDX_PRIV3CODE*@size(segdesc) + 3,
					0,
					IDX_TASK1STACK*@size(segdesc) + 3,
					0,
					IDX_PRIV3DATA*@size(segdesc) + 3,
					0,
					0,
					0,
					0,
					0,
					0,
					0,
					0,
					0,
					104
				];
But when an interrupt occurs, I'm still getting bochs error:

Code: Select all

00094644500e[CPU  ] interrupt(): SS selector null
Is there something else I have to take in account?

Thanks

Martin

Posted: Mon Feb 11, 2008 6:08 pm
by Combuster
Bochs spits in your face for trying to load a 0 for SS somewhere. Have you actually looked at the values in various fields of the TSS?

Posted: Mon Feb 11, 2008 9:50 pm
by ucosty
Your ring0 TSS that you have ltr'ed needs to have the ring 0 SS selector set.

Posted: Tue Feb 12, 2008 2:05 am
by sancho1980
yeah i know
but as you can see above, I HAVE provided a ring0 stack segment selector in the tss!

Posted: Tue Feb 12, 2008 2:19 am
by ucosty
sancho1980 wrote:yeah i know
but as you can see above, I HAVE provided a ring0 stack segment selector in the tss!
Your comment says that it is a ring 0 stack for your process. That's different.

Posted: Tue Feb 12, 2008 2:29 am
by sancho1980
what do you mean?

-the above tss is the tss of the task thats running when the interrupt occurs
-it is a ring3 task
-as you can see it has ss0/sp0 set (not null)

so what do you mean with the
ring0 TSS that you have ltr'ed
. at the time the interrupt happens, THIS (above, ring3!) is the task thats executing, and not any ring0 task

Posted: Tue Feb 12, 2008 3:19 pm
by sancho1980
hi everybody
can really no one help me?
am i understanding something wrong?

Posted: Tue Feb 12, 2008 6:24 pm
by Combuster
You are stating the opposite of what bochs tells you. The only problem you are making is that we have to believe you while bochs is IMNSHO far more reliable. So instead of blaming bochs, I really suggest you look why bochs is claiming that the new SS is the null selector. The debugger version of bochs might help you here.

Two things to look for:
1) your assumption may be plain wrong. Human error gets everyone once in a while. Just be man enough to consider the possibility.
2) Even if you loaded that TSS, and SS0 was indeed set properly, it does not need to stay that way for longer periods of time.

p.s. bumping a thread after only an hour earns you an impatient tag.

Posted: Wed Feb 13, 2008 6:15 pm
by sancho1980
i can see where you're coming from
see, i have now built into my clock handler an instruction that prints out the ss0 selector value of the currently executing task..every time the clock ticks
i am always getting the same value: 24, which is IDX_KERNELSTACK*@size(segdesc)
the reason i am posting this is not because i cannot read and understand what bochs is telling me
but i believe the underlying reason must be a different one, something i am forgetting or dont know about this stack switching mechanism
in my last few threads we saw how wrong some of the bochs errors actually are, although this time i did follow your advice and had a look into the bochs source myself, which unfortunately didnt shed any light on the problem
the ss0 field in my tss definitely has the right value, but im getting this error, thats where i stand, and i have absolutely no explanation for that :-(

Posted: Wed Feb 13, 2008 7:36 pm
by ucosty
Can you at least clarify what type of task changing method you are using, i.e Hardware or software.

Posted: Thu Feb 14, 2008 3:34 am
by pini
I suggest you try the bochs-debugger and set breakpoint at your timer isr. Then you can execute step by step and see where it happens.

My last thought about this is that maybe the error is thrown when trying to set SS back to your ring3-SS when iret-ing.

Posted: Thu Feb 14, 2008 5:00 am
by sancho1980
ucosty wrote:Can you at least clarify what type of task changing method you are using, i.e Hardware or software.
yes
i use hardware task switching
my clock handler is a task gate itself
it works by resetting the backlink field of the clock task to the task i want to execute
because a task interrupt doesnt use the stack switching, there is no problem with clock interrupts, they work fine
but my keyboard isr is a trap, so stack switching is done whenever a key is pressed..and that's when the problem occurs

Posted: Thu Feb 14, 2008 1:43 pm
by sancho1980
i am starting to think this is some kind of a privilege issue, my understanding is as follows:

when an interrupt occurs, the cpu switches over to the ss0 stack in the task state segment
this ss0 stack needs to have
ss.rpl=ss.dpl=0

no?

Posted: Fri Feb 15, 2008 2:08 am
by pini
I'd say you need ss.rpl = ss.dpl != cpl for stack switching to occur. Usually they are 0 because most kernel code runs in ring 0 (but could also be 1 or 2, provided the user task runs in ring 3, and then using ss1 or ss2 from the tss, but basically, you're right).

Posted: Sat Feb 16, 2008 11:26 am
by sancho1980
im still stuck with this
i tried something different now.
it still crashes on key int, the problem now is, i dont even see the bochs error in this output, does any of you spot it:

Code: Select all

<bochs:1> c
00000003572i[BIOS ] $Revision: 1.187 $ $Date: 2007/10/14 08:11:05 $
00000080000e[VGA  ] character height = 1, skipping text update
00000160000e[VGA  ] character height = 1, skipping text update
00000240000e[VGA  ] character height = 1, skipping text update
00000318056i[KBD  ] reset-disable command received
00000320000e[VGA  ] character height = 1, skipping text update
00000352736i[BIOS ] Starting rombios32
00000353559i[BIOS ] ram_size=0x02000000
00000354168i[BIOS ] Found 1 cpu(s)
00000400000e[VGA  ] character height = 1, skipping text update
00000480000e[VGA  ] character height = 1, skipping text update
00000560000e[VGA  ] character height = 1, skipping text update
00000640000e[VGA  ] character height = 1, skipping text update
00000641441i[VBIOS] VGABios $Id: vgabios.c,v 1.66 2006/07/10 07:47:51 vruppert Exp $
00000641512i[VGA  ] VBE known Display Interface b0c0
00000641544i[VGA  ] VBE known Display Interface b0c4
00000644469i[VBIOS] VBE Bios $Id: vbe.c,v 1.58 2006/08/19 09:39:43 vruppert Exp $
00000720000i[XGUI ] charmap update. Font Height is 16
00000800000i[XGUI ] charmap update. Font Height is 16
00001088736i[BIOS ] Booting from 0000:7c00
00035618544i[CPU  ] CPU is in protected mode (halted)
00035618544i[CPU  ] CS.d_b = 32 bit
00035618544i[CPU  ] SS.d_b = 32 bit
00035618544i[CPU  ] | EAX=00000780  EBX=00000049  ECX=00000f49  EDX=00000000
00035618544i[CPU  ] | ESP=ffffff88  EBP=ffffffa4  ESI=00000000  EDI=00000000
00035618544i[CPU  ] | IOPL=0 id vip vif ac vm RF nt of df IF tf SF zf af pf CF
00035618544i[CPU  ] | SEG selector     base    limit G D
00035618544i[CPU  ] | SEG sltr(index|ti|rpl)     base    limit G D
00035618544i[CPU  ] |  CS:0008( 0001| 0|  0) 00014700 0009b500 0 1
00035618544i[CPU  ] |  DS:0083( 0010| 0|  3) 00014700 000fffff 0 1
00035618544i[CPU  ] |  SS:0090( 0012| 0|  0) 00200000 000ffff8 1 1
00035618544i[CPU  ] |  ES:0083( 0010| 0|  3) 00014700 000fffff 0 1
00035618544i[CPU  ] |  FS:0000( 0000| 0|  0) 00000000 000fffff 1 1
00035618544i[CPU  ] |  GS:0000( 0000| 0|  0) 000b8000 000f0fa0 0 1
00035618544i[CPU  ] | EIP=00000172 (00000172)
00035618544i[CPU  ] | CR0=0x00000019 CR1=0 CR2=0x00000000
00035618544i[CPU  ] | CR3=0x00000000 CR4=0x00000000
00035618544i[CPU  ] >> mov word ptr gs:[eax], cx : 65668908
00035618544e[CPU  ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00035618544i[SYS  ] bx_pc_system_c::Reset(SOFTWARE) called
Next at t=35618544
(0) [0xfffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b         ; ea5be000f0
thanks

martin