Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm doing some novice work with ucontext and threading. I'm printing out certain register values just to practice doing it.
However, I'm confused about one of the register values in Linux, REG_UESP. For instance, I know that REG_EIP contains the address of the instruction pointer, and REG_ESP contains the address of the stack pointer.
I can't figure out what REG_UESP is, though. Is it an unsigned version of ESP? Is it the address of the last element popped off the stack?
When I print it out right now, it gives an address of 0. Does this mean it points to the first memory address, or that its value is null?
The UESP is the user stack pointer, which is only relevant when there has been a change in privilege level. If there hasn't been a change in privilege level, then this will not have been set. There is actually only one real stack pointer register, but the thread context has to keep the stack pointer from the user thread when it switches to a new stack pointer after the change in privilege level.
Note also that from the point of view of a stack pointer, '0' points to the end of virtual memory, not the beginning, since the stack pointer will predecrement. But this wouldn't be a normal value in most x86 contexts.
Last edited by neonsignal; 11-02-2012 at 04:57 AM.
Note also that from the point of view of a stack pointer, '0' points to the end of virtual memory, not the beginning, since the stack pointer will predecrement. But this wouldn't be a normal value in most x86 contexts.
Hmmm... I don't understand this last bit, Neon... You seem to be suggesting that the CPU does something other than simply copy the user-state SP value verbatim into this register as it performs the switch.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.