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@.
This commit is contained in:
jym 2009-08-05 20:15:36 +00:00
parent 8b926bc93c
commit bba2c41d59
6 changed files with 44 additions and 19 deletions

View File

@ -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"
@ -18,6 +18,13 @@ options MSGBUFSIZE=24576
#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
#options CONSDEVNAME="\"xencons\""

View File

@ -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
@ -29,6 +29,16 @@ makeoptions CPUFLAGS="-march=i686"
#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
#options CONSDEVNAME="\"xencons\""

View File

@ -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 @@ struct cpu_attach_args {
#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

View File

@ -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 @@ check_pa_acc(paddr_t pa, vm_prot_t prot)
void
x86_init(void)
{
#ifndef XEN
msr_cpu_broadcast_initmtx();
#endif
}
#ifdef MODULAR

View File

@ -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
@ -57,15 +57,6 @@ defflag opt_intel_odcm.h XXXINTEL_ONDEMAND_CLOCKMOD
# 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

View File

@ -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 @@ defflag opt_pcifixup.h PCI_ADDR_FIXUP PCI_BUS_FIXUP
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/des/arch/i386/des_cbc.S des
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
@ -276,6 +293,8 @@ attach vcpu at xendevbus
file arch/xen/x86/cpu.c cpu | vcpu
file arch/x86/x86/msr_ipifuncs.c
#
# Compatibility modules
#