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

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