[kernel] r13979 - in dists/lenny/linux-2.6-abi/debian: . patches/bugfix/x86 patches/series

Dann Frazier dannf at alioth.debian.org
Mon Jul 20 04:51:14 UTC 2009


Author: dannf
Date: Mon Jul 20 04:51:12 2009
New Revision: 13979

Log:
Fix issues with tsc clocksource on VMWare (Closes: #524542)

Added:
   dists/lenny/linux-2.6-abi/debian/patches/bugfix/x86/add-X86_FEATURE_HYPERVISOR-feature-bit.patch
   dists/lenny/linux-2.6-abi/debian/patches/bugfix/x86/add-a-synthetic-TSC_RELIABLE-feature-bit.patch
   dists/lenny/linux-2.6-abi/debian/patches/bugfix/x86/add-a-synthetic-TS_RELIABLE-feature-bit.patch
   dists/lenny/linux-2.6-abi/debian/patches/bugfix/x86/hypervisor-detection-and-get-tsc_freq-from-hypervisor.patch
   dists/lenny/linux-2.6-abi/debian/patches/bugfix/x86/skip-verification-by-the-watchdog-for-TSC-clocksource.patch
   dists/lenny/linux-2.6-abi/debian/patches/bugfix/x86/vmware-look-for-DMI-string-in-product-serial-key.patch
   dists/lenny/linux-2.6-abi/debian/patches/series/18abi
Modified:
   dists/lenny/linux-2.6-abi/debian/changelog

Modified: dists/lenny/linux-2.6-abi/debian/changelog
==============================================================================
--- dists/lenny/linux-2.6-abi/debian/changelog	Mon Jul 20 04:46:27 2009	(r13978)
+++ dists/lenny/linux-2.6-abi/debian/changelog	Mon Jul 20 04:51:12 2009	(r13979)
@@ -1,3 +1,9 @@
+linux-2.6 (2.6.26-18abi) UNRELEASED; urgency=high
+
+  * Fix issues with tsc clocksource on VMWare (Closes: #524542)
+
+ -- maximilian attems <maks at debian.org>  Wed, 10 Jun 2009 15:34:04 +0200
+
 linux-2.6 (2.6.26-18) UNRELEASED; urgency=high
 
   [ maximilian attems ]

Added: dists/lenny/linux-2.6-abi/debian/patches/bugfix/x86/add-X86_FEATURE_HYPERVISOR-feature-bit.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/lenny/linux-2.6-abi/debian/patches/bugfix/x86/add-X86_FEATURE_HYPERVISOR-feature-bit.patch	Mon Jul 20 04:51:12 2009	(r13979)
@@ -0,0 +1,33 @@
+commit 49ab56ac6e1b907b7dadb72a4012460359feaf0e
+Author: Alok Kataria <akataria at vmware.com>
+Date:   Sat Nov 1 18:34:37 2008 -0700
+
+    x86: add X86_FEATURE_HYPERVISOR feature bit
+    
+    Impact: Number declaration only.
+    
+    Add X86_FEATURE_HYPERVISOR bit (CPUID level 1, ECX, bit 31).
+    
+    Signed-off-by: H. Peter Anvin <hpa at zytor.com>
+
+Backported to Debian's 2.6.26 by dann frazier <dannf at debian.org>
+
+diff -urpN a/include/asm-x86/cpufeature.h b/include/asm-x86/cpufeature.h
+--- a/include/asm-x86/cpufeature.h	2009-07-16 14:25:56.000000000 -0600
++++ b/include/asm-x86/cpufeature.h	2009-07-16 14:28:37.000000000 -0600
+@@ -91,6 +91,7 @@
+ #define X86_FEATURE_CX16	(4*32+13) /* CMPXCHG16B */
+ #define X86_FEATURE_XTPR	(4*32+14) /* Send Task Priority Messages */
+ #define X86_FEATURE_DCA		(4*32+18) /* Direct Cache Access */
++#define X86_FEATURE_HYPERVISOR	(4*32+31) /* Running on a hypervisor */
+ 
+ /* VIA/Cyrix/Centaur-defined CPU features, CPUID level 0xC0000001, word 5 */
+ #define X86_FEATURE_XSTORE	(5*32+ 2) /* on-CPU RNG present (xstore insn) */
+@@ -188,6 +189,7 @@ extern const char * const x86_power_flag
+ #define cpu_has_gbpages		boot_cpu_has(X86_FEATURE_GBPAGES)
+ #define cpu_has_arch_perfmon	boot_cpu_has(X86_FEATURE_ARCH_PERFMON)
+ #define cpu_has_pat		boot_cpu_has(X86_FEATURE_PAT)
++#define cpu_has_hypervisor	boot_cpu_has(X86_FEATURE_HYPERVISOR)
+ 
+ #if defined(CONFIG_X86_INVLPG) || defined(CONFIG_X86_64)
+ # define cpu_has_invlpg		1

Added: dists/lenny/linux-2.6-abi/debian/patches/bugfix/x86/add-a-synthetic-TSC_RELIABLE-feature-bit.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/lenny/linux-2.6-abi/debian/patches/bugfix/x86/add-a-synthetic-TSC_RELIABLE-feature-bit.patch	Mon Jul 20 04:51:12 2009	(r13979)
@@ -0,0 +1,113 @@
+commit 2ca7545f254a0a2f754bfbdaaba15aee85397cb7
+Author: Alok Kataria <akataria at vmware.com>
+Date:   Mon Jan 26 21:00:22 2009 +0100
+
+    UBUNTU: x86: Add a synthetic TSC_RELIABLE feature bit.
+    
+    Bug: #319945
+    
+        Impact: Changes timebase calibration on Vmware.
+    
+        Use the synthetic TSC_RELIABLE bit to workaround virtualization anomalies.
+    
+        Virtual TSCs can be kept nearly in sync, but because the virtual TSC
+        offset is set by software, it's not perfect.  So, the TSC
+        synchronization test can fail. Even then the TSC can be used as a
+        clocksource since the VMware platform exports a reliable TSC to the
+        guest for timekeeping purposes. Use this bit to check if we need to
+        skip the TSC sync checks.
+    
+        Along with this also set the CONSTANT_TSC bit when on VMware, since we
+        still want to use TSC as clocksource on VM running over hardware which
+        has unsynchronized TSC's (opteron's), since the hypervisor will take
+        care of providing consistent TSC to the guest.
+    
+        Signed-off-by: Alok N Kataria <akataria at vmware.com>
+        Signed-off-by: Dan Hecht <dhecht at vmware.com>
+        Signed-off-by: H. Peter Anvin <hpa at zytor.com>
+        Acked-by: Tim Gardner <tim.gardner at canonical.com>
+        Acked-by: Stefan Bader <stefan.bader at canonical.com>
+
+Adjusted to apply to Debian's 2.6.26 by dann frazier <dannf at debian.org>
+
+diff -urpN a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
+--- a/arch/x86/kernel/cpu/hypervisor.c	2009-07-19 16:58:14.000000000 -0600
++++ b/arch/x86/kernel/cpu/hypervisor.c	2009-07-19 17:10:14.000000000 -0600
+@@ -44,7 +44,17 @@ unsigned long get_hypervisor_tsc_freq(vo
+ 	return 0;
+ }
+ 
++static inline void __cpuinit
++hypervisor_set_feature_bits(struct cpuinfo_x86 *c)
++{
++	if (boot_cpu_data.x86_hyper_vendor == X86_HYPER_VENDOR_VMWARE) {
++		vmware_set_feature_bits(c);
++		return;
++	}
++}
++
+ void __cpuinit init_hypervisor(struct cpuinfo_x86 *c)
+ {
+ 	detect_hypervisor_vendor(c);
++	hypervisor_set_feature_bits(c);
+ }
+diff -urpN a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
+--- a/arch/x86/kernel/cpu/vmware.c	2009-07-19 16:58:14.000000000 -0600
++++ b/arch/x86/kernel/cpu/vmware.c	2009-07-19 17:09:10.000000000 -0600
+@@ -94,3 +94,21 @@ unsigned long vmware_get_tsc_khz(void)
+ 	BUG_ON(!vmware_platform());
+ 	return __vmware_get_tsc_khz();
+ }
++
++/*
++ * VMware hypervisor takes care of exporting a reliable TSC to the guest.
++ * Still, due to timing difference when running on virtual cpus, the TSC can
++ * be marked as unstable in some cases. For example, the TSC sync check at
++ * bootup can fail due to a marginal offset between vcpus' TSCs (though the
++ * TSCs do not drift from each other).  Also, the ACPI PM timer clocksource
++ * is not suitable as a watchdog when running on a hypervisor because the
++ * kernel may miss a wrap of the counter if the vcpu is descheduled for a
++ * long time. To skip these checks at runtime we set these capability bits,
++ * so that the kernel could just trust the hypervisor with providing a
++ * reliable virtual TSC that is suitable for timekeeping.
++ */
++void __cpuinit vmware_set_feature_bits(struct cpuinfo_x86 *c)
++{
++	set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
++	set_cpu_cap(c, X86_FEATURE_TSC_RELIABLE);
++}
+diff -urpN a/arch/x86/kernel/tsc_sync.c b/arch/x86/kernel/tsc_sync.c
+--- a/arch/x86/kernel/tsc_sync.c	2008-07-13 15:51:29.000000000 -0600
++++ b/arch/x86/kernel/tsc_sync.c	2009-07-19 17:09:10.000000000 -0600
+@@ -110,6 +110,12 @@ void __cpuinit check_tsc_sync_source(int
+ 	if (unsynchronized_tsc())
+ 		return;
+ 
++	if (boot_cpu_has(X86_FEATURE_TSC_RELIABLE)) {
++		printk(KERN_INFO
++		       "Skipping synchronization checks as TSC is reliable.\n");
++		return;
++	}
++
+ 	printk(KERN_INFO "checking TSC synchronization [CPU#%d -> CPU#%d]:",
+ 			  smp_processor_id(), cpu);
+ 
+@@ -163,7 +169,7 @@ void __cpuinit check_tsc_sync_target(voi
+ {
+ 	int cpus = 2;
+ 
+-	if (unsynchronized_tsc())
++	if (unsynchronized_tsc() || boot_cpu_has(X86_FEATURE_TSC_RELIABLE))
+ 		return;
+ 
+ 	/*
+diff -urpN a/include/asm-x86/vmware.h b/include/asm-x86/vmware.h
+--- a/include/asm-x86/vmware.h	2009-07-19 16:58:52.000000000 -0600
++++ b/include/asm-x86/vmware.h	2009-07-19 17:09:10.000000000 -0600
+@@ -22,5 +22,6 @@
+ 
+ extern unsigned long vmware_get_tsc_khz(void);
+ extern int vmware_platform(void);
++extern void vmware_set_feature_bits(struct cpuinfo_x86 *c);
+ 
+ #endif

Added: dists/lenny/linux-2.6-abi/debian/patches/bugfix/x86/add-a-synthetic-TS_RELIABLE-feature-bit.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/lenny/linux-2.6-abi/debian/patches/bugfix/x86/add-a-synthetic-TS_RELIABLE-feature-bit.patch	Mon Jul 20 04:51:12 2009	(r13979)
@@ -0,0 +1,29 @@
+commit b2bcc7b299f37037b4a78dc1538e5d6508ae8110
+Author: Alok Kataria <akataria at vmware.com>
+Date:   Fri Oct 31 11:59:53 2008 -0700
+
+    x86: add a synthetic TSC_RELIABLE feature bit
+    
+    Impact: None, bit reservation only
+    
+    Add a synthetic TSC_RELIABLE feature bit which will be used to mark
+    TSC as reliable so that we could skip all the runtime checks for
+    TSC stablity, which have false positives in virtual environment.
+    
+    Signed-off-by: Alok N Kataria <akataria at vmware.com>
+    Signed-off-by: Dan Hecht <dhecht at vmware.com>
+    Signed-off-by: H. Peter Anvin <hpa at zytor.com>
+
+Backported to Debian's 2.6.26 by dann frazier <dannf at debian.org>
+
+diff -urpN a/include/asm-x86/cpufeature.h b/include/asm-x86/cpufeature.h
+--- a/include/asm-x86/cpufeature.h	2008-07-13 15:51:29.000000000 -0600
++++ b/include/asm-x86/cpufeature.h	2009-07-16 14:25:56.000000000 -0600
+@@ -79,6 +79,7 @@
+ #define X86_FEATURE_REP_GOOD	(3*32+16) /* rep microcode works well on this CPU */
+ #define X86_FEATURE_MFENCE_RDTSC (3*32+17) /* Mfence synchronizes RDTSC */
+ #define X86_FEATURE_LFENCE_RDTSC (3*32+18) /* Lfence synchronizes RDTSC */
++#define X86_FEATURE_TSC_RELIABLE (3*32+23) /* TSC is known to be reliable */
+ 
+ /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
+ #define X86_FEATURE_XMM3	(4*32+ 0) /* Streaming SIMD Extensions-3 */

Added: dists/lenny/linux-2.6-abi/debian/patches/bugfix/x86/hypervisor-detection-and-get-tsc_freq-from-hypervisor.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/lenny/linux-2.6-abi/debian/patches/bugfix/x86/hypervisor-detection-and-get-tsc_freq-from-hypervisor.patch	Mon Jul 20 04:51:12 2009	(r13979)
@@ -0,0 +1,423 @@
+commit fd59eae709565d0c294f84bc2bf3c942a561c474
+Author: Alok Kataria <akataria at vmware.com>
+Date:   Fri Jan 16 15:35:02 2009 -0800
+
+    UBUNTU: x86: Hypervisor detection and get tsc_freq from hypervisor
+    
+    Bug: #319945
+    BumpABI: yes
+    ABI changes: Adds an element to cpuinfo_x86 which modifies the hash for
+                 boot_cpu_data and per_cpu__cpu_info.
+    
+    Impact: Changes timebase calibration on Vmware.
+    
+    This patch adds function to detect if we are running under VMware.
+    The current way to check if we are on VMware is following,
+    #  check if "hypervisor present bit" is set, if so read the 0x40000000
+    cpuid leaf and check for "VMwareVMware" signature.
+    #  if the above fails, check the DMI vendors name for "VMware" string
+    if we find one we query the VMware hypervisor port to check if we are
+    under VMware.
+    
+    The DMI + "VMware hypervisor port check" is needed for older VMware products,
+    which don't implement the hypervisor signature cpuid leaf.
+    Also note that since we are checking for the DMI signature the hypervisor
+    port should never be accessed on native hardware.
+    
+    This patch also adds a hypervisor_get_tsc_freq function, instead of
+    calibrating the frequency which can be error prone in virtualized
+    environment, we ask the hypervisor for it. We get the frequency from
+    the hypervisor by accessing the hypervisor port if we are running on VMware.
+    Other hypervisors too can add code to the generic routine to get frequency on
+    their platform.
+    
+    Signed-off-by: Alok N Kataria <akataria at vmware.com>
+    Signed-off-by: Dan Hecht <dhecht at vmware.com>
+    Signed-off-by: H. Peter Anvin <hpa at zytor.com>
+    Signed-off-by: Stefan Bader <stefan.bader at canonical.com>
+    Acked-by: Tim Gardner <tim.gardner at canonical.com>
+
+Backported to Debian's 2.6.26 by dann frazier <dannf at debian.org>
+
+diff -urpN a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
+--- a/arch/x86/kernel/cpu/common.c	2008-07-13 15:51:29.000000000 -0600
++++ b/arch/x86/kernel/cpu/common.c	2009-07-19 17:05:05.000000000 -0600
+@@ -13,6 +13,7 @@
+ #include <asm/mtrr.h>
+ #include <asm/mce.h>
+ #include <asm/pat.h>
++#include <asm/hypervisor.h>
+ #ifdef CONFIG_X86_LOCAL_APIC
+ #include <asm/mpspec.h>
+ #include <asm/apic.h>
+@@ -491,6 +492,8 @@ void __cpuinit identify_cpu(struct cpuin
+ 				c->x86, c->x86_model);
+ 	}
+ 
++	init_hypervisor(c);
++
+ 	/*
+ 	 * On SMP, boot_cpu_data holds the common feature set between
+ 	 * all CPUs; so make sure that we indicate which features are
+diff -urpN a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
+--- a/arch/x86/kernel/cpu/hypervisor.c	1969-12-31 17:00:00.000000000 -0700
++++ b/arch/x86/kernel/cpu/hypervisor.c	2009-07-19 16:58:14.000000000 -0600
+@@ -0,0 +1,50 @@
++/*
++ * Common hypervisor code
++ *
++ * Copyright (C) 2008, VMware, Inc.
++ * Author : Alok N Kataria <akataria at vmware.com>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT.  See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ */
++
++#include <linux/init.h>
++
++#include <asm/processor.h>
++#include <asm/vmware.h>
++#include <asm/hypervisor.h>
++
++static inline void __cpuinit
++detect_hypervisor_vendor(struct cpuinfo_x86 *c)
++{
++	if (vmware_platform()) {
++		c->x86_hyper_vendor = X86_HYPER_VENDOR_VMWARE;
++	} else {
++		c->x86_hyper_vendor = X86_HYPER_VENDOR_NONE;
++	}
++}
++
++unsigned long get_hypervisor_tsc_freq(void)
++{
++	if (boot_cpu_data.x86_hyper_vendor == X86_HYPER_VENDOR_VMWARE)
++		return vmware_get_tsc_khz();
++	return 0;
++}
++
++void __cpuinit init_hypervisor(struct cpuinfo_x86 *c)
++{
++	detect_hypervisor_vendor(c);
++}
+diff -urpN a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
+--- a/arch/x86/kernel/cpu/Makefile	2008-07-13 15:51:29.000000000 -0600
++++ b/arch/x86/kernel/cpu/Makefile	2009-07-19 17:05:37.000000000 -0600
+@@ -4,6 +4,7 @@
+ 
+ obj-y			:= intel_cacheinfo.o addon_cpuid_features.o
+ obj-y			+= proc.o feature_names.o
++obj-y			+= vmware.o hypervisor.o
+ 
+ obj-$(CONFIG_X86_32)	+= common.o bugs.o
+ obj-$(CONFIG_X86_32)	+= amd.o
+diff -urpN a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
+--- a/arch/x86/kernel/cpu/vmware.c	1969-12-31 17:00:00.000000000 -0700
++++ b/arch/x86/kernel/cpu/vmware.c	2009-07-19 16:58:14.000000000 -0600
+@@ -0,0 +1,96 @@
++/*
++ * VMware Detection code.
++ *
++ * Copyright (C) 2008, VMware, Inc.
++ * Author : Alok N Kataria <akataria at vmware.com>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT.  See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ */
++
++#include <linux/dmi.h>
++#include <linux/init.h>
++
++#include <asm/div64.h>
++#include <asm/vmware.h>
++
++#define CPUID_VMWARE_INFO_LEAF	0x40000000
++#define VMWARE_HYPERVISOR_MAGIC	0x564D5868
++#define VMWARE_HYPERVISOR_PORT	0x5658
++
++#define VMWARE_PORT_CMD_GETVERSION	10
++#define VMWARE_PORT_CMD_GETHZ		45
++
++#define VMWARE_PORT(cmd, eax, ebx, ecx, edx)				\
++	__asm__("inl (%%dx)" :						\
++			"=a"(eax), "=c"(ecx), "=d"(edx), "=b"(ebx) :	\
++			"0"(VMWARE_HYPERVISOR_MAGIC),			\
++			"1"(VMWARE_PORT_CMD_##cmd),			\
++			"2"(VMWARE_HYPERVISOR_PORT), "3"(UINT_MAX) :	\
++			"memory");
++
++static inline int __vmware_platform(void)
++{
++	uint32_t eax, ebx, ecx, edx;
++	VMWARE_PORT(GETVERSION, eax, ebx, ecx, edx);
++	return eax != (uint32_t)-1 && ebx == VMWARE_HYPERVISOR_MAGIC;
++}
++
++static unsigned long __vmware_get_tsc_khz(void)
++{
++        uint64_t tsc_hz;
++        uint32_t eax, ebx, ecx, edx;
++
++        VMWARE_PORT(GETHZ, eax, ebx, ecx, edx);
++
++        if (ebx == UINT_MAX)
++                return 0;
++        tsc_hz = eax | (((uint64_t)ebx) << 32);
++        do_div(tsc_hz, 1000);
++        BUG_ON(tsc_hz >> 32);
++        return tsc_hz;
++}
++
++/*
++ * While checking the dmi string infomation, just checking the product
++ * serial key should be enough, as this will always have a VMware
++ * specific string when running under VMware hypervisor.
++ */
++int vmware_platform(void)
++{
++	if (cpu_has_hypervisor) {
++		unsigned int eax, ebx, ecx, edx;
++		char hyper_vendor_id[13];
++
++		cpuid(CPUID_VMWARE_INFO_LEAF, &eax, &ebx, &ecx, &edx);
++		memcpy(hyper_vendor_id + 0, &ebx, 4);
++		memcpy(hyper_vendor_id + 4, &ecx, 4);
++		memcpy(hyper_vendor_id + 8, &edx, 4);
++		hyper_vendor_id[12] = '\0';
++		if (!strcmp(hyper_vendor_id, "VMwareVMware"))
++			return 1;
++	} else if (dmi_available && dmi_name_in_serial("VMware") &&
++		   __vmware_platform())
++		return 1;
++
++	return 0;
++}
++
++unsigned long vmware_get_tsc_khz(void)
++{
++	BUG_ON(!vmware_platform());
++	return __vmware_get_tsc_khz();
++}
+diff -urpN a/arch/x86/kernel/setup_32.c b/arch/x86/kernel/setup_32.c
+--- a/arch/x86/kernel/setup_32.c	2009-07-19 16:50:37.000000000 -0600
++++ b/arch/x86/kernel/setup_32.c	2009-07-19 17:02:57.000000000 -0600
+@@ -67,6 +67,7 @@
+ #include <asm/bios_ebda.h>
+ #include <asm/cacheflush.h>
+ #include <asm/processor.h>
++#include <asm/hypervisor.h>
+ 
+ /* This value is set up by the early boot code to point to the value
+    immediately after the boot time page tables.  It contains a *physical*
+@@ -885,6 +886,12 @@ void __init setup_arch(char **cmdline_p)
+ 
+ 	dmi_scan_machine();
+ 
++	/*
++	 * VMware detection requires dmi to be available, so this
++	 * needs to be done after dmi_scan_machine, for the BP.
++	 */
++	init_hypervisor(&boot_cpu_data);
++
+ 	io_delay_init();
+ 
+ #ifdef CONFIG_X86_SMP
+diff -urpN a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c
+--- a/arch/x86/kernel/setup_64.c	2008-07-13 15:51:29.000000000 -0600
++++ b/arch/x86/kernel/setup_64.c	2009-07-19 17:01:31.000000000 -0600
+@@ -71,6 +71,7 @@
+ #include <asm/topology.h>
+ #include <asm/trampoline.h>
+ #include <asm/pat.h>
++#include <asm/hypervisor.h>
+ 
+ #include <mach_apic.h>
+ #ifdef CONFIG_PARAVIRT
+@@ -400,6 +401,12 @@ void __init setup_arch(char **cmdline_p)
+ 
+ 	dmi_scan_machine();
+ 
++	/*
++	 * VMware detection requires dmi to be available, so this
++	 * needs to be done after dmi_scan_machine, for the BP.
++	 */
++	init_hypervisor(&boot_cpu_data);
++
+ 	io_delay_init();
+ 
+ #ifdef CONFIG_KVM_CLOCK
+@@ -1094,6 +1101,8 @@ void __cpuinit identify_cpu(struct cpuin
+ 
+ 	c->apicid = phys_pkg_id(0);
+ 
++	init_hypervisor(c);
++
+ 	/*
+ 	 * Vendor-specific initialization.  In this section we
+ 	 * canonicalize the feature flags, meaning if there are
+diff -urpN a/arch/x86/kernel/tsc_32.c b/arch/x86/kernel/tsc_32.c
+--- a/arch/x86/kernel/tsc_32.c	2008-07-13 15:51:29.000000000 -0600
++++ b/arch/x86/kernel/tsc_32.c	2009-07-19 16:58:14.000000000 -0600
+@@ -11,6 +11,7 @@
+ #include <asm/tsc.h>
+ #include <asm/io.h>
+ #include <asm/timer.h>
++#include <asm/hypervisor.h>
+ 
+ #include "mach_timer.h"
+ 
+@@ -149,11 +150,17 @@ unsigned long long sched_clock(void)
+ unsigned long native_calculate_cpu_khz(void)
+ {
+ 	unsigned long long start, end;
+-	unsigned long count;
++	unsigned long count, hypervisor_tsc_khz;
+ 	u64 delta64 = (u64)ULLONG_MAX;
+ 	int i;
+ 	unsigned long flags;
+ 
++	hypervisor_tsc_khz = get_hypervisor_tsc_freq();
++	if (hypervisor_tsc_khz) {
++		printk(KERN_INFO "TSC: Frequency read from the hypervisor\n");
++		return hypervisor_tsc_khz;
++	}
++
+ 	local_irq_save(flags);
+ 
+ 	/* run 3 times to ensure the cache is warm and to get an accurate reading */
+diff -urpN a/arch/x86/kernel/tsc_64.c b/arch/x86/kernel/tsc_64.c
+--- a/arch/x86/kernel/tsc_64.c	2008-07-13 15:51:29.000000000 -0600
++++ b/arch/x86/kernel/tsc_64.c	2009-07-19 17:02:19.000000000 -0600
+@@ -12,6 +12,7 @@
+ #include <asm/timex.h>
+ #include <asm/timer.h>
+ #include <asm/vgtod.h>
++#include <asm/hypervisor.h>
+ 
+ static int notsc __initdata = 0;
+ 
+@@ -199,8 +200,17 @@ static unsigned long __init tsc_read_ref
+ void __init tsc_calibrate(void)
+ {
+ 	unsigned long flags, tsc1, tsc2, tr1, tr2, pm1, pm2, hpet1, hpet2;
++	unsigned long hypervisor_tsc_khz;
+ 	int hpet = is_hpet_enabled(), cpu;
+ 
++	hypervisor_tsc_khz = get_hypervisor_tsc_freq();
++	if (hypervisor_tsc_khz) {
++		printk(KERN_INFO "TSC: Frequency read from the hypervisor\n");
++		tsc_khz = hypervisor_tsc_khz;
++		set_cyc2ns_scale(tsc_khz);
++		return;
++	}
++
+ 	local_irq_save(flags);
+ 
+ 	tsc1 = tsc_read_refs(&pm1, hpet ? &hpet1 : NULL);
+diff -urpN a/include/asm-x86/hypervisor.h b/include/asm-x86/hypervisor.h
+--- a/include/asm-x86/hypervisor.h	1969-12-31 17:00:00.000000000 -0700
++++ b/include/asm-x86/hypervisor.h	2009-07-19 16:58:14.000000000 -0600
+@@ -0,0 +1,26 @@
++/*
++ * Copyright (C) 2008, VMware, Inc.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT.  See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ */
++#ifndef ASM_X86__HYPERVISOR_H
++#define ASM_X86__HYPERVISOR_H
++
++extern unsigned long get_hypervisor_tsc_freq(void);
++extern void init_hypervisor(struct cpuinfo_x86 *c);
++
++#endif
+diff -urpN a/include/asm-x86/processor.h b/include/asm-x86/processor.h
+--- a/include/asm-x86/processor.h	2008-07-13 15:51:29.000000000 -0600
++++ b/include/asm-x86/processor.h	2009-07-19 17:00:56.000000000 -0600
+@@ -109,6 +109,7 @@ struct cpuinfo_x86 {
+ 	/* Index into per_cpu list: */
+ 	u16			cpu_index;
+ #endif
++	unsigned int x86_hyper_vendor;
+ } __attribute__((__aligned__(SMP_CACHE_BYTES)));
+ 
+ #define X86_VENDOR_INTEL	0
+@@ -122,6 +123,9 @@ struct cpuinfo_x86 {
+ 
+ #define X86_VENDOR_UNKNOWN	0xff
+ 
++#define X86_HYPER_VENDOR_NONE  0
++#define X86_HYPER_VENDOR_VMWARE 1
++
+ /*
+  * capabilities of CPUs
+  */
+diff -urpN a/include/asm-x86/vmware.h b/include/asm-x86/vmware.h
+--- a/include/asm-x86/vmware.h	1969-12-31 17:00:00.000000000 -0700
++++ b/include/asm-x86/vmware.h	2009-07-19 16:58:52.000000000 -0600
+@@ -0,0 +1,26 @@
++/*
++ * Copyright (C) 2008, VMware, Inc.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful, but
++ * WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
++ * NON INFRINGEMENT.  See the GNU General Public License for more
++ * details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ */
++#ifndef ASM_X86__VMWARE_H
++#define ASM_X86__VMWARE_H
++
++extern unsigned long vmware_get_tsc_khz(void);
++extern int vmware_platform(void);
++
++#endif

Added: dists/lenny/linux-2.6-abi/debian/patches/bugfix/x86/skip-verification-by-the-watchdog-for-TSC-clocksource.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/lenny/linux-2.6-abi/debian/patches/bugfix/x86/skip-verification-by-the-watchdog-for-TSC-clocksource.patch	Mon Jul 20 04:51:12 2009	(r13979)
@@ -0,0 +1,68 @@
+commit 0532dac67ee608e6f583549452ec07e9d2788af7
+Author: Alok Kataria <akataria at vmware.com>
+Date:   Mon Jan 26 21:00:22 2009 +0100
+
+    UBUNTU: x86: Skip verification by the watchdog for TSC clocksource.
+    
+    Bug: #319945
+    
+        Impact: Changes timekeeping on Vmware (or with tsc=reliable).
+    
+        This is achieved by resetting the CLOCKSOURCE_MUST_VERIFY flag.
+    
+        We add a tsc=reliable commandline option to enable this.
+        This enables legacy hardware without HPET, LAPIC, or ACPI timers
+        to enter high-resolution timer mode.
+    
+        Along with that have extended this to be used in virtualization environement
+        too. Now we also set this flag if the X86_FEATURE_TSC_RELIABLE bit is set.
+    
+        This is important since there is a wrap-around problem with the acpi_pm timer.
+        The acpi_pm counter is just 24bits and this can overflow in ~4 seconds. With
+        the NO_HZ kernels in virtualized environment, there can be situations when
+        the guest is descheduled for longer duration, as a result we may miss the wrap
+        of the acpi counter. When TSC is used as a clocksource and acpi_pm timer is
+        being used as the watchdog clocksource this error in acpi_pm results in TSC
+        being marked as unstable, and essentially results in time dropping in chunks
+        of 4 seconds whenever this wrap is missed. Since the virtualized TSC is
+        reliable on VMware, we should always use the TSCs clocksource on VMware, so
+        we skip the verfication at runtime, by checking for the feature bit.
+    
+        Since we reset the flag for mgeode systems too, i have combined
+        the mgeode case with the feature bit check.
+    
+        Signed-off-by: Jeff Hansen <jhansen at cardaccess-inc.com>
+        Signed-off-by: Alok N Kataria <akataria at vmware.com>
+        Signed-off-by: Dan Hecht <dhecht at vmware.com>
+        Signed-off-by: H. Peter Anvin <hpa at zytor.com>
+        Acked-by: Tim Gardner <tim.gardner at canonical.com>
+        Acked-by: Stefan Bader <stefan.bader at canonical.com>
+
+Adjusted to apply to Debian's 2.6.26 by dann frazier <dannf at debian.org>
+
+diff -urpN a/arch/x86/kernel/tsc_32.c b/arch/x86/kernel/tsc_32.c
+--- a/arch/x86/kernel/tsc_32.c	2009-07-19 16:58:14.000000000 -0600
++++ b/arch/x86/kernel/tsc_32.c	2009-07-19 17:11:35.000000000 -0600
+@@ -446,6 +446,9 @@ void __init tsc_init(void)
+ 
+ 	unsynchronized_tsc();
+ 	check_geode_tsc_reliable();
++	if (boot_cpu_has(X86_FEATURE_TSC_RELIABLE))
++		 clocksource_tsc.flags &= ~CLOCK_SOURCE_MUST_VERIFY;
++
+ 	current_tsc_khz = tsc_khz;
+ 	clocksource_tsc.mult = clocksource_khz2mult(current_tsc_khz,
+ 							clocksource_tsc.shift);
+diff -urpN a/arch/x86/kernel/tsc_64.c b/arch/x86/kernel/tsc_64.c
+--- a/arch/x86/kernel/tsc_64.c	2009-07-19 17:02:19.000000000 -0600
++++ b/arch/x86/kernel/tsc_64.c	2009-07-19 17:11:35.000000000 -0600
+@@ -357,6 +357,9 @@ EXPORT_SYMBOL_GPL(mark_tsc_unstable);
+ void __init init_tsc_clocksource(void)
+ {
+ 	if (!notsc) {
++		if (boot_cpu_has(X86_FEATURE_TSC_RELIABLE))
++			clocksource_tsc.flags &= ~CLOCK_SOURCE_MUST_VERIFY;
++
+ 		clocksource_tsc.mult = clocksource_khz2mult(tsc_khz,
+ 							clocksource_tsc.shift);
+ 		if (check_tsc_unstable())

Added: dists/lenny/linux-2.6-abi/debian/patches/bugfix/x86/vmware-look-for-DMI-string-in-product-serial-key.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/lenny/linux-2.6-abi/debian/patches/bugfix/x86/vmware-look-for-DMI-string-in-product-serial-key.patch	Mon Jul 20 04:51:12 2009	(r13979)
@@ -0,0 +1,65 @@
+commit bb363507f6359762f368b09bf36309425768910a
+Author: Alok Kataria <akataria at vmware.com>
+Date:   Mon Jan 26 21:00:23 2009 +0100
+
+    UBUNTU: x86: vmware: look for DMI string in the product serial key
+    
+    Bug: #319945
+    
+        Impact: Should permit VMware detection on older platforms where the
+        vendor is changed.  Could theoretically cause a regression if some
+        weird serial number scheme contains the string "VMware" by pure
+        chance.  Seems unlikely, especially with the mixed case.
+    
+        In some user configured cases, VMware may choose not to put a VMware specific
+        DMI string, but the product serial key is always there and is VMware specific.
+        Add a interface to check the serial key, when checking for VMware in the DMI
+        information.
+    
+        Signed-off-by: Alok N Kataria <akataria at vmware.com>
+        Signed-off-by: H. Peter Anvin <hpa at zytor.com>
+        Acked-by: Tim Gardner <tim.gardner at canonical.com>
+        Acked-by: Stefan Bader <stefan.bader at canonical.com>
+
+Backported to Debian's 2.6.26 by dann frazier <dannf at debian.org>
+
+diff -urpN a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
+--- a/drivers/firmware/dmi_scan.c	2008-07-13 15:51:29.000000000 -0600
++++ b/drivers/firmware/dmi_scan.c	2009-07-19 17:15:17.000000000 -0600
+@@ -452,6 +452,17 @@ const char *dmi_get_system_info(int fiel
+ }
+ EXPORT_SYMBOL(dmi_get_system_info);
+ 
++/**
++ *	dmi_name_in_serial - 	Check if string is in the DMI product serial
++ *				information.
++ */
++int dmi_name_in_serial(const char *str)
++{
++	int f = DMI_PRODUCT_SERIAL;
++	if (dmi_ident[f] && strstr(dmi_ident[f], str))
++		return 1;
++	return 0;
++}
+ 
+ /**
+  *	dmi_name_in_vendors - Check if string is anywhere in the DMI vendor information.
+diff -urpN a/include/linux/dmi.h b/include/linux/dmi.h
+--- a/include/linux/dmi.h	2008-07-13 15:51:29.000000000 -0600
++++ b/include/linux/dmi.h	2009-07-19 17:15:17.000000000 -0600
+@@ -81,6 +81,7 @@ extern const struct dmi_device * dmi_fin
+ extern void dmi_scan_machine(void);
+ extern int dmi_get_year(int field);
+ extern int dmi_name_in_vendors(const char *str);
++extern int dmi_name_in_serial(const char *str);
+ extern int dmi_available;
+ extern int dmi_walk(void (*decode)(const struct dmi_header *));
+ 
+@@ -93,6 +94,7 @@ static inline const struct dmi_device * 
+ static inline void dmi_scan_machine(void) { return; }
+ static inline int dmi_get_year(int year) { return 0; }
+ static inline int dmi_name_in_vendors(const char *s) { return 0; }
++static inline int dmi_name_in_serial(const char *s) { return 0; }
+ #define dmi_available 0
+ static inline int dmi_walk(void (*decode)(const struct dmi_header *))
+ 	{ return -1; }

Added: dists/lenny/linux-2.6-abi/debian/patches/series/18abi
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/lenny/linux-2.6-abi/debian/patches/series/18abi	Mon Jul 20 04:51:12 2009	(r13979)
@@ -0,0 +1,6 @@
++ bugfix/x86/add-a-synthetic-TS_RELIABLE-feature-bit.patch
++ bugfix/x86/add-X86_FEATURE_HYPERVISOR-feature-bit.patch
++ bugfix/x86/hypervisor-detection-and-get-tsc_freq-from-hypervisor.patch
++ bugfix/x86/add-a-synthetic-TSC_RELIABLE-feature-bit.patch
++ bugfix/x86/skip-verification-by-the-watchdog-for-TSC-clocksource.patch
++ bugfix/x86/vmware-look-for-DMI-string-in-product-serial-key.patch



More information about the Kernel-svn-changes mailing list