Blame SOURCES/kvm-i386-kvm-set-tsc_khz-before-configuring-Hyper-V-CPUI.patch

4a2fec
From 4297501331fd196444ad0b830b026ae39c2744cf Mon Sep 17 00:00:00 2001
4a2fec
From: Ladi Prosek <lprosek@redhat.com>
4a2fec
Date: Tue, 10 Oct 2017 14:02:49 +0200
4a2fec
Subject: [PATCH 11/69] i386/kvm: set tsc_khz before configuring Hyper-V CPUID
4a2fec
4a2fec
RH-Author: Ladi Prosek <lprosek@redhat.com>
4a2fec
Message-id: <20171010140251.23801-3-lprosek@redhat.com>
4a2fec
Patchwork-id: 77060
4a2fec
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH 2/4] i386/kvm: set tsc_khz before configuring Hyper-V CPUID
4a2fec
Bugzilla: 1500347
4a2fec
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
RH-Acked-by: David Hildenbrand <david@redhat.com>
4a2fec
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
4a2fec
4a2fec
Timing-related Hyper-V enlightenments will benefit from knowing the final
4a2fec
tsc_khz value. This commit just moves the code in preparation for further
4a2fec
changes.
4a2fec
4a2fec
Signed-off-by: Ladi Prosek <lprosek@redhat.com>
4a2fec
Message-Id: <20170807085703.32267-3-lprosek@redhat.com>
4a2fec
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
(cherry picked from commit ddb98b5a9ff27b21100da1d701ddf5da34c66673)
4a2fec
Signed-off-by: Ladi Prosek <lprosek@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 target/i386/kvm.c | 38 +++++++++++++++++++-------------------
4a2fec
 1 file changed, 19 insertions(+), 19 deletions(-)
4a2fec
4a2fec
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
4a2fec
index b14a0db..15d56ae 100644
4a2fec
--- a/target/i386/kvm.c
4a2fec
+++ b/target/i386/kvm.c
4a2fec
@@ -695,6 +695,25 @@ int kvm_arch_init_vcpu(CPUState *cs)
4a2fec
 
4a2fec
     cpuid_i = 0;
4a2fec
 
4a2fec
+    r = kvm_arch_set_tsc_khz(cs);
4a2fec
+    if (r < 0) {
4a2fec
+        goto fail;
4a2fec
+    }
4a2fec
+
4a2fec
+    /* vcpu's TSC frequency is either specified by user, or following
4a2fec
+     * the value used by KVM if the former is not present. In the
4a2fec
+     * latter case, we query it from KVM and record in env->tsc_khz,
4a2fec
+     * so that vcpu's TSC frequency can be migrated later via this field.
4a2fec
+     */
4a2fec
+    if (!env->tsc_khz) {
4a2fec
+        r = kvm_check_extension(cs->kvm_state, KVM_CAP_GET_TSC_KHZ) ?
4a2fec
+            kvm_vcpu_ioctl(cs, KVM_GET_TSC_KHZ) :
4a2fec
+            -ENOTSUP;
4a2fec
+        if (r > 0) {
4a2fec
+            env->tsc_khz = r;
4a2fec
+        }
4a2fec
+    }
4a2fec
+
4a2fec
     /* Paravirtualization CPUIDs */
4a2fec
     if (hyperv_enabled(cpu)) {
4a2fec
         c = &cpuid_data.entries[cpuid_i++];
4a2fec
@@ -961,25 +980,6 @@ int kvm_arch_init_vcpu(CPUState *cs)
4a2fec
         }
4a2fec
     }
4a2fec
 
4a2fec
-    r = kvm_arch_set_tsc_khz(cs);
4a2fec
-    if (r < 0) {
4a2fec
-        goto fail;
4a2fec
-    }
4a2fec
-
4a2fec
-    /* vcpu's TSC frequency is either specified by user, or following
4a2fec
-     * the value used by KVM if the former is not present. In the
4a2fec
-     * latter case, we query it from KVM and record in env->tsc_khz,
4a2fec
-     * so that vcpu's TSC frequency can be migrated later via this field.
4a2fec
-     */
4a2fec
-    if (!env->tsc_khz) {
4a2fec
-        r = kvm_check_extension(cs->kvm_state, KVM_CAP_GET_TSC_KHZ) ?
4a2fec
-            kvm_vcpu_ioctl(cs, KVM_GET_TSC_KHZ) :
4a2fec
-            -ENOTSUP;
4a2fec
-        if (r > 0) {
4a2fec
-            env->tsc_khz = r;
4a2fec
-        }
4a2fec
-    }
4a2fec
-
4a2fec
     if (cpu->vmware_cpuid_freq
4a2fec
         /* Guests depend on 0x40000000 to detect this feature, so only expose
4a2fec
          * it if KVM exposes leaf 0x40000000. (Conflicts with Hyper-V) */
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec