Re: RFC: Adding a hw.features[2] sysctl

From: Peter Wemm <peter_at_wemm.org>
Date: Sat, 12 Jan 2008 23:10:33 -0800
On Jan 12, 2008 10:44 PM, Kostik Belousov <kostikbel_at_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_at_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_at_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_at_wemm.org; peter_at_FreeBSD.org; peter_at_yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5
Received on Sun Jan 13 2008 - 06:10:35 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:25 UTC