yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
c461a1
From 592237e21bc3527ebc66b8f4c76652cf5cde9438 Mon Sep 17 00:00:00 2001
c461a1
From: "plai@redhat.com" <plai@redhat.com>
c461a1
Date: Mon, 23 Sep 2019 20:40:19 +0200
c461a1
Subject: [PATCH 03/12] target-i386: Isolate KVM-specific code on CPU feature
2ec96d
 filtering logic
2ec96d
MIME-Version: 1.0
2ec96d
Content-Type: text/plain; charset=UTF-8
2ec96d
Content-Transfer-Encoding: 8bit
2ec96d
c461a1
RH-Author: plai@redhat.com
c461a1
Message-id: <1569271227-28026-3-git-send-email-plai@redhat.com>
c461a1
Patchwork-id: 90855
c461a1
O-Subject: [RHEL7.8 qemu-kvm PATCH v6 02/10] target-i386: Isolate KVM-specific code on CPU feature filtering logic
c461a1
Bugzilla: 1709971
c461a1
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
2ec96d
RH-Acked-by: Bandan Das <bsd@redhat.com>
c461a1
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
c461a1
c461a1
From: Eduardo Habkost <ehabkost@redhat.com>
2ec96d
2ec96d
This will allow us to re-use the feature filtering logic (and the
2ec96d
check/enforce flag logic) for TCG.
2ec96d
2ec96d
Reviewed-by: Richard Henderson <rth@twiddle.net>
2ec96d
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2ec96d
Signed-off-by: Andreas Färber <afaerber@suse.de>
2ec96d
(cherry picked from commit 27418adf32b9cd164d464fffc4fc0505d6b2b15d)
2ec96d
Signed-off-by: Paul Lai <plai@redhat.com>
2ec96d
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
2ec96d
---
2ec96d
 target-i386/cpu.c | 21 +++++++++++++--------
2ec96d
 1 file changed, 13 insertions(+), 8 deletions(-)
2ec96d
2ec96d
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
c461a1
index 6fb805b..ff0921f 100644
2ec96d
--- a/target-i386/cpu.c
2ec96d
+++ b/target-i386/cpu.c
c461a1
@@ -2387,6 +2387,16 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
2ec96d
     return cpu_list;
2ec96d
 }
2ec96d
 
2ec96d
+static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w)
2ec96d
+{
2ec96d
+    FeatureWordInfo *wi = &feature_word_info[w];
2ec96d
+
2ec96d
+    assert(kvm_enabled());
2ec96d
+    return kvm_arch_get_supported_cpuid(kvm_state, wi->cpuid_eax,
2ec96d
+                                                   wi->cpuid_ecx,
2ec96d
+                                                   wi->cpuid_reg);
2ec96d
+}
2ec96d
+
2ec96d
 /*
2ec96d
  * Filters CPU feature words based on host availability of each feature.
2ec96d
  *
c461a1
@@ -2394,20 +2404,15 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
2ec96d
  *
2ec96d
  * Returns: 0 if all flags are supported by the host, non-zero otherwise.
2ec96d
  */
2ec96d
-static int filter_features_for_kvm(X86CPU *cpu)
2ec96d
+static int x86_cpu_filter_features(X86CPU *cpu)
2ec96d
 {
2ec96d
     CPUX86State *env = &cpu->env;
2ec96d
-    KVMState *s = kvm_state;
2ec96d
     FeatureWord w;
2ec96d
     int rv = 0;
2ec96d
 
2ec96d
-    assert(kvm_enabled());
2ec96d
-
2ec96d
     for (w = 0; w < FEATURE_WORDS; w++) {
2ec96d
         FeatureWordInfo *wi = &feature_word_info[w];
2ec96d
-        uint32_t host_feat = kvm_arch_get_supported_cpuid(s, wi->cpuid_eax,
2ec96d
-                                                             wi->cpuid_ecx,
2ec96d
-                                                             wi->cpuid_reg);
2ec96d
+        uint32_t host_feat = x86_cpu_get_supported_feature_word(w);
2ec96d
         uint32_t requested_features = env->features[w];
2ec96d
         env->features[w] &= host_feat;
2ec96d
         cpu->filtered_features[w] = requested_features & ~env->features[w];
c461a1
@@ -3102,7 +3107,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
2ec96d
             env->features[w] &= feature_word_info[w].tcg_features;
2ec96d
         }
2ec96d
     } else {
2ec96d
-        if (filter_features_for_kvm(cpu) && cpu->enforce_cpuid) {
2ec96d
+        if (x86_cpu_filter_features(cpu) && cpu->enforce_cpuid) {
2ec96d
             error_setg(&local_err,
2ec96d
                        "Host's CPU doesn't support requested features");
2ec96d
             goto out;
2ec96d
-- 
2ec96d
1.8.3.1
2ec96d