>You discussed that kernel do not keep track of SS for process specific >kernel stack as it always starts from fixed offset of task_struct, but >does that mean, linux kernel do not make use of SS element in the TSS of >process. I think the kernel can not by-pass the rules defined by >processor. Processor expects the SS and SP elements to be right at the >time of stack switching, so we need to initialize them to the right >values while forking a process. Yes, the kernel cannot bypass the TSS entirely. >I think kernel definitely keep tracks of SS and SP for all CPU levels >including kernel mode also (ring 0), so that when we are switching form >user space to kernel space the processor can switch the stacks >automatically. At stack switching time CPU expects the SS and SP >elements of TSS to be right, it's just going to copy those values in SS >and SP registers of CPU, so that now we can push and pop the things on >the kernel stack. In Linxu , the SS and DS normally holds the same value. Mostly I have seen that,\ when in kernel mode, DS=SS=0x18 and when in user mode DS=SS=0x28 (this is what i remember !). As Linux does not believe in x86 processor recommended task switching (ie storing/retrieving all the necessary register values in a TSS) it uses the process's stack to hold the required registers. But, it cannot get away from the fact that, when a switch happens to kernel mode, the processor expects to find the SS and ESP values for that privilege level in the current TSS (the one which i pointed to be the TS register if i am correct!). In Linux, we have only one TSS per processor, and when a process is scheduled most probably the kernel sets the TSS's SS0 (SS corresponding to ring 0) as 0x18 and ESP0 will be current process's task_struct + 8K (in 2.4). Again, I have not really gone through that piece of code in the kernel, so this is my assumption. Correct me if I am wrong. -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/