Re: [PATCH 02/10] KVM: x86: Improve accuracy of KVM clock when TSC scaling is in force

From: Paolo Bonzini
Date: Mon Apr 22 2024 - 08:23:18 EST


On Thu, Apr 18, 2024 at 9:51 PM David Woodhouse <dwmw2@xxxxxxxxxxxxx> wrote:
> gpa_t time;
> struct pvclock_vcpu_time_info hv_clock;
> - unsigned int hw_tsc_khz;
> + unsigned int hw_tsc_hz;

Why not change this to u64? 4.3 GHz is scarily close to current
processors, though I expect that it will break a lot more software
than just KVM.

> static int kvm_guest_time_update(struct kvm_vcpu *v)
> {
> - unsigned long flags, tgt_tsc_khz;
> + unsigned long flags;
> + uint64_t tgt_tsc_hz;

.. especially considering that you did use a 64-bit integer here
(though---please use u64 not uint64_t; and BTW if you want to add a
patch to change kvm_get_time_scale() to u64, please do.

Thanks,

Paolo