How to know the address ranges of kernel stacks, for user processes and kernel threads?

John Baldwin jhb at FreeBSD.org
Fri Jan 30 15:20:40 UTC 2015


On 1/28/15 7:54 PM, Yue Chen wrote:
> How can we know the kernel stack ranges for user process and kernel threads
> under FreeBSD x86_64?
> 
> It seems that each kernel stack has two pages (IA-32) to use. Does x86_64
> still have two pages or more? And how can we find the address of these two
> pages from a kernel module?

In 'struct thread' there is td_kstack_pages and td_kstack.  If you grep
for those and see where they are initialized that will lead you to find
in the source what the defaults are for amd64 (and you can also use
those in your kernel module).  Note that some kthreads have a different
sized stack, so using the members in struct thread is probably what you
want to do regardless.

-- 
John Baldwin


More information about the freebsd-current mailing list