diff mbox series

[RFC,21/22] i386: record if Hyper-V features were already expanded

Message ID 20200904145431.196885-22-vkuznets@redhat.com (mailing list archive)
State New, archived
Headers show
Series i386: KVM: expand Hyper-V features early | expand

Commit Message

Vitaly Kuznetsov Sept. 4, 2020, 2:54 p.m. UTC
Introduce a per cpu hyperv_features_expaned flag indicating that Hyper-V
related CPUIDs were already acquired from KVM. We are going to start
doing the expansion prior to creating KVM vCPU but in case KVM doesn't
support sustem wide KVM_GET_SUPPORTED_HV_CPUID ioctl this can't happen.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 target/i386/cpu.h | 1 +
 target/i386/kvm.c | 6 ++++++
 2 files changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 0aad60e0c707..c72755139047 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1669,6 +1669,7 @@  struct X86CPU {
     uint32_t hyperv_interface_id[4];
     uint32_t hyperv_version_id[4];
     uint32_t hyperv_limits[3];
+    bool hyperv_features_expaned;
 
     bool check_cpuid;
     bool enforce_cpuid;
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 0945983498b2..961241528a5c 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -1225,6 +1225,10 @@  static void hyperv_expand_features(CPUState *cs, Error **errp)
     if (!hyperv_enabled(cpu))
         return;
 
+    if (cpu->hyperv_features_expaned) {
+        return;
+    }
+
     if (kvm_check_extension(kvm_state, KVM_CAP_HYPERV_CPUID) > 0) {
         cpuid = get_supported_hv_cpuid(cs);
     } else {
@@ -1361,6 +1365,8 @@  static void hyperv_expand_features(CPUState *cs, Error **errp)
     /* Not exposed by KVM but needed to make CPU hotplug in Windows work */
     env->features[FEAT_HYPERV_EDX] |= HV_CPU_DYNAMIC_PARTITIONING_AVAILABLE;
 
+    cpu->hyperv_features_expaned = true;
+
 out:
 
     g_free(cpuid);