From: Marcelo Tosatti <mtosatti@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Andrey Korolyov" <andrey@xdel.ru>,
"Marcin GibuÅa" <m.gibula@beyond.pl>,
"Marcelo Tosatti" <mtosatti@redhat.com>
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 [thread overview]
Message-ID: <20140905135539.340689829@amt.cnet> (raw)
In-Reply-To: 20140905135244.104423770@amt.cnet
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: kvmclock-ensure-proper-env-tsc.patch --]
[-- Type: text/plain, Size: 1276 bytes --]
Ensure proper env->tsc value for kvmclock_current_nsec calculation.
Reported-and-analyzed-by: Marcin Gibuła <m.gibula@beyond.pl>
Cc: qemu-stable@nongnu.org
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
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));
next prev parent reply other threads:[~2014-09-05 13:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-05 13:52 [Qemu-devel] [patch 0/3] kvmclock: Ensure time in migration never goes backward (v3) Marcelo Tosatti
2014-09-05 13:52 ` [Qemu-devel] [patch 1/3] kvmclock: Ensure time in migration never goes backward Marcelo Tosatti
2014-09-09 15:12 ` Marcelo Tosatti
2014-09-09 21:16 ` Alexander Graf
2014-09-09 23:07 ` Marcelo Tosatti
2014-09-05 13:52 ` [Qemu-devel] [patch 2/3] Introduce cpu_clean_all_dirty Marcelo Tosatti
2014-09-05 13:52 ` Marcelo Tosatti [this message]
2014-09-05 18:16 ` [Qemu-devel] [patch 0/3] kvmclock: Ensure time in migration never goes backward (v3) Andrey Korolyov
2014-09-05 18:26 ` Marcelo Tosatti
2014-09-05 18:29 ` Paolo Bonzini
2014-09-05 18:35 ` Andrey Korolyov
2014-09-05 19:35 ` Andrey Korolyov
2014-09-05 22:14 ` Paolo Bonzini
2014-09-05 23:05 ` Andrey Korolyov
2014-09-09 17:54 ` Andrey Korolyov
2014-09-16 9:14 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140905135539.340689829@amt.cnet \
--to=mtosatti@redhat.com \
--cc=andrey@xdel.ru \
--cc=m.gibula@beyond.pl \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).