Date: Sat, 12 Jan 2008 23:10:33 -0800 From: "Peter Wemm" <peter@wemm.org> To: "Kostik Belousov" <kostikbel@gmail.com> Cc: Joe Marcus Clarke <marcus@freebsd.org>, current <current@freebsd.org> Subject: Re: RFC: Adding a hw.features[2] sysctl Message-ID: <e7db6d980801122310s74b6e059m93a2a401a910eb73@mail.gmail.com> In-Reply-To: <20080113064450.GW57756@deviant.kiev.zoral.com.ua> References: <1200197787.67286.13.camel@shumai.marcuscom.com> <20080113064450.GW57756@deviant.kiev.zoral.com.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
On Jan 12, 2008 10:44 PM, Kostik Belousov <kostikbel@gmail.com> 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<SSE3,RSVD2,MON,DS_CPL,CNXT-ID> > > hw.features: > > 0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE> > > > > 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<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2> AMD Features=0xe0500800<SYSCALL,NX,MMX+,LM,3DNow!+,3DNow!> 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<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT> Features2=0x2001<SSE3,CX16> AMD Features=0xea500800<SYSCALL,NX,MMX+,FFXSR,RDTSCP,LM,3DNow!+,3DNow!> AMD Features2=0x1f<LAHF,CMP,SVM,ExtAPIC,CR8> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?e7db6d980801122310s74b6e059m93a2a401a910eb73>