diff options
| author | David Woodhouse <dwmw@amazon.co.uk> | 2026-08-26 14:32:53 -0700 |
|---|---|---|
| committer | Sean Christopherson <seanjc@google.com> | 2026-09-11 11:46:19 -0700 |
| commit | d9173f59df3a625b0e8b7df9873b7358996acc6a (patch) | |
| tree | fa25702ace496dd53c0f87b0384a29575d7d9d46 /tools/perf/scripts/python/stackcollapse.py | |
| parent | c56419275caad2d99264b7c50b0701552ed3ef75 (diff) | |
KVM: x86: Fix compute_guest_tsc() to handle negative time deltas
The compute_guest_tsc() function computes the guest TSC at a given
kernel_ns timestamp. When the master clock reference point
(master_kernel_ns) is earlier than vcpu->arch.this_tsc_nsec, the delta
is negative. Since pvclock_scale_delta() takes a u64, the negative
value wraps to a huge positive number, producing a wildly wrong result.
Handle negative deltas explicitly by scaling the absolute value of the
delta and applying it to this_tsc_write with the appropriate sign.
This is believed to be unreachable in practice; no path has been
identified which invokes compute_guest_tsc() with a timestamp from
before the vCPU's TSC generation was established. Fix it for
robustness, in the spirit of defence in depth.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Link: https://patch.msgid.link/20260826213303.914988-14-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'tools/perf/scripts/python/stackcollapse.py')
0 files changed, 0 insertions, 0 deletions
