Re: [PATCH 3/3] KVM: x86: hyper-v: Implement HvCallRestorePartitionTime
From: David Woodhouse
Date: Mon Oct 05 2026 - 18:31:05 EST
On Mon, 2026-10-05 at 19:24 +0000, Mushahid Hussain wrote:
>
> -static void __kvm_set_clock(struct kvm *kvm, struct kvm_clock_data
> *data)
> +/* Must precede pvclock_update_vm_gtod_copy(), which reads the
> matched count. */
> +static void kvm_open_tsc_generation(struct kvm *kvm, u64 guest_tsc)
> {
> struct kvm_arch *ka = &kvm->arch;
> - u64 now_raw_ns;
> + struct kvm_vcpu *vcpu;
> + unsigned long i;
> +
> + lockdep_assert_held(&ka->tsc_write_lock);
> +
> + ka->cur_tsc_generation++;
> + ka->cur_tsc_write = guest_tsc;
> + ka->last_tsc_write = guest_tsc;
> + ka->nr_vcpus_matched_tsc = atomic_read(&kvm->online_vcpus) -
> 1;
> +
> + kvm_for_each_vcpu(i, vcpu, kvm) {
> + if (vcpu->arch.guest_tsc_protected)
> + continue;
> + ka->last_tsc_khz = vcpu->arch.virtual_tsc_khz;
> + ka->last_tsc_scaling_ratio = vcpu-
> >arch.l1_tsc_scaling_ratio;
> + break;
> + }
> +}
> +
> +/* Every vCPU reads @guest_tsc at host TSC @host_tsc. */
> +static void kvm_set_tsc_generation(struct kvm *kvm, u64 host_tsc,
> + u64 guest_tsc, u64 ns)
This series doesn't add a KVM selftest. Please do.
And *if* you're going to do the rework I'm citing here, please do it in
a preliminary patch, called out separately from the functional
addition.
And... *don't* do the rework I'm citing here. Or at least if you must,
please do it on top of
https://git.infradead.org/?p=users/dwmw2/linux.git;a=shortlog;h=refs/heads/kvmclock10-part2
But actually, I have a strong suspicion you just want to set the TSC
and then use a version of KVM_SET_CLOCK_GUEST, *not* KVM_SET_CLOCK?
Attachment:
smime.p7s
Description: S/MIME cryptographic signature