Files
qemu-spoof/patches/0026-cpuid-leaf15.patch
lirent 633538217c feat(cpuid): leaf 0x15 TSC / core-crystal ratio (patch 0026)
Real Intel CPUs enumerate leaf 0x15 (TSC/crystal ratio); QEMU returns 0. Fill it
consistently with leaf 0x16 (TSC == base freq). Intel persona only. Module getters
spoof_cpu_crystal_hz/tsc_num/tsc_den. Inert without a seed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12 00:16:21 +03:00

27 lines
1.1 KiB
Diff

qemu-spoof: CPUID leaf 0x15 (TSC / core-crystal ratio)
Stock QEMU returns 0 for leaf 0x15; real Intel CPUs enumerate the TSC / nominal
core-crystal clock ratio. Fill EAX(denominator)/EBX(numerator)/ECX(crystal Hz) from
the module so TSC == the leaf-0x16 base frequency (24 MHz crystal * base_mhz / 24).
Intel only; the getters return 0 for an AMD persona or when off, matching stock.
(spoof.h include in target/i386 is added by 0013.)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index c6fd1dc..aa0dd73 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -8811,6 +8811,14 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
}
break;
}
+ case 0x15:
+ /* qemu-spoof: TSC / nominal core-crystal ratio (stock QEMU returns 0).
+ * The getters return 0 when off or for an AMD persona, matching stock. */
+ *eax = (uint32_t)spoof_cpu_tsc_den(0);
+ *ebx = (uint32_t)spoof_cpu_tsc_num(0);
+ *ecx = (uint32_t)spoof_cpu_crystal_hz(0);
+ *edx = 0;
+ break;
case 0x1C: /* Last Branch Records Information Leaf */
*eax = 0;
*ebx = 0;