Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Jan 2015 10:20:43 -0500
From:      John Baldwin <jhb@FreeBSD.org>
To:        Yue Chen <ycyc321@gmail.com>, freebsd-hackers@freebsd.org,  freebsd-current@freebsd.org
Subject:   Re: How to know the address ranges of kernel stacks, for user processes and kernel threads?
Message-ID:  <54CBA14B.7030608@FreeBSD.org>
In-Reply-To: <CAKtBrB4eKn-Zfeh1fmjiMUaU4ZMbewd3wh4%2BNzc_BpS7rtRiUA@mail.gmail.com>
References:  <CAKtBrB4eKn-Zfeh1fmjiMUaU4ZMbewd3wh4%2BNzc_BpS7rtRiUA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?54CBA14B.7030608>