aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuck <350528965+Duck912@users.noreply.github.com>2026-11-03 01:28:21 -0500
committerGitHub <noreply@github.com>2026-11-03 07:28:21 +0100
commitad7282cd736ae75b126088d7d6986efebd048c15 (patch)
treeee4d86008ec8404a5cb383e813f1349db4d7cc36
parentf201586db8aa463dc7690a26d4cf884ff8c195a8 (diff)
common: measure the TSC only on CPUs without CPUID leaf 0x15 (#373)
The fallback that measures the TSC rate when the CPU reports none was meant for AMD, which has no leaf 0x15 at all. It also caught Intel CPUs that have the leaf but report a crystal frequency of 0 (Coffee Lake, e.g. the i5-9400F) and moved them from the OS clock to the measured RDTSC clock. With the same fallback in another Eden-based build, an i5-9400F crashed about 3.5 s after launch; limiting the fallback to CPUs without the leaf fixed it for that tester. Those Intel CPUs now keep the OS clock, as before the fallback. AMD CPUs still get the measured RDTSC clock (a Ryzen 7 9800X3D reports max leaf 0xd, so nothing changes there). Assisted-by: Claude Opus 5.5 (debugging, porting and drafting) Signed-off-by: Duck912 <350528965+Duck912@users.noreply.github.com>
-rw-r--r--src/common/cpu_features.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/common/cpu_features.cpp b/src/common/cpu_features.cpp
index 93eecb1dc5..c7f6e6f036 100644
--- a/src/common/cpu_features.cpp
+++ b/src/common/cpu_features.cpp
@@ -227,8 +227,10 @@ const CPUCaps g_cpu_caps = [] {
// AMD CPUs have no leaf 0x15 (Zen 4 stops at 0x10): measure their invariant TSC too, or every
// guest clock read (CNTPCT, which games read thousands of times a frame) goes through the
- // host's much slower QueryPerformanceCounter.
- if (caps.invariant_tsc && caps.tsc_frequency == 0) {
+ // host's much slower QueryPerformanceCounter. Intel CPUs that have the leaf but report no
+ // crystal frequency (e.g. Coffee Lake) keep the OS clock: an i5-9400F crashed at launch on the
+ // measured RDTSC clock.
+ if (max_std_fn < 0x15 && caps.invariant_tsc && caps.tsc_frequency == 0) {
caps.tsc_frequency = X64::EstimateRDTSCFrequency();
}