I am here to ask again for help. I don't come here for a few months because I simply could find an answer without bothering you guys. But now the time has come .
I am trying to implement user-space threads in my kernel ( running in CPL=3 ). Basically what I'm trying to do is creating a task within my scheduler, but running with ring 3 segments and a stack in the user-space addresses ( the scheduler already works with kernel-mode threads ). But as soon as i make the call to sched_create_task ( the function that spawns a new task inside the scheduler).
Also in case you are wondering, task is the same thing as a thread.
My problem is that i get a GPF when the scheduler is switching tasks, with the error code indicating that the segment 0x20 doesn't exist in my GDT.
This is my GDT ( indicated by bochs ):
Code: Select all
Global Descriptor Table (base=0x00000000c0111aa0, limit=47):
GDT[0x00]=??? descriptor hi=0x00000000, lo=0x00000000
GDT[0x01]=Code segment, base=0x00000000, limit=0xffffffff, Execute/Read, Non-Conforming, Accessed, 32-bit
GDT[0x02]=Data segment, base=0x00000000, limit=0xffffffff, Read/Write, Accessed
GDT[0x03]=Code segment, base=0x00000000, limit=0xffffffff, Execute/Read, Non-Conforming, Accessed, 32-bit
GDT[0x04]=Data segment, base=0x00000000, limit=0xffffffff, Read/Write
GDT[0x05]=32-Bit TSS (Busy) at 0xc0111a20, length 0x11a88
Code: Select all
00175322448e[CPU0 ] check_cs(0x0023): not a valid code segment !
https://github.com/PedroFalcato/Spartix ... l/kernel.c - line 195
https://github.com/PedroFalcato/Spartix ... cheduler.c
I think i supplied enough information, but if you need more, just ask.
Thanks for all the help,
TheRussianFail