qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Vitaly Kuznetsov
Subject: [PATCH RFC 21/22] i386: record if Hyper-V features were already expanded
Date: Fri, 4 Sep 2020 16:54:30 +0200

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 --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);
-- 
2.25.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]