Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 120822
b: refs/heads/master
c: eca0cd0
h: refs/heads/master
v: v3
  • Loading branch information
Alok Kataria authored and H. Peter Anvin committed Nov 2, 2008
1 parent 09aa04b commit 080c780
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 88b094fb8d4fe43b7025ea8d487059e8813e02cd
refs/heads/master: eca0cd028bdf0f6aaceb0d023e9c7501079a7dda
1 change: 1 addition & 0 deletions trunk/arch/x86/include/asm/vmware.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 10 additions & 1 deletion trunk/arch/x86/kernel/cpu/hypervisor.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,17 @@ unsigned long get_hypervisor_tsc_freq(void)
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);
}

18 changes: 18 additions & 0 deletions trunk/arch/x86/kernel/cpu/vmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,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);
}
8 changes: 7 additions & 1 deletion trunk/arch/x86/kernel/tsc_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ void __cpuinit check_tsc_sync_source(int cpu)
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);

Expand Down Expand Up @@ -161,7 +167,7 @@ void __cpuinit check_tsc_sync_target(void)
{
int cpus = 2;

if (unsynchronized_tsc())
if (unsynchronized_tsc() || boot_cpu_has(X86_FEATURE_TSC_RELIABLE))
return;

/*
Expand Down

0 comments on commit 080c780

Please sign in to comment.