From: Marcelo Tosatti <mtosatti@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: kvm@vger.kernel.org,
Benjamin Serebrin <benjamin.serebrin@amd.com>,
Marcelo Tosatti <mtosatti@redhat.com>
Subject: [patch 1/3] QEMU/KVM: x86: separate TSC load from kvm_arch_load_regs
Date: Mon, 08 Dec 2008 23:12:48 -0200 [thread overview]
Message-ID: <20081209012212.014302332@localhost.localdomain> (raw)
In-Reply-To: 20081209011247.570596925@localhost.localdomain
[-- Attachment #1: kvm-load-tsc --]
[-- Type: text/plain, Size: 2490 bytes --]
kvm_load_registers is a general interface to load registers, and is
used by vmport, gdbstub, etc. The TSC MSR is continually counting, so
it can't be simply read and written back as the other registers/MSR's
(doing so overwrites the current count).
Introduce kvm_load_tsc and use it for x86's migration CPU load code.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: kvm-userspace.tip/qemu/qemu-kvm-x86.c
===================================================================
--- kvm-userspace.tip.orig/qemu/qemu-kvm-x86.c
+++ kvm-userspace.tip/qemu/qemu-kvm-x86.c
@@ -257,7 +257,6 @@ void kvm_arch_load_regs(CPUState *env)
set_msr_entry(&msrs[n++], MSR_IA32_SYSENTER_EIP, env->sysenter_eip);
if (kvm_has_msr_star)
set_msr_entry(&msrs[n++], MSR_STAR, env->star);
- set_msr_entry(&msrs[n++], MSR_IA32_TSC, env->tsc);
#ifdef TARGET_X86_64
if (lm_capable_kernel) {
set_msr_entry(&msrs[n++], MSR_CSTAR, env->cstar);
@@ -272,6 +271,18 @@ void kvm_arch_load_regs(CPUState *env)
perror("kvm_set_msrs FAILED");
}
+void kvm_load_tsc(CPUState *env)
+{
+ int rc;
+ struct kvm_msr_entry msr;
+
+ set_msr_entry(&msr, MSR_IA32_TSC, env->tsc);
+
+ rc = kvm_set_msrs(kvm_context, env->cpu_index, &msr, 1);
+ if (rc == -1)
+ perror("kvm_set_tsc FAILED.\n");
+}
+
void kvm_save_mpstate(CPUState *env)
{
#ifdef KVM_CAP_MP_STATE
Index: kvm-userspace.tip/qemu/qemu-kvm-x86.h
===================================================================
--- /dev/null
+++ kvm-userspace.tip/qemu/qemu-kvm-x86.h
@@ -0,0 +1,13 @@
+/*
+ * qemu/kvm integration
+ *
+ * Copyright (C) 2006-2008 Qumranet Technologies
+ *
+ * Licensed under the terms of the GNU GPL version 2 or higher.
+ */
+#ifndef QEMU_KVM_X86
+#define QEMU_KVM_X86
+
+void kvm_load_tsc(CPUState *env);
+
+#endif
Index: kvm-userspace.tip/qemu/target-i386/machine.c
===================================================================
--- kvm-userspace.tip.orig/qemu/target-i386/machine.c
+++ kvm-userspace.tip/qemu/target-i386/machine.c
@@ -5,6 +5,7 @@
#include "exec-all.h"
#include "qemu-kvm.h"
+#include "qemu-kvm-x86.h"
void register_machines(void)
{
@@ -328,6 +329,7 @@ int cpu_load(QEMUFile *f, void *opaque,
}
qemu_get_be64s(f, &env->tsc);
kvm_load_registers(env);
+ kvm_load_tsc(env);
if (version_id >= 5) {
qemu_get_be32s(f, &env->mp_state);
kvm_load_mpstate(env);
--
next prev parent reply other threads:[~2008-12-09 1:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-09 1:12 [patch 0/3] synchronized TSC between vcpu's on SMP guests Marcelo Tosatti
2008-12-09 1:12 ` Marcelo Tosatti [this message]
2008-12-10 10:10 ` [patch 1/3] QEMU/KVM: x86: separate TSC load from kvm_arch_load_regs Avi Kivity
2008-12-09 1:12 ` [patch 2/3] QEMU/KVM: BIOS: revert TSC zeroing Marcelo Tosatti
2008-12-09 1:12 ` [patch 3/3] KVM: VMX: initialize TSC offset relative to vm creation time Marcelo Tosatti
2008-12-10 10:19 ` Avi Kivity
2008-12-10 16:53 ` Marcelo Tosatti
2008-12-11 17:38 ` Avi Kivity
2008-12-11 19:45 ` Marcelo Tosatti
2008-12-28 9:26 ` Avi Kivity
2008-12-09 11:38 ` [patch 0/3] synchronized TSC between vcpu's on SMP guests Michael Tokarev
2008-12-09 10:47 ` Marcelo Tosatti
2008-12-09 22:48 ` Michael Tokarev
2008-12-22 23:16 ` David S. Ahern
2008-12-28 9:33 ` Avi Kivity
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=20081209012212.014302332@localhost.localdomain \
--to=mtosatti@redhat.com \
--cc=avi@redhat.com \
--cc=benjamin.serebrin@amd.com \
--cc=kvm@vger.kernel.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