x86/time: update TSC stamp on restore from deep C-state
authorIgor Druzhinin <igor.druzhinin@citrix.com>
Fri, 17 Jan 2020 15:11:20 +0000 (16:11 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 17 Jan 2020 15:11:20 +0000 (16:11 +0100)
commitbbf283f853f8c0e4d29248dd44d3b0e0abc07629
tree4d0e256ed893e907479b74200afb994c471d6b8c
parentc3f18f86634d18fe1092503edfd36cce0185d0eb
x86/time: update TSC stamp on restore from deep C-state

If ITSC is not available on CPU (e.g if running nested as PV shim)
then X86_FEATURE_NONSTOP_TSC is not advertised in certain cases, i.e.
all AMD and some old Intel processors. In which case TSC would need to
be restored on CPU from platform time by Xen upon exiting C-states.

As platform time might be behind the last TSC stamp recorded for the
current CPU, invariant of TSC stamp being always behind local TSC counter
is violated. This has an effect of get_s_time() going negative resulting
in eventual system hang or crash.

Fix this issue by updating local TSC stamp along with TSC counter write.

Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/time.c