NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/52919: modular procfs gets cpuinfo wrong

>Number:         52919
>Category:       kern
>Synopsis:       modular procfs gets cpuinfo wrong
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 12 09:50:00 +0000 2018
>Originator:     Paul Goyette
>Release:        NetBSD 8.99.7
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:          |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org |
System: NetBSD 8.99.7 NetBSD 8.99.7 (SPEEDY 2017-11-29 22:03:05 UTC) #0: Wed Nov 29 23:14:50 UTC 2017 amd64
Architecture: x86_64
Machine: amd64
Due to conditional compilation of the struct cpu_info structure, some fields
can be misaligned between kernel and module, resulting in wrong data being
referenced.  For example, on x86, the XEN and SVS kernel options control the
inclusion of certain fields, and a modular cpuinfo reports various incorrect

processor       : 15
vendor_id       : ÿÿÿÿ
cpu family      : 2
model           : 15
model name      : Intel(R) Core(TM) i7-6900K CPU @ 3.20GHz
stepping        : 0
cpu MHz         : 3483.18
apicid          : 15
initial apicid  : 15
fpu             : yes
fpu_exception   : yes
cpuid level     : 570624
wp              : yes
flags           : fpu apic mtrr pge mca pat pse36 pn clflush dts acpi mmx mmxext monitor ace cmp_legacy 3dnowprefetch osvw cqm xsaveopt cqm_llc cqm_occup_llc dtherm ida arat pln pts 
clflush size    : 524288

Compare the vendor_id, family, model, stepping, and cache-line size to the
output returned by cpuctl:

cpu0: highest basic info 00000014
cpu0: highest extended info 80000008
cpu0: "Intel(R) Core(TM) i7-6900K CPU @ 3.20GHz"
cpu0: Intel Xeon E[57] v4 (Broadwell), Core i7-69xx Extreme (686-class), 3198.27 MHz
cpu0: family 0x6 model 0x4f stepping 0x1 (id 0x406f1)
cpu0: features 0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE>
cpu0: features 0xbfebfbff<MCA,CMOV,PAT,PSE36,CLFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2>
cpu0: features 0xbfebfbff<SS,HTT,TM,SBF>
cpu0: features1 0x7ffefbbf<SSE3,PCLMULQDQ,DTES64,MONITOR,DS-CPL,VMX,EST,TM2>
cpu0: features1 0x7ffefbbf<SSSE3,SDBG,FMA,CX16,xTPR,PDCM,PCID,DCA,SSE41,SSE42>
cpu0: features1 0x7ffefbbf<F16C,RDRAND>
cpu0: features2 0x2c100800<SYSCALL/SYSRET,XD,P1GB,RDTSCP,EM64T>
cpu0: features3 0x121<LAHF,LZCNT,PREFETCHW>
cpu0: features5 0x21cbfbb<FSGSBASE,TSCADJUST,BMI1,HLE,AVX2,SMEP,BMI2,ERMS>
cpu0: xsave features 0x7<x87,SSE,AVX>
cpu0: xsave instructions 0x1<XSAVEOPT>
cpu0: xsave area size: current 832, maximum 832, xgetbv enabled
cpu0: enabled xsave 0x7<x87,SSE,AVX>
cpu0: I-cache 32KB 64B/line 8-way, D-cache 32KB 64B/line 8-way
cpu0: L2 cache 256KB 64B/line 8-way
cpu0: L3 cache 20MB 64B/line 20-way
cpu0: 64B prefetching
cpu0: ITLB 64 4KB entries 8-way, 2M/4M: 8 entries
cpu0: DTLB 64 4KB entries 4-way
cpu0: L2 STLB 1536 4KB entries 6-way
cpu0: L1 1GB page DTLB 4 1GB entries 4-way
cpu0: Initial APIC ID 0
cpu0: Cluster/Package ID 0
cpu0: Core ID 0
cpu0: SMT ID 0
cpu0: DSPM-ecx 0x9<HWF,EPB>
cpu0: SEF highest subleaf 00000000
cpu0: microcode version 0xb000021, platform ID 2

(Note also that the text version of the processor name has the correct
CPU speed - 3.20GHz, yet the numeric version reports 3843.18MHz

A built-in version of the same module reports correct values, since the
kernel and module code are built with the same options, resulting in no
(For example) build a x86 kernel with SVS, DIAGNOSTIC, and LOCKDEBUG, but
without a built-in procfs.  Boot the kernel, mount /proc (ie, autoload the
procfs module), and `cat /proc/cpuinfo`

Please note that I have not exhaustively investigated other processor
architectures to determine what, if any, alignment issue might exist.
1. Update the structure definition to be insensitive to kernel options,
   (ie, include all fields, whether or not they're used), or
2. Include (a copy of) the MD routines for loading the cpuinfo structure
   within the module itself, or
3. Other alternatives?


Home | Main Index | Thread Index | Old Index