Wed Aug 5 20:15:37 2009 UTC ()
Add Intel SpeedStep and AMD PowerNow! support in Xen dom0. MSR operations
are now compiled in by default.

Note that MSR support in Xen depends on its version. rdmsr() should always
succeed, but wrmsr() to certain registers can end in a NOOP. In that case,
the error will be logged (see xm dmesg).

Setting CPU frequency (SpeedStep) requires Xen 3.3 with the option
cpufreq="dom0-kernel" passed down to hypervisor during boot.

Compiled and tested for SpeedStep under i386 for XEN3_DOM0 and XEN3PAE_DOM0
by jym@. amd64 was tested by Joel Carnat.

See also http://mail-index.netbsd.org/port-xen/2009/08/02/msg005213.html .

Commit requested by bouyer@.


(jym)
diff -r1.42 -r1.43 src/sys/arch/amd64/conf/XEN3_DOM0
diff -r1.18 -r1.19 src/sys/arch/i386/conf/XEN3_DOM0
diff -r1.28 -r1.29 src/sys/arch/x86/include/cpuvar.h
diff -r1.32 -r1.33 src/sys/arch/x86/x86/x86_machdep.c
diff -r1.20 -r1.21 src/sys/arch/xen/conf/files.compat
diff -r1.102 -r1.103 src/sys/arch/xen/conf/files.xen

cvs diff -r1.42 -r1.43 src/sys/arch/amd64/conf/XEN3_DOM0 (expand / switch to context diff)
--- src/sys/arch/amd64/conf/XEN3_DOM0 2009/04/20 20:50:37 1.42
+++ src/sys/arch/amd64/conf/XEN3_DOM0 2009/08/05 20:15:36 1.43
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOM0,v 1.42 2009/04/20 20:50:37 cegger Exp $
+# $NetBSD: XEN3_DOM0,v 1.43 2009/08/05 20:15:36 jym Exp $
 
 include 	"arch/amd64/conf/std.xen"
 
@@ -17,6 +17,13 @@
 
 #options 	VM86		# virtual 8086 emulation
 #options 	USER_LDT	# user-settable LDT; used by WINE
+
+# Enhanced SpeedStep Technology in the Pentium M
+options		ENHANCED_SPEEDSTEP
+#options	EST_FREQ_USERWRITE	# any user can set frequency
+
+# AMD PowerNow! and Cool`n'Quiet technology
+options		POWERNOW_K8
 
 #options 	MTRR		# memory-type range register syscall support
 

cvs diff -r1.18 -r1.19 src/sys/arch/i386/conf/Attic/XEN3_DOM0 (expand / switch to context diff)
--- src/sys/arch/i386/conf/Attic/XEN3_DOM0 2009/07/29 13:37:57 1.18
+++ src/sys/arch/i386/conf/Attic/XEN3_DOM0 2009/08/05 20:15:36 1.19
@@ -1,4 +1,4 @@
-#	$NetBSD: XEN3_DOM0,v 1.18 2009/07/29 13:37:57 cegger Exp $
+#	$NetBSD: XEN3_DOM0,v 1.19 2009/08/05 20:15:36 jym Exp $
 #
 #	XEN3_0: Xen 3.0 domain0 kernel
 
@@ -28,6 +28,16 @@
 
 #options 	VM86		# virtual 8086 emulation
 #options 	USER_LDT	# user-settable LDT; used by WINE
+
+# Enhanced SpeedStep Technology in the Pentium M
+options		ENHANCED_SPEEDSTEP
+#options	EST_FREQ_USERWRITE	# any user can set frequency
+
+# AMD PowerNow! K7
+options		POWERNOW_K7
+
+# AMD PowerNow! and Cool`n'Quiet technology
+options		POWERNOW_K8
 
 #options 	MTRR		# memory-type range register syscall support
 

cvs diff -r1.28 -r1.29 src/sys/arch/x86/include/cpuvar.h (expand / switch to context diff)
--- src/sys/arch/x86/include/cpuvar.h 2009/03/11 03:34:43 1.28
+++ src/sys/arch/x86/include/cpuvar.h 2009/08/05 20:15:36 1.29
@@ -1,4 +1,4 @@
-/* 	$NetBSD: cpuvar.h,v 1.28 2009/03/11 03:34:43 yamt Exp $ */
+/* 	$NetBSD: cpuvar.h,v 1.29 2009/08/05 20:15:36 jym Exp $ */
 
 /*-
  * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
@@ -88,8 +88,8 @@
 
 #if defined(_KERNEL_OPT)
 #include "opt_multiprocessor.h"
-#ifndef XEN
 #include "opt_enhanced_speedstep.h"
+#ifndef XEN
 #include "opt_intel_coretemp.h"
 #include "opt_intel_odcm.h"
 #endif

cvs diff -r1.32 -r1.33 src/sys/arch/x86/x86/x86_machdep.c (expand / switch to context diff)
--- src/sys/arch/x86/x86/x86_machdep.c 2009/06/20 13:10:14 1.32
+++ src/sys/arch/x86/x86/x86_machdep.c 2009/08/05 20:15:36 1.33
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_machdep.c,v 1.32 2009/06/20 13:10:14 cegger Exp $	*/
+/*	$NetBSD: x86_machdep.c,v 1.33 2009/08/05 20:15:36 jym Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.32 2009/06/20 13:10:14 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.33 2009/08/05 20:15:36 jym Exp $");
 
 #include "opt_modular.h"
 
@@ -130,9 +130,7 @@
 void
 x86_init(void)
 {
-#ifndef XEN
 	msr_cpu_broadcast_initmtx();
-#endif
 }
 
 #ifdef MODULAR

cvs diff -r1.20 -r1.21 src/sys/arch/xen/conf/files.compat (expand / switch to context diff)
--- src/sys/arch/xen/conf/files.compat 2009/07/29 12:02:06 1.20
+++ src/sys/arch/xen/conf/files.compat 2009/08/05 20:15:37 1.21
@@ -1,4 +1,4 @@
-#	$NetBSD: files.compat,v 1.20 2009/07/29 12:02:06 cegger Exp $
+#	$NetBSD: files.compat,v 1.21 2009/08/05 20:15:37 jym Exp $
 #	NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp 
 
 # options for MP configuration through the MP spec
@@ -56,15 +56,6 @@
 
 # Intel On Die Temperature sensor
 defflag opt_intel_coretemp.h		XXXINTEL_CORETEMP
-
-# AMD Powernow/Cool`n'Quiet Technology
-defflag opt_powernow_k8.h	XXPOWERNOW_K8
-
-# Intel Enhanced Speedstep
-defflag	opt_enhanced_speedstep.h XXXENHANCED_SPEEDSTEP
-defflag opt_est.h		XXXEST_FREQ_USERWRITE
-
-defflag opt_powernow_k7.h XXXPOWERNOW_K7
 
 # Multiboot support
 defflag 	opt_multiboot.h		XXXMULTIBOOT

cvs diff -r1.102 -r1.103 src/sys/arch/xen/conf/files.xen (expand / switch to context diff)
--- src/sys/arch/xen/conf/files.xen 2009/07/29 12:02:06 1.102
+++ src/sys/arch/xen/conf/files.xen 2009/08/05 20:15:37 1.103
@@ -1,4 +1,4 @@
-#	$NetBSD: files.xen,v 1.102 2009/07/29 12:02:06 cegger Exp $
+#	$NetBSD: files.xen,v 1.103 2009/08/05 20:15:37 jym Exp $
 #	NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp 
 #	NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp 
 
@@ -26,6 +26,18 @@
 
 defparam		PCI_CONF_MODE
 
+# Intel Enhanced Speedstep
+defflag					ENHANCED_SPEEDSTEP
+defflag	opt_est.h			EST_FREQ_USERWRITE
+file	arch/x86/x86/est.c		enhanced_speedstep
+file	arch/x86/x86/intel_busclock.c	enhanced_speedstep
+
+# AMD Powernow/Cool`n'Quiet Technology
+defflag opt_powernow_k8.h	POWERNOW_K8
+# Powernow common functions
+file	arch/x86/x86/powernow_k8.c	powernow_k8
+file	arch/x86/x86/powernow_common.c	powernow_k8 | powernow_k7
+
 file	arch/xen/x86/autoconf.c
 ifdef i386
 file	arch/i386/i386/aout_machdep.c	exec_aout
@@ -60,6 +72,11 @@
 
 file	crypto/blowfish/arch/i386/bf_enc.S	blowfish
 file	crypto/blowfish/arch/i386/bf_cbc.S	blowfish
+
+# AMD PowerNow K7
+defflag					POWERNOW_K7
+file	arch/i386/i386/powernow_k7.c		powernow_k7
+
 elifdef amd64
 file	arch/amd64/amd64/busfunc.S
 file	arch/amd64/amd64/cpufunc.S
@@ -275,6 +292,8 @@
 attach vcpu at xendevbus
 
 file	arch/xen/x86/cpu.c		cpu | vcpu
+
+file	arch/x86/x86/msr_ipifuncs.c
 
 #
 # Compatibility modules