x86/time: don't move TSC backwards in time_calibration_tsc_rendezvous()
authorJan Beulich <jbeulich@suse.com>
Fri, 19 Feb 2021 16:21:41 +0000 (17:21 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 19 Feb 2021 16:21:41 +0000 (17:21 +0100)
commit76aff7f6336b0ce19559700717537449972531be
tree530fdea1c497c475c379f6917275f3c3edb9956a
parenta2639824e8458a8f3826e184081a13bfa27ea884
x86/time: don't move TSC backwards in time_calibration_tsc_rendezvous()

While doing this for small amounts may be okay, the unconditional use
of CPU0's value here has been found to be a problem when the boot time
TSC of the BSP was behind that of all APs by more than a second. In
particular because of get_s_time_fixed() producing insane output when
the calculated delta is negative, we can't allow this to happen.

On the first iteration have all other CPUs sort out the highest TSC
value any one of them has read. On the second iteration, if that
maximum is higher than CPU0's, update its recorded value from that
taken in the first iteration. Use the resulting value on the last
iteration to write everyone's TSCs.

To account for the possible discontinuity, have
time_calibration_rendezvous_tail() record the newly written value, but
extrapolate local stime using the value read.

Reported-by: Claudemir Todo Bom <claudemir@todobom.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
xen/arch/x86/time.c