Re: [PATCH v6 15/36] KVM: x86: Fix compute_guest_tsc() to handle negative time deltas

David Woodhouse <[email protected]>
Newsgroups org.xenproject.lists.xen-devel,org.kernel.vger.kvm,org.kernel.vger.linux-doc,org.kernel.vger.linux-kernel,org.kernel.vger.linux-kselftest
Message-ID <[email protected]>
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.
smime.p7s (application/pkcs7-signature, 6 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.