Re: [PATCH v6 15/36] KVM: x86: Fix compute_guest_tsc() to handle negative time deltas
From: David Woodhouse
Date: Sat Jul 25 2026 - 13:13:08 EST
On Fri, 2026-07-24 at 14:27 -0700, Sean Christopherson wrote:
>
> To cut down on the duplicate code, and IMO to make it easier to identify the
> differences, how about this?
>
> s64 delta_ns = kernel_ns - vcpu->arch.this_tsc_nsec;
> u64 tsc;
>
> /* Handle negative deltas gracefully (master clock ref may be earlier) */
> tsc = pvclock_scale_delta(abs(-delta_ns),
> vcpu->arch.virtual_tsc_mult,
> vcpu->arch.virtual_tsc_shift);
>
> return vcpu->arch.this_tsc_write + (delta_ns >= 0 ? tsc : -tsc);
Oh, I missed that part. Done, rebased to kvm-x86/next and pushed to my
kvmclock7 branch while I test it and await further feedback.
Attachment:
smime.p7s
Description: S/MIME cryptographic signature