what is the job of ESPn and SSn in TSS?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
amirsadig

what is the job of ESPn and SSn in TSS?

Post by amirsadig »

I don't need to declare my question ;D. n is for 0, 1, 2
richie

Re:what is the job of ESPn and SSn in TSS?

Post by richie »

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.
amirsadig

Re:what is the job of ESPn and SSn in TSS?

Post by amirsadig »

thanks for details, so I have understand how fork() function work.
Peter_Vigren

Re:what is the job of ESPn and SSn in TSS?

Post by Peter_Vigren »

richie wrote: (You can specify how many parameters are copied from the user stack to the new kernel-function stack.)
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?
User avatar
Pype.Clicker
Member
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?

Post by Pype.Clicker »

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.
richie

Re:what is the job of ESPn and SSn in TSS?

Post by richie »

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.
Post Reply