Subject: kern/36995: ENHANCED_SPEEDSTEP dangerous on newer Core 2 Duo CPUs
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <jmcneill@invisible.ca>
List: netbsd-bugs
Date: 09/17/2007 01:55:00
>Number:         36995
>Category:       kern
>Synopsis:       ENHANCED_SPEEDSTEP dangerous on newer Core 2 Duo CPUs
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 17 01:55:00 +0000 2007
>Originator:     jmcneill@invisible.ca
>Release:        NetBSD 4.99.30
>Organization:
	
>Environment:
	
	
System: NetBSD black.invisible.ca 4.99.30 NetBSD 4.99.30 (GENERIC) #47: Sun Sep 16 21:41:28 EDT 2007 jmcneill@black.invisible.ca:/export/home/jmcneill/branches/jmcneill-pm/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
Later Core 2 Duo CPUs appear to have the ability to overclock
themselves using the enhanced speedstep API:

cpu0 at mainbus0 apid 0: (boot processor)
cpu0: Intel(R) Core(TM)2 Duo CPU     T7100  @ 1.80GHz, 1795.65 MHz
cpu0: features: bffbfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR>
cpu0: features: bffbfbff<PGE,MCA,CMOV,PAT,PSE36,CFLUSH,B20,DS,ACPI,MMX>
cpu0: features: bffbfbff<FXSR,SSE,SSE2,SS,HTT,TM,SBF>
cpu0: features2: e3bd<SSE3,MONITOR,DS-CPL,VMX,EST,TM2,xTPR,PDCM>
cpu0: features3: bffbfbff<SYSCALL/SYSRET,XD,EM64T>
cpu0: L2 cache 2 MB 64B/line 8-way
cpu0: Enhanced SpeedStep (1420 mV) 2000 MHz
cpu0: unknown Enhanced SpeedStep CPU.
est_init_main: bus_clock = 20000
est_init_main: idlo = 0x617
est_init_main: lo  1068 mV, 1200 MHz
est_init_main: raw   23   ,    6    
est_init_main: idhi = 0xa2d
est_init_main: hi  1420 mV, 2000 MHz
est_init_main: raw   45   ,   10    
est_init_main: cur  = 0xa2d
est_init_main: fake entry 0: 1420 mV, 2000 MHz  MSR*100 mV = 1000 freq = 4500
est_init_main: fake entry 1: 1340 mV, 1800 MHz  MSR*100 mV =  900 freq = 3951
est_init_main: fake entry 2: 1260 mV, 1600 MHz  MSR*100 mV =  800 freq = 3402
est_init_main: fake entry 3: 1164 mV, 1400 MHz  MSR*100 mV =  700 freq = 2853
est_init_main: fake entry 4: 1084 mV, 1200 MHz  MSR*100 mV =  600 freq = 2304
cpu0: Enhanced SpeedStep frequencies available (MHz): 2000 1800 1600 1400 1200

machdep.est.frequency.target = 2000
machdep.est.frequency.current = 2000
machdep.est.frequency.available = 2000 1800 1600 1400 1200

Since both ENHANCED_SPEEDSTEP and sysutils/estd assume that the highest value
reported is the normal CPU speed, we erroneously overclock the CPU which
could cause serious hardware issues.

>How-To-Repeat:
Boot an i386 or amd64 kernel with a later Core 2 Duo that includes
options ENHANCED_SPEEDSTEP in the kernel.
>Fix:
Workaround: Drop machdep.est.frequency.target to a lower value at
startup, and do not run estd.
Proper fix: Unknown; is there a feature flag we can check when we calculate
est frequencies to ignore the highest value?

>Unformatted: