cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-i386-fix-LAPIC-TSC-deadline-timer-save-restore.patch

218e99
From 12623687c4bd5eeb5b3ca8f23cf3b646357e2bc3 Mon Sep 17 00:00:00 2001
218e99
From: Marcelo Tosatti <mtosatti@redhat.com>
218e99
Date: Tue, 20 Aug 2013 21:42:24 +0200
218e99
Subject: [PATCH 25/28] kvm: i386: fix LAPIC TSC deadline timer save/restore
218e99
218e99
RH-Author: Marcelo Tosatti <mtosatti@redhat.com>
218e99
Message-id: <20130820214224.GA9334@amt.cnet>
218e99
Patchwork-id: 53623
218e99
O-Subject: [RHEL7 qemu-kvm PATCH] kvm: i386: fix LAPIC TSC deadline timer save/restore
218e99
Bugzilla: 972433
218e99
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
218e99
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
218e99
RH-Acked-by: Gleb Natapov <gleb@redhat.com>
218e99
218e99
BZ: 972433
218e99
218e99
commit 7477cd3897082d2650d520a4e9aa7f8affa3dd5d of uq/master branch
218e99
of qemu-kvm.git repository
218e99
218e99
The configuration of the timer represented by MSR_IA32_TSCDEADLINE depends on:
218e99
218e99
- APIC LVT Timer register.
218e99
- TSC value.
218e99
218e99
Change the order to respect the dependency.
218e99
218e99
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
218e99
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 target-i386/kvm.c |   29 ++++++++++++++++++++++++++---
218e99
 1 files changed, 26 insertions(+), 3 deletions(-)
218e99
218e99
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
218e99
index 8da6a0d..c5a9416 100644
218e99
--- a/target-i386/kvm.c
218e99
+++ b/target-i386/kvm.c
218e99
@@ -1042,6 +1042,26 @@ static void kvm_msr_entry_set(struct kvm_msr_entry *entry,
218e99
     entry->data = value;
218e99
 }
218e99
 
218e99
+static int kvm_put_tscdeadline_msr(X86CPU *cpu)
218e99
+{
218e99
+    CPUX86State *env = &cpu->env;
218e99
+    struct {
218e99
+        struct kvm_msrs info;
218e99
+        struct kvm_msr_entry entries[1];
218e99
+    } msr_data;
218e99
+    struct kvm_msr_entry *msrs = msr_data.entries;
218e99
+
218e99
+    if (!has_msr_tsc_deadline) {
218e99
+        return 0;
218e99
+    }
218e99
+
218e99
+    kvm_msr_entry_set(&msrs[0], MSR_IA32_TSCDEADLINE, env->tsc_deadline);
218e99
+
218e99
+    msr_data.info.nmsrs = 1;
218e99
+
218e99
+    return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MSRS, &msr_data);
218e99
+}
218e99
+
218e99
 static int kvm_put_msrs(X86CPU *cpu, int level)
218e99
 {
218e99
     CPUX86State *env = &cpu->env;
218e99
@@ -1065,9 +1085,6 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
218e99
     if (has_msr_tsc_adjust) {
218e99
         kvm_msr_entry_set(&msrs[n++], MSR_TSC_ADJUST, env->tsc_adjust);
218e99
     }
218e99
-    if (has_msr_tsc_deadline) {
218e99
-        kvm_msr_entry_set(&msrs[n++], MSR_IA32_TSCDEADLINE, env->tsc_deadline);
218e99
-    }
218e99
     if (has_msr_misc_enable) {
218e99
         kvm_msr_entry_set(&msrs[n++], MSR_IA32_MISC_ENABLE,
218e99
                           env->msr_ia32_misc_enable);
218e99
@@ -1705,6 +1722,12 @@ int kvm_arch_put_registers(CPUState *cpu, int level)
218e99
             return ret;
218e99
         }
218e99
     }
218e99
+
218e99
+    ret = kvm_put_tscdeadline_msr(x86_cpu);
218e99
+    if (ret < 0) {
218e99
+        return ret;
218e99
+    }
218e99
+
218e99
     ret = kvm_put_vcpu_events(x86_cpu, level);
218e99
     if (ret < 0) {
218e99
         return ret;
218e99
-- 
218e99
1.7.1
218e99