Results 1 to 4 of 4
I would like to have a look at user-mode stack when an application is in kernel mode using kprobes or just some printk statements in the source. The main idea ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 04-18-2009 #1Just Joined!
- Join Date
- Apr 2009
- Posts
- 2
User mode information
I would like to have a look at user-mode stack when an application is in kernel mode using kprobes or just some printk statements in the source. The main idea is to know what my application was doing when a context switch is about to happen (e.g in schedule() method). Now, I know that in kernel mode stack/address space is switched from the user mode to kernel. So, I tried doing something like this but now sure if it should work or there is any other easy way to do this.
- user_stack = current->mm->start_task
- get_user_pages(..., user_stack, ...., pages)
- unsigned long addr = page_to_phys(page)
Any help or hint will be greatly appreciated. Thanks
- 04-18-2009 #2
The stack pointer(user stack pointer) is saved in the kernel stack during the switch..Check the Intel/AMD manuals for details...G4143
Note this applies to Intel/AMD 32 bitMake mine Arch Linux
- 04-18-2009 #3Just Joined!
- Join Date
- Apr 2009
- Posts
- 2
The hard part seems to be accessing physical memory containing this stack pointer. Any idea?
- 04-18-2009 #4
If your operating in kernel mode you literally dereference the stack pointer to the point at which the user stack(user %esp) is saved. Once you have the value for the user %esp you have the the user stack...you shouldn't have to deal with physical memory even if you did the processor couldn't translate it(physical memory) while paging is enabled...G4143
Make mine Arch Linux


Reply With Quote

