Received: from eggs.gnu.org ([2001:4830:134:3::10]:42029) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4Z7O-0005Fb-RK for qemu-devel@nongnu.org; Tue, 08 Jul 2014 13:24:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4Z6S-00017c-Hm for qemu-devel@nongnu.org; Tue, 08 Jul 2014 13:23:50 -0400 Received: from e38.co.us.ibm.com ([32.97.110.159]:47983) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4Z6S-000170-8j for qemu-devel@nongnu.org; Tue, 08 Jul 2014 13:22:52 -0400 Received: from /spool/local by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 8 Jul 2014 11:22:51 -0600 From: Michael Roth Date: Tue, 8 Jul 2014 12:18:48 -0500 Message-Id: <1404839947-1086-138-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1404839947-1086-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1404839947-1086-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH 137/156] kvmclock: Ensure proper env->tsc value for kvmclock_current_nsec calculation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org From: Marcelo Tosatti Ensure proper env->tsc value for kvmclock_current_nsec calculation. Reported-by: Marcin GibuĊ‚a Cc: qemu-stable@nongnu.org Signed-off-by: Marcelo Tosatti Signed-off-by: Paolo Bonzini (cherry picked from commit 9b1786829aefb83f37a8f3135e3ea91c56001b56) Signed-off-by: Michael Roth --- hw/i386/kvm/clock.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c index be5f867..6f62498 100644 --- a/hw/i386/kvm/clock.c +++ b/hw/i386/kvm/clock.c @@ -17,6 +17,7 @@ #include "qemu/host-utils.h" #include "sysemu/sysemu.h" #include "sysemu/kvm.h" +#include "sysemu/cpus.h" #include "hw/sysbus.h" #include "hw/kvm/clock.h" @@ -65,6 +66,7 @@ static uint64_t kvmclock_current_nsec(KVMClockState *s) cpu_physical_memory_read(kvmclock_struct_pa, &time, sizeof(time)); + assert(time.tsc_timestamp <= migration_tsc); delta = migration_tsc - time.tsc_timestamp; if (time.tsc_shift < 0) { delta >>= -time.tsc_shift; @@ -123,6 +125,8 @@ static void kvmclock_vm_state_change(void *opaque, int running, if (s->clock_valid) { return; } + + cpu_synchronize_all_states(); ret = kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, &data); if (ret < 0) { fprintf(stderr, "KVM_GET_CLOCK failed: %s\n", strerror(ret)); -- 1.9.1