Index: sys/x86/x86/tsc.c =================================================================== --- sys/x86/x86/tsc.c +++ sys/x86/x86/tsc.c @@ -147,6 +147,23 @@ tsc_early_calib_exact = 1; } +static void +tsc_freq_xen(void) +{ + u_int regs[4]; + + /* + * Must run *after* generic tsc_freq_cpuid_vm, so that when Xen is + * emulating Viridian support the Viridian leaf is used instead. + */ + cpuid_count(0x40000003, 0, regs); + tsc_freq = (uint64_t)(regs[2]) * 1000; + tsc_early_calib_exact = 1; + if (bootverbose) + printf("Early TSC frequency %juHz derived from Xen CPUID\n", + (uintmax_t)tsc_freq); +} + /* * Calculate TSC frequency using information from the CPUID leaf 0x15 'Time * Stamp Counter and Nominal Core Crystal Clock'. If leaf 0x15 is not @@ -318,9 +335,14 @@ if (tsc_freq_cpuid_vm()) return; - if (vm_guest == VM_GUEST_VMWARE) { + switch (vm_guest) { + case VM_GUEST_VMWARE: tsc_freq_vmware(); return; + + case VM_GUEST_XEN: + tsc_freq_xen(); + return; } if (tsc_freq_cpuid(&tsc_freq)) {