KVM: x86: fix maintaining of kvm_clock stability on guest CPU hotplug
authorDenis Plotnikov <dplotnikov@virtuozzo.com>
Fri, 7 Apr 2017 09:09:53 +0000 (12:09 +0300)
committerRadim Krčmář <rkrcmar@redhat.com>
Wed, 12 Apr 2017 18:17:15 +0000 (20:17 +0200)
commitbd8fab39cd4fe429f161dfc86bf64993d5c17320
treec27b16f5159a12a84b68730747ae3d4ac3a0ae47
parentc5e8ec8e9beffb9481dba27ab5048c03c8585d7d
KVM: x86: fix maintaining of kvm_clock stability on guest CPU hotplug

VCPU TSC synchronization is perfromed in kvm_write_tsc() when the TSC
value being set is within 1 second from the expected, as obtained by
extrapolating of the TSC in already synchronized VCPUs.

This is naturally achieved on all VCPUs at VM start and resume;
however on VCPU hotplug it is not: the newly added VCPU is created
with TSC == 0 while others are well ahead.

To compensate for that, consider host-initiated kvm_write_tsc() with
TSC == 0 a special case requiring synchronization regardless of the
current TSC on other VCPUs.

Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
arch/x86/kvm/x86.c