Modern x86 TSC features under TCG
Goal
I would like to be able to boot x86 Linux guests in Qemu on non-x86 hosts (so under TCG) such that Linux can use emulated TSC as a proper, stable, reliable clocksource, with frequency known from emulated CPUID (and MSRs, if necessary) without boot-time calibration (which does not work reliably under TCG).
Technical details
This feature seems to be implementable by switching RDTSC emulation from host tick counter to a stable counter with known frequency (e.g. a 1 GHz timer counting nanoseconds given by clock_gettime), then wiring up the necessary bits in CPUID emulation according to what Linux needs. Over the years, Linux has grown quite a bit of logic for qualifying the TSC as a stable clocksource:
- https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kernel/tsc.c
- https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kernel/tsc_msr.c
Additional information
I may be able to find a volunteer to implement this. If this feature does not appear to be a good first task, please let me know.