From owner-freebsd-hackers@FreeBSD.ORG Tue May 3 17:43:44 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 5089D10656B7; Tue, 3 May 2011 17:43:44 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 28BB68FC17; Tue, 3 May 2011 17:43:42 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p43HhdYD086134 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 3 May 2011 20:43:39 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id p43Hhdpq082417; Tue, 3 May 2011 20:43:39 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p43Hhd4S082416; Tue, 3 May 2011 20:43:39 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 3 May 2011 20:43:39 +0300 From: Kostik Belousov To: John Baldwin Message-ID: <20110503174339.GI48734@deviant.kiev.zoral.com.ua> References: <4DBFFEC2.4010506@soeberg.net> <201105031144.32862.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="eVUvLhJy3aWqIBaz" Content-Disposition: inline In-Reply-To: <201105031144.32862.jhb@freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua 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 17:43:44 -0000 --eVUvLhJy3aWqIBaz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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, > >=20 > > I've been using the following poor-man's approach in my driver init for= =20 > > ages in an attempt at detecting PAE option on BSD 6 (or greater) i386= =20 > > kernels, as I depend on dmabus(9) but provide a loadable kernel module = only. > >=20 > > >>> > > if (sizeof(void*) =3D=3D 4) { > > if (((uint64_t)(cnt.v_page_count * cnt.v_page_size) / 1073741824)= =20 > > >=3D 4) { > > printf("FreeBSD i386 detected with PAE option enabled. FreeBSD= =20 > > PAE type\n"); > > printf("kernels does not support loadable modules which use DMA.= =20 > > Please\n"); > > printf("reconfigure your kernel for non-PAE or switch to amd64= =20 > > kernel.\n"); > > return EFAULT; > > } > > } > > <<< >=20 > Hmmm, even this isn't really accurate as some folks may choose to enable = PAE > even with < 4GB to get PG_NX functionality. > =20 > > afaik there's a sysctl method of checking this per BSD7 (or is it 8?),= =20 > > but what about BSD6? Any hints on how I can runtime detect the above? >=20 > Definitely a kern.features.pae sysctl in 7. I don't see anything similar= in=20 > 6. =20 Read %cr4 and test the bit there. --eVUvLhJy3aWqIBaz Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk3APsoACgkQC3+MBN1Mb4hFawCg0x+eKns4F9qgvH1Rja+R+Gi2 KZgAn0ndc1NnvKZdnycp8UElct80n9bE =ZARE -----END PGP SIGNATURE----- --eVUvLhJy3aWqIBaz--