qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [patch 3/3] kvmclock: Ensure proper env->tsc value for kvmc


From: Marcelo Tosatti
Subject: [Qemu-devel] [patch 3/3] kvmclock: Ensure proper env->tsc value for kvmclock_current_nsec calculation
Date: Fri, 05 Sep 2014 10:52:47 -0300
User-agent: quilt/0.60-1

Ensure proper env->tsc value for kvmclock_current_nsec calculation.

Reported-and-analyzed-by: Marcin Gibuła <address@hidden>
Cc: address@hidden
Signed-off-by: Marcelo Tosatti <address@hidden>

---
 hw/i386/kvm/clock.c |    5 +++++
 1 file changed, 5 insertions(+)

Index: qemu/hw/i386/kvm/clock.c
===================================================================
--- qemu.orig/hw/i386/kvm/clock.c       2014-09-05 10:07:04.116665549 -0300
+++ qemu/hw/i386/kvm/clock.c    2014-09-05 10:31:06.894106473 -0300
@@ -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 @@
 
     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,9 @@
         if (s->clock_valid) {
             return;
         }
+
+        cpu_synchronize_all_states();
+        cpu_clean_all_dirty();
         ret = kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, &data);
         if (ret < 0) {
             fprintf(stderr, "KVM_GET_CLOCK failed: %s\n", strerror(ret));





reply via email to

[Prev in Thread] Current Thread [Next in Thread]