From owner-freebsd-hackers@FreeBSD.ORG Tue May 3 18:39:14 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E4E90106566C for ; Tue, 3 May 2011 18:39:14 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id BAB788FC1E for ; Tue, 3 May 2011 18:39:14 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 4E90E46B39; Tue, 3 May 2011 14:39:14 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id C6C448A02B; Tue, 3 May 2011 14:39:13 -0400 (EDT) From: John Baldwin To: Kostik Belousov Date: Tue, 3 May 2011 14:25:12 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: <4DBFFEC2.4010506@soeberg.net> <201105031144.32862.jhb@freebsd.org> <20110503174339.GI48734@deviant.kiev.zoral.com.ua> In-Reply-To: <20110503174339.GI48734@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201105031425.12710.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Tue, 03 May 2011 14:39:13 -0400 (EDT) Cc: freebsd-hackers@freebsd.org, philip-freebsd1@soeberg.net Subject: Re: Runtime check for PAE option on BSD 6+ i386 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 May 2011 18:39:15 -0000 On Tuesday, May 03, 2011 1:43:39 pm Kostik Belousov wrote: > On Tue, May 03, 2011 at 11:44:32AM -0400, John Baldwin wrote: > > On Tuesday, May 03, 2011 9:10:26 am Philip Soeberg wrote: > > > Hi fellow FreeBSD hackers, > > > > > > I've been using the following poor-man's approach in my driver init for > > > ages in an attempt at detecting PAE option on BSD 6 (or greater) i386 > > > kernels, as I depend on dmabus(9) but provide a loadable kernel module only. > > > > > > >>> > > > if (sizeof(void*) == 4) { > > > if (((uint64_t)(cnt.v_page_count * cnt.v_page_size) / 1073741824) > > > >= 4) { > > > printf("FreeBSD i386 detected with PAE option enabled. FreeBSD > > > PAE type\n"); > > > printf("kernels does not support loadable modules which use DMA. > > > Please\n"); > > > printf("reconfigure your kernel for non-PAE or switch to amd64 > > > kernel.\n"); > > > return EFAULT; > > > } > > > } > > > <<< > > > > Hmmm, even this isn't really accurate as some folks may choose to enable PAE > > even with < 4GB to get PG_NX functionality. > > > > > afaik there's a sysctl method of checking this per BSD7 (or is it 8?), > > > but what about BSD6? Any hints on how I can runtime detect the above? > > > > Definitely a kern.features.pae sysctl in 7. I don't see anything similar in > > 6. > > Read %cr4 and test the bit there. Oh, cute. :) -- John Baldwin