From owner-freebsd-current@FreeBSD.ORG Fri Jan 30 15:20:40 2015 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7CD9D3FB; Fri, 30 Jan 2015 15:20:40 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 55726A22; Fri, 30 Jan 2015 15:20:40 +0000 (UTC) Received: from new-host-3.home (pool-173-54-116-245.nwrknj.fios.verizon.net [173.54.116.245]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 59D80B94E; Fri, 30 Jan 2015 10:20:39 -0500 (EST) Message-ID: <54CBA14B.7030608@FreeBSD.org> Date: Fri, 30 Jan 2015 10:20:43 -0500 From: John Baldwin User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Yue Chen , 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? References: In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 30 Jan 2015 10:20:39 -0500 (EST) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Jan 2015 15:20:40 -0000 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