what is the job of ESPn and SSn in TSS?
what is the job of ESPn and SSn in TSS?
I don't need to declare my question ;D. n is for 0, 1, 2
Re:what is the job of ESPn and SSn in TSS?
In pmode you can declare special descriptors called CallGates. These Callgates define Kernelfunctions that can be called by user processes. For example you have in you user programm a instruction like 'call far 0x08:0x00'. (Like in calls to TSS-Descriptors the offset is ignord). This instruction will call the Callgate defined in the first descriptor. A callgate can be used to execute code in a higher prevelege level. The problem is what to do with the parameters. If the kernelfunction would use the stack of the user process there wouldn't be a clear seperation between user-processes and kernel-processes. (consider of a kernel-function that pushes some secret informations on the stack. These informations will stay in the user memory after the kernel-function returns). Thus if a switch from a lower preveleged process to a higher process is performed there is also a stack-switch needed. (You can specify how many parameters are copied from the user stack to the new kernel-function stack.) But where to get these new values for esp and ss? These values are stored in the TSS. So every level has its own stack. If you switch from ring 3 to ring 1 the values of esp1 and ss1 are used. The other direction wouldn't cause a change of esp and ss. Because there is no lower preveleged level than ring 3 there is no need for a esp3 or a ss3 field.
Re:what is the job of ESPn and SSn in TSS?
thanks for details, so I have understand how fork() function work.
Re:what is the job of ESPn and SSn in TSS?
How do I specify the number of parameters being copied? Will they be on the kernel stack as they were on the user stack? I mean, is the order the same?richie wrote: (You can specify how many parameters are copied from the user stack to the new kernel-function stack.)
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:what is the job of ESPn and SSn in TSS?
the order will be kept. The amount of stack-wide (32bits for a 32bits stack, ...) parameters to be copied is specified in the gate descriptor (should check the intel manual, but i think it's byte 4 in the descriptor)
I think it's for call gates only, though.
I think it's for call gates only, though.
Re:what is the job of ESPn and SSn in TSS?
And there is a maximum amount of 31 DWORDs that can be speciefied to be copied. But it's much faster to use registers as parameters.