RE: problem with saving process descriptor info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




>I get process registers by doing:
>struct pt_regs *regs_pointer = ((struct pt_regs *)
>(2*PAGE_SIZE + (unsigned long) p)) - 1;   


>By comparing the results, I note that the regs.esp,
>the mm->start_stack, the p->thread->esp and the
>p->thread->esp0 differ each other. What's the meaning
>of each field? What these fields differ in?

Well, let me have a go at this!
	From your post, regs.esp = bf5ffad0, mm->start_stack = 0xbffff5a0,
p->thread->esp0 = 0xcc932000 and
p->thread->esp = 0xcc931f88.

Say, a process makes a system call and enters the kernel mode, as there is a
change in privilege level
on entering kernel mode, the stack used should also change, ie now the
process should work with the kernel
mode stack which in linux (2.4 versions atleast) is 8KB above the
task_struct. As there is a change in
the stack used, there is a need to save the earlier used user mode SS and
ESP so that the user mode stack
 can be restored when control comes back to user mode. For this, the user
mode SS and ESP values gets saved 
in the kernel mode stack and this is what you get when you print regs.esp,
which in your case is 0xbf5ffad0.

mm->stack_start is the address at which the stack begins for this process,
which in this case is 0xbffff5a0,
you can see that regs.esp value is less than mm->stack_start as the stack
grows from high to low address.

One place where p->thread->esp is used is in the switch_to macro which is
called from the schedule function.
As there is a stack switch about to take place the current process should
store its kernel mode ESP value
so that when it is selected for execution later, it can use its kernel mode
stack again. You may have
to go through the schedule function implementation to get a better idea
about this.

p->thread->esp0 in all probability should be the start of the kernel mode
stack of the process.

Any comments, corrections ??

gop



		
___________________________________ 
Nuovo Yahoo! Messenger: E' molto più divertente: Audibles, Avatar, Webcam,
Giochi, Rubrica... Scaricalo ora! 
http://it.messenger.yahoo.it

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux