From owner-freebsd-current@FreeBSD.ORG Sun Jan 13 07:10:35 2008 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3109B16A418 for ; Sun, 13 Jan 2008 07:10:35 +0000 (UTC) (envelope-from peter@wemm.org) Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.156]) by mx1.freebsd.org (Postfix) with ESMTP id E39A913C45A for ; Sun, 13 Jan 2008 07:10:34 +0000 (UTC) (envelope-from peter@wemm.org) Received: by fg-out-1718.google.com with SMTP id 16so1910694fgg.35 for ; Sat, 12 Jan 2008 23:10:33 -0800 (PST) Received: by 10.82.121.15 with SMTP id t15mr1742471buc.1.1200208233125; Sat, 12 Jan 2008 23:10:33 -0800 (PST) Received: by 10.82.181.17 with HTTP; Sat, 12 Jan 2008 23:10:33 -0800 (PST) Message-ID: Date: Sat, 12 Jan 2008 23:10:33 -0800 From: "Peter Wemm" To: "Kostik Belousov" In-Reply-To: <20080113064450.GW57756@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1200197787.67286.13.camel@shumai.marcuscom.com> <20080113064450.GW57756@deviant.kiev.zoral.com.ua> Cc: Joe Marcus Clarke , current Subject: Re: RFC: Adding a hw.features[2] sysctl X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 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: Sun, 13 Jan 2008 07:10:35 -0000 On Jan 12, 2008 10:44 PM, Kostik Belousov wrote: > On Sat, Jan 12, 2008 at 11:16:27PM -0500, Joe Marcus Clarke wrote: > > I find it would be useful to have the list of CPU features available via > > a sysctl. Currently, he only ways to get this information are to have > > linprocfs mounted, or parse dmesg.boot (if it exists). Attached are > Not quite true, since the raw CPU capabilities are accessible using > the cpuid instruction, both to the kernel- and user-mode. > > patches to add hw.features and hw.features2 sysctls for i386 and amd64 > > (where a list of CPU features is applicable). The results are identical > > to the Features and Features2 strings from dmesg: > > > > hw.features2: 0x41d > > hw.features: > > 0xbfebfbff > > > > Comments? > > The only part that I do not fully agree is to dedicate 1Kb of the kernel > memory to the strings that could be reconstructed in the usermode and > are relatively rare used. > > I would suggest either export only bitmask of the cpu features and do > the formatting in the sysctl(8), or implement the user-mode utility that > would pretty-print results of the cpuid execution, like cpuid from ports. > > The first option could be preferable, since kernel might disable some > features, that is not reflected in the output of cpuid instruction. > Example of this would be identcpu.c, line 860 (HTT on AMD). > It just so happens I wrote almost exactly this program a few weeks ago for somebody at work: peter@daintree[11:05pm]~-101> ./is64bit CPU: AMD Athlon(tm) 64 Processor 3200+ Origin="AuthenticAMD" Id=0xf48 Stepping = 8 Features=0x78bfbff AMD Features=0xe0500800 64 bit capable: Yes 64 bit OS: Yes peter@overcee[11:06pm]~-306> ./is64bit CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 6000+ Origin="AuthenticAMD" Id=0x40f33 Stepping = 3 Features=0x178bfbff Features2=0x2001 AMD Features=0xea500800 AMD Features2=0x1f Cores per package: 2 64 bit capable: Yes 64 bit OS: Yes It is a 32 bit 4.x 'run everywhere' binary. They wanted it for surveying machines to see which could be upgraded to a 64 bit OS. It runs silently returns status code based on 64-bit-ness if you give it the -q flag. It is a 100% cut/paste from identcpu etc. -Peter -- Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com "All of this is for nothing if we don't go to the stars" - JMS/B5