Re: [PATCH v6 03/51] x86/tsc: Ensure that TSC recalibration doesn't run if TSC frequency is known
[email protected] Thu, 06 Aug 2026 23:55:56 +0000
| Newsgroups | org.kernel.vger.linux-hyperv,org.kernel.vger.kvm |
|---|---|
| Message-ID | <[email protected]> |
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Valid virtual machine configurations with legacy CPU models will trigger a spurious WARN_ON_ONCE (and potential kernel panic) due to hypervisor paravirt clocks. -- --- Patch [3]: [PATCH v6 03/51] x86/tsc: Ensure that TSC recalibration doesn't run if TSC frequency is known --- commit dd99d8caeb7628be679eca32563aa6618e548028 Author: Sean Christopherson <[email protected]> x86/tsc: Ensure that TSC recalibration doesn't run if TSC frequency is known This commit adds a warning and bails from recalibrate_cpu_khz() if X86_FEATURE_TSC_KNOWN_FREQ is set. This is intended to catch out-of-spec hardware states on ancient CPUs where recalibration is attempted post-boot. > diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c > --- a/arch/x86/kernel/tsc.c > +++ b/arch/x86/kernel/tsc.c [ ... ] > @@ -930,6 +930,9 @@ void recalibrate_cpu_khz(void) > if (!boot_cpu_has(X86_FEATURE_TSC)) > return; > > + if (WARN_ON_ONCE(cpu_feature_enabled(X86_FEATURE_TSC_KNOWN_FREQ))) > + return; > + [Severity: Medium] Will this trigger spurious warnings on valid virtual machine configurations? The commit message mentions that hitting this requires concocting an impossible CPU model like combining a P4 signature with CPUID 0x15. However, hypervisor paravirt clocks (like kvmclock, vmware, or mshyperv) unconditionally call setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ) during early boot, regardless of the emulated CPU generation. If a VM is configured with a legacy CPU model (e.g. -cpu athlon) and runs an SMP=n kernel, the powernow-k7 cpufreq driver can successfully load and explicitly call recalibrate_cpu_khz(). Since the paravirt clock already forced the TSC_KNOWN_FREQ feature, cpu_feature_enabled() will evaluate to true and trigger this WARN_ON_ONCE, which can escalate to a fatal kernel panic on systems with panic_on_warn enabled. Does this warning need to account for paravirtualized clocks setting this feature flag on legacy CPU models? > cpu_khz = x86_platform.calibrate_cpu(); > tsc_khz = x86_platform.calibrate_tsc(); -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=3