x86/HVM: use fixed TSC value when saving or restoring domain
authorBoris Ostrovsky <boris.ostrovsky@oracle.com>
Tue, 22 Apr 2014 10:08:56 +0000 (12:08 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 22 Apr 2014 10:08:56 +0000 (12:08 +0200)
commit88e64cb785c1de4f686c1aa1993a0003b7db9e1a
tree377d523ed0240c9b7e71f2cd3e3cc12b7065a583
parentb95fd03b5f0b66384bd7c190d5861ae68eb98c85
x86/HVM: use fixed TSC value when saving or restoring domain

When a domain is saved each VCPU's TSC value needs to be preserved. To get it we
use hvm_get_guest_tsc(). This routine (either itself or via get_s_time() which
it may call) calculates VCPU's TSC based on current host's TSC value (by doing a
rdtscll()). Since this is performed for each VCPU separately we end up with
un-synchronized TSCs.

Similarly, during a restore each VCPU is assigned its TSC based on host's current
tick, causing virtual TSCs to diverge further.

With this, we can easily get into situation where a guest may see time going
backwards.

Instead of reading new TSC value for each VCPU when saving/restoring it we should
use the same value across all VCPUs.

Reported-by: Philippe Coquard <philippe.coquard@mpsa.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/hvm/hvm.c
xen/arch/x86/hvm/save.c
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/hvm/vmx/vmx.c
xen/include/asm-x86/hvm/hvm.h