yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
958e1b
From da4fe791cecafbec05395041c52cb545308b1b61 Mon Sep 17 00:00:00 2001
958e1b
From: Marcelo Tosatti <mtosatti@redhat.com>
958e1b
Date: Thu, 26 Jun 2014 15:06:15 +0200
958e1b
Subject: [PATCH 13/13] kvmclock: Ensure proper env->tsc value for kvmclock_current_nsec calculation
958e1b
MIME-Version: 1.0
958e1b
Content-Type: text/plain; charset=UTF-8
958e1b
Content-Transfer-Encoding: 8bit
958e1b
958e1b
RH-Author: Marcelo Tosatti <mtosatti@redhat.com>
958e1b
Message-id: <20140626150716.639538444@amt.cnet>
958e1b
Patchwork-id: 59386
958e1b
O-Subject: [RHEL-7.1 qemu-kvm PATCH 2/2] kvmclock: Ensure proper env->tsc value for kvmclock_current_nsec calculation
958e1b
Bugzilla: 1098602
958e1b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
958e1b
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
958e1b
RH-Acked-by: Andrew Jones <drjones@redhat.com>
958e1b
958e1b
commit 9b1786829aefb83f37a8f3135e3ea91c56001b56 upstream
958e1b
958e1b
Ensure proper env->tsc value for kvmclock_current_nsec calculation.
958e1b
958e1b
Reported-by: Marcin GibuĊ‚a <m.gibula@beyond.pl>
958e1b
Cc: qemu-stable@nongnu.org
958e1b
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
958e1b
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
958e1b
958e1b
BZ: 1098602
958e1b
958e1b
---
958e1b
 hw/i386/kvm/clock.c |    4 ++++
958e1b
 1 file changed, 4 insertions(+)
958e1b
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
---
958e1b
 hw/i386/kvm/clock.c |    4 ++++
958e1b
 1 files changed, 4 insertions(+), 0 deletions(-)
958e1b
958e1b
diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c
958e1b
index 1f2a26e..d52c2ea 100644
958e1b
--- a/hw/i386/kvm/clock.c
958e1b
+++ b/hw/i386/kvm/clock.c
958e1b
@@ -17,6 +17,7 @@
958e1b
 #include "qemu/host-utils.h"
958e1b
 #include "sysemu/sysemu.h"
958e1b
 #include "sysemu/kvm.h"
958e1b
+#include "sysemu/cpus.h"
958e1b
 #include "hw/sysbus.h"
958e1b
 #include "hw/kvm/clock.h"
958e1b
 
958e1b
@@ -60,6 +61,7 @@ static uint64_t kvmclock_current_nsec(KVMClockState *s)
958e1b
 
958e1b
     cpu_physical_memory_read(kvmclock_struct_pa, &time, sizeof(time));
958e1b
 
958e1b
+    assert(time.tsc_timestamp <= migration_tsc);
958e1b
     delta = migration_tsc - time.tsc_timestamp;
958e1b
     if (time.tsc_shift < 0) {
958e1b
         delta >>= -time.tsc_shift;
958e1b
@@ -118,6 +120,8 @@ static void kvmclock_vm_state_change(void *opaque, int running,
958e1b
         if (s->clock_valid) {
958e1b
             return;
958e1b
         }
958e1b
+
958e1b
+        cpu_synchronize_all_states();
958e1b
         ret = kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, &data);
958e1b
         if (ret < 0) {
958e1b
             fprintf(stderr, "KVM_GET_CLOCK failed: %s\n", strerror(ret));
958e1b
-- 
958e1b
1.7.1
958e1b