From owner-svn-src-all@FreeBSD.ORG Sat Feb 27 18:00:57 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BF8BD106564A; Sat, 27 Feb 2010 18:00:57 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AECEF8FC15; Sat, 27 Feb 2010 18:00:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1RI0v8x032346; Sat, 27 Feb 2010 18:00:57 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1RI0vKW032341; Sat, 27 Feb 2010 18:00:57 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201002271800.o1RI0vKW032341@svn.freebsd.org> From: Alan Cox Date: Sat, 27 Feb 2010 18:00:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204420 - in head/sys: amd64/amd64 i386/i386 kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Feb 2010 18:00:57 -0000 Author: alc Date: Sat Feb 27 18:00:57 2010 New Revision: 204420 URL: http://svn.freebsd.org/changeset/base/204420 Log: When running as a guest operating system, the FreeBSD kernel must assume that the virtual machine monitor has enabled machine check exceptions. Unfortunately, on AMD Family 10h processors the machine check hardware has a bug (Erratum 383) that can result in a false machine check exception when a superpage promotion occurs. Thus, I am disabling superpage promotion when the FreeBSD kernel is running as a guest operating system on an AMD Family 10h processor. Reviewed by: jhb, kib MFC after: 3 days Modified: head/sys/amd64/amd64/pmap.c head/sys/i386/i386/pmap.c head/sys/kern/subr_param.c head/sys/sys/systm.h Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Sat Feb 27 17:55:29 2010 (r204419) +++ head/sys/amd64/amd64/pmap.c Sat Feb 27 18:00:57 2010 (r204420) @@ -686,6 +686,15 @@ pmap_init(void) pv_entry_high_water = 9 * (pv_entry_max / 10); /* + * Disable large page mappings by default if the kernel is running in + * a virtual machine on an AMD Family 10h processor. This is a work- + * around for Erratum 383. + */ + if (vm_guest == VM_GUEST_VM && cpu_vendor_id == CPU_VENDOR_AMD && + CPUID_TO_FAMILY(cpu_id) == 0x10) + pg_ps_enabled = 0; + + /* * Are large page mappings enabled? */ TUNABLE_INT_FETCH("vm.pmap.pg_ps_enabled", &pg_ps_enabled); Modified: head/sys/i386/i386/pmap.c ============================================================================== --- head/sys/i386/i386/pmap.c Sat Feb 27 17:55:29 2010 (r204419) +++ head/sys/i386/i386/pmap.c Sat Feb 27 18:00:57 2010 (r204420) @@ -692,6 +692,15 @@ pmap_init(void) pv_entry_high_water = 9 * (pv_entry_max / 10); /* + * Disable large page mappings by default if the kernel is running in + * a virtual machine on an AMD Family 10h processor. This is a work- + * around for Erratum 383. + */ + if (vm_guest == VM_GUEST_VM && cpu_vendor_id == CPU_VENDOR_AMD && + CPUID_TO_FAMILY(cpu_id) == 0x10) + pg_ps_enabled = 0; + + /* * Are large page mappings enabled? */ TUNABLE_INT_FETCH("vm.pmap.pg_ps_enabled", &pg_ps_enabled); Modified: head/sys/kern/subr_param.c ============================================================================== --- head/sys/kern/subr_param.c Sat Feb 27 17:55:29 2010 (r204419) +++ head/sys/kern/subr_param.c Sat Feb 27 18:00:57 2010 (r204420) @@ -74,10 +74,6 @@ __FBSDID("$FreeBSD$"); #define MAXFILES (maxproc * 2) #endif -/* Values of enum VM_GUEST members are used as indices in - * vm_guest_sysctl_names */ -enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN }; - static int sysctl_kern_vm_guest(SYSCTL_HANDLER_ARGS); int hz; @@ -137,6 +133,10 @@ SYSCTL_PROC(_kern, OID_AUTO, vm_guest, C */ struct buf *swbuf; +/* + * The elements of this array are ordered based upon the values of the + * corresponding enum VM_GUEST members. + */ static const char *const vm_guest_sysctl_names[] = { "none", "generic", Modified: head/sys/sys/systm.h ============================================================================== --- head/sys/sys/systm.h Sat Feb 27 17:55:29 2010 (r204419) +++ head/sys/sys/systm.h Sat Feb 27 18:00:57 2010 (r204420) @@ -63,6 +63,9 @@ extern int bootverbose; /* nonzero to p extern int maxusers; /* system tune hint */ extern int ngroups_max; /* max # of supplemental groups */ +extern int vm_guest; /* Running as virtual machine guest? */ + +enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN }; #ifdef INVARIANTS /* The option is always available */ #define KASSERT(exp,msg) do { \