qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
	anthony@codemonkey.ws, gleb@redhat.com
Subject: [Qemu-devel] [PULL 8/9] kvm: i386: fix LAPIC TSC deadline timer save/restore
Date: Sat, 24 Aug 2013 05:50:01 +0200	[thread overview]
Message-ID: <1377316202-2849-9-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1377316202-2849-1-git-send-email-pbonzini@redhat.com>

From: Marcelo Tosatti <mtosatti@redhat.com>

The configuration of the timer represented by MSR_IA32_TSCDEADLINE depends on:

- APIC LVT Timer register.
- TSC value.

Change the order to respect the dependency.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target-i386/kvm.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 7bb8455..58f7bb7 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -1073,6 +1073,26 @@ static void kvm_msr_entry_set(struct kvm_msr_entry *entry,
     entry->data = value;
 }
 
+static int kvm_put_tscdeadline_msr(X86CPU *cpu)
+{
+    CPUX86State *env = &cpu->env;
+    struct {
+        struct kvm_msrs info;
+        struct kvm_msr_entry entries[1];
+    } msr_data;
+    struct kvm_msr_entry *msrs = msr_data.entries;
+
+    if (!has_msr_tsc_deadline) {
+        return 0;
+    }
+
+    kvm_msr_entry_set(&msrs[0], MSR_IA32_TSCDEADLINE, env->tsc_deadline);
+
+    msr_data.info.nmsrs = 1;
+
+    return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MSRS, &msr_data);
+}
+
 static int kvm_put_msrs(X86CPU *cpu, int level)
 {
     CPUX86State *env = &cpu->env;
@@ -1096,9 +1116,6 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
     if (has_msr_tsc_adjust) {
         kvm_msr_entry_set(&msrs[n++], MSR_TSC_ADJUST, env->tsc_adjust);
     }
-    if (has_msr_tsc_deadline) {
-        kvm_msr_entry_set(&msrs[n++], MSR_IA32_TSCDEADLINE, env->tsc_deadline);
-    }
     if (has_msr_misc_enable) {
         kvm_msr_entry_set(&msrs[n++], MSR_IA32_MISC_ENABLE,
                           env->msr_ia32_misc_enable);
@@ -1808,6 +1825,12 @@ int kvm_arch_put_registers(CPUState *cpu, int level)
             return ret;
         }
     }
+
+    ret = kvm_put_tscdeadline_msr(x86_cpu);
+    if (ret < 0) {
+        return ret;
+    }
+
     ret = kvm_put_vcpu_events(x86_cpu, level);
     if (ret < 0) {
         return ret;
-- 
1.8.3.1

  parent reply	other threads:[~2013-08-24  3:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-24  3:49 [Qemu-devel] [PULL 0/9] KVM changes for 2013-08-23 Paolo Bonzini
2013-08-24  3:49 ` [Qemu-devel] [PULL 1/9] Initialize IA32_FEATURE_CONTROL MSR in reset and migration Paolo Bonzini
2013-08-24  3:49 ` [Qemu-devel] [PULL 2/9] target-i386: remove tabs from target-i386/cpu.h Paolo Bonzini
2013-08-24  3:49 ` [Qemu-devel] [PULL 3/9] kvm: migrate vPMU state Paolo Bonzini
2013-08-24  3:49 ` [Qemu-devel] [PULL 4/9] kvm: add KVM_IRQFD_FLAG_RESAMPLE support Paolo Bonzini
2013-08-24  3:49 ` [Qemu-devel] [PULL 5/9] kvm: x86: fix setting IA32_FEATURE_CONTROL with nested VMX disabled Paolo Bonzini
2013-08-24  3:49 ` [Qemu-devel] [PULL 6/9] kvm: Simplify kvm_handle_io Paolo Bonzini
2013-08-24  3:50 ` [Qemu-devel] [PULL 7/9] kvm-all.c: max_cpus should not exceed KVM vcpu limit Paolo Bonzini
2013-08-24  3:50 ` Paolo Bonzini [this message]
2013-08-24  3:50 ` [Qemu-devel] [PULL 9/9] kvm: shorten the parameter list for get_real_device() Paolo Bonzini
2013-08-24  3:55 ` [Qemu-devel] [PULL 0/9] KVM changes for 2013-08-23 Paolo Bonzini
  -- strict thread matches above, loose matches on Subject: below --
2013-08-24  3:55 [Qemu-devel] [PULL v2 " Paolo Bonzini
2013-08-24  3:55 ` [Qemu-devel] [PULL 8/9] kvm: i386: fix LAPIC TSC deadline timer save/restore Paolo Bonzini
2013-08-23  9:39 [Qemu-devel] [PULL 0/9] KVM changes for 2013-08-23 Paolo Bonzini
2013-08-23  9:39 ` [Qemu-devel] [PULL 8/9] kvm: i386: fix LAPIC TSC deadline timer save/restore Paolo Bonzini
2013-08-23  9:03 [Qemu-devel] [PULL 0/9] KVM changes for 2013-08-23 Paolo Bonzini
2013-08-23  9:03 ` [Qemu-devel] [PULL 8/9] kvm: i386: fix LAPIC TSC deadline timer save/restore 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=1377316202-2849-9-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=gleb@redhat.com \
    --cc=mtosatti@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).