On Wed, May 20, 2026, David Woodhouse wrote:
> On Fri, 2026-05-15 at 12:19 -0700, Sean Christopherson wrote:
> > When running as a KVM guest with kvmclock support enabled, stuff the APIC
> > timer period/frequency with the local APIC bus frequency reported in
> > CPUID.0x40000010.EBX instead of trying to calibrate/guess the frequency.
> >
> > See Documentation/virt/kvm/x86/cpuid.rst for details.
> >
> > Signed-off-by: Sean Christopherson <[email protected]>
>
> I still don't much like the way this is done inside kvm_get_tsc_khz().
Yeah, I don't like it either (understatement). Aha! native_calibrate_tsc() is
the oddball, all of the PV flows stuff lapic_timer_period when parsing the
initial
timing info. I'll just do that. Blindly writing a global is all kinds of
fugly,
but that's a future
problem to solve.
> We also probably ought to be looking for the timing leaf on other
> hypervisors including VMware
VMware gets the frequency via hypercall. Why, I have no idea. I'll let the
VMware folks deal with that.
eax = vmware_hypercall3(VMWARE_CMD_GETHZ, UINT_MAX, &ebx, &ecx);
> and probably Bhyve too. Should it be done somewhere else?
I'm not opposed to that, though I don't know that it'd be a net positive. The
"hard" part of getting the info is finding the CPUID base and checking if the
leaf is available. Unlike the native CPUID leaf, no math is necessary, and so
once the leaf is obtained, getting the frequency is trivial.
Regardless, I definitely don't want to take it on in this series. :-)