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
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 bit
The hard part seems to be accessing physical memory containing this stack pointer. Any idea?
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
Originally Posted by phyizal