git: eb28df303b06 - stable/13 - Detect CPU type before asking VMWare for TSC freq
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 11 Feb 2022 06:52:07 UTC
The branch stable/13 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=eb28df303b068c5db94943c9858e359975f7fa74 commit eb28df303b068c5db94943c9858e359975f7fa74 Author: Colin Percival <cperciva@FreeBSD.org> AuthorDate: 2022-01-04 07:00:39 +0000 Commit: Colin Percival <cperciva@FreeBSD.org> CommitDate: 2022-02-11 06:52:00 +0000 Detect CPU type before asking VMWare for TSC freq This allows us to set tsc_is_invariant and select appropriately fenced versions of RDTSC based on the CPU type. Reviewed by: markj Sponsored by: https://www.patreon.com/cperciva (cherry picked from commit fd980feb574d0924918b42cd449cedf557dfb9e0) --- sys/x86/x86/tsc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c index 1e63c313c7e4..1b6c8282e44e 100644 --- a/sys/x86/x86/tsc.c +++ b/sys/x86/x86/tsc.c @@ -134,7 +134,6 @@ tsc_freq_vmware(void) if (regs[1] != UINT_MAX) tsc_freq = regs[0] | ((uint64_t)regs[1] << 32); } - tsc_is_invariant = 1; tsc_early_calib_exact = 1; } @@ -268,11 +267,6 @@ probe_tsc_freq(void) tsc_perf_stat = 1; } - if (vm_guest == VM_GUEST_VMWARE) { - tsc_freq_vmware(); - return; - } - switch (cpu_vendor_id) { case CPU_VENDOR_AMD: case CPU_VENDOR_HYGON: @@ -311,6 +305,11 @@ probe_tsc_freq(void) break; } + if (vm_guest == VM_GUEST_VMWARE) { + tsc_freq_vmware(); + return; + } + if (tsc_freq_cpuid(&tsc_freq)) { /* * If possible, use the value obtained from CPUID as the initial