x86/time: use relative counts in calibration loops
authorJan Beulich <jbeulich@suse.com>
Thu, 13 Jan 2022 13:30:18 +0000 (14:30 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 13 Jan 2022 13:30:18 +0000 (14:30 +0100)
commit467191641d2a2fd2e43b3ae7b80399f89d339980
tree40cbf7fc7aba44246712f8338ad0cb08186f99ec
parent2e8aa1663c76a189998bf51b869b9e468c992c89
x86/time: use relative counts in calibration loops

Looping until reaching/exceeding a certain value is error prone: If the
target value is close enough to the wrapping point, the loop may not
terminate at all. Switch to using delta values, which then allows to
fold the two loops each into just one.

Fixes: 93340297802b ("x86/time: calibrate TSC against platform timer")
Reported-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/time.c