bootloader: Implement TSC calibration via hypervisor CPUID leaf.

While debugging some problems on the HaikuPorts build VMs, mmlr
noticed their clocks had an alarming amount of drift. This prompted
an investigation into TSC calibration mechanisms, and the discovery
that there is a VM-specific one which we did not implement.

This mechanism is more accurate than counting cycles on VMs where
cycles can be "stolen" (the probable cause of the aforementioned
clock drift.)

Tested in VMware (works out of the box) and on QEMU/KVM
(may need TSC frequency specified or a host with invariant TSC.)

Change-Id: I4ccfdb2e4e2621404ec9026e7106c02bf96faf18
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7063
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Augustin Cavalier
2023-10-25 00:53:55 +00:00
committed by waddlesplash
parent b8fbb723ea
commit bb2808d615
6 changed files with 55 additions and 23 deletions
@@ -17,7 +17,7 @@ extern "C" {
#endif
void calculate_cpu_conversion_factor(uint8 channel);
void determine_cpu_conversion_factor(uint8 channel);
status_t boot_arch_cpu_init(void);
void arch_ucode_load(BootVolume& volume);