Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 Feb 2010 18:00:57 +0000 (UTC)
From:      Alan Cox <alc@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r204420 - in head/sys: amd64/amd64 i386/i386 kern sys
Message-ID:  <201002271800.o1RI0vKW032341@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 {						\



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002271800.o1RI0vKW032341>