summaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorBruce Rogers2012-07-20 18:44:24 +0200
committerMarcelo Tosatti2012-08-01 22:23:50 +0200
commit4b6486659a7defef82ea51b276024b3aa357fefc (patch)
treec5d6b29bb6c8658c3310fc91d0a6a4ccb8c4f99c /arch/x86
parentKVM: PIC: call ack notifiers for irqs that are dropped form irr (diff)
downloadkernel-qcow2-linux-4b6486659a7defef82ea51b276024b3aa357fefc.tar.gz
kernel-qcow2-linux-4b6486659a7defef82ea51b276024b3aa357fefc.tar.xz
kernel-qcow2-linux-4b6486659a7defef82ea51b276024b3aa357fefc.zip
KVM: x86: apply kvmclock offset to guest wall clock time
When a guest migrates to a new host, the system time difference from the previous host is used in the updates to the kvmclock system time visible to the guest, resulting in a continuation of correct kvmclock based guest timekeeping. The wall clock component of the kvmclock provided time is currently not updated with this same time offset. Since the Linux guest caches the wall clock based time, this discrepency is not noticed until the guest is rebooted. After reboot the guest's time calculations are off. This patch adjusts the wall clock by the kvmclock_offset, resulting in correct guest time after a reboot. Cc: Zachary Amsden <zamsden@gmail.com> Signed-off-by: Bruce Rogers <brogers@suse.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kvm/x86.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 59b59508ff07..42bce48f6928 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -925,6 +925,10 @@ static void kvm_write_wall_clock(struct kvm *kvm, gpa_t wall_clock)
*/
getboottime(&boot);
+ if (kvm->arch.kvmclock_offset) {
+ struct timespec ts = ns_to_timespec(kvm->arch.kvmclock_offset);
+ boot = timespec_sub(boot, ts);
+ }
wc.sec = boot.tv_sec;
wc.nsec = boot.tv_nsec;
wc.version = version;