Blame SOURCES/kvm-target-i386-Loop-based-feature-word-filtering-in-TCG.patch

619821
From 91e436476830a82f429e1df848ea751280580b46 Mon Sep 17 00:00:00 2001
619821
From: Eduardo Habkost <ehabkost@redhat.com>
619821
Date: Thu, 23 Feb 2017 14:29:45 +0100
619821
Subject: [PATCH 15/17] target-i386: Loop-based feature word filtering in TCG
619821
 mode
619821
MIME-Version: 1.0
619821
Content-Type: text/plain; charset=UTF-8
619821
Content-Transfer-Encoding: 8bit
619821
619821
RH-Author: Eduardo Habkost <ehabkost@redhat.com>
619821
Message-id: <20170223142945.17790-15-ehabkost@redhat.com>
619821
Patchwork-id: 74046
619821
O-Subject: [RHEL-7.4 qemu-kvm PATCH v2 14/14] target-i386: Loop-based feature word filtering in TCG mode
619821
Bugzilla: 1382122
619821
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
619821
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
619821
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
619821
619821
Instead of manually filtering each feature word, add a tcg_features
619821
field to FeatureWordInfo, and use that field to filter all feature words
619821
in TCG mode.
619821
619821
Reviewed-by: Richard Henderson <rth@twiddle.net>
619821
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
619821
Signed-off-by: Andreas Färber <afaerber@suse.de>
619821
(cherry picked from commit 37ce3522cb88c524caec57cb52a4bfbb880abbe5)
619821
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
619821
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
619821
---
619821
 target-i386/cpu.c | 26 +++++++++++++++-----------
619821
 1 file changed, 15 insertions(+), 11 deletions(-)
619821
619821
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
619821
index 010b95f..38056eb 100644
619821
--- a/target-i386/cpu.c
619821
+++ b/target-i386/cpu.c
619821
@@ -254,54 +254,65 @@ typedef struct FeatureWordInfo {
619821
     bool cpuid_needs_ecx; /* CPUID instruction uses ECX as input */
619821
     uint32_t cpuid_ecx;   /* Input ECX value for CPUID */
619821
     int cpuid_reg;        /* output register (R_* constant) */
619821
+    uint32_t tcg_features; /* Feature flags supported by TCG */
619821
 } FeatureWordInfo;
619821
 
619821
 static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
619821
     [FEAT_1_EDX] = {
619821
         .feat_names = feature_name,
619821
         .cpuid_eax = 1, .cpuid_reg = R_EDX,
619821
+        .tcg_features = TCG_FEATURES,
619821
     },
619821
     [FEAT_1_ECX] = {
619821
         .feat_names = ext_feature_name,
619821
         .cpuid_eax = 1, .cpuid_reg = R_ECX,
619821
+        .tcg_features = TCG_EXT_FEATURES,
619821
     },
619821
     [FEAT_8000_0001_EDX] = {
619821
         .feat_names = ext2_feature_name,
619821
         .cpuid_eax = 0x80000001, .cpuid_reg = R_EDX,
619821
+        .tcg_features = TCG_EXT2_FEATURES,
619821
     },
619821
     [FEAT_8000_0001_ECX] = {
619821
         .feat_names = ext3_feature_name,
619821
         .cpuid_eax = 0x80000001, .cpuid_reg = R_ECX,
619821
+        .tcg_features = TCG_EXT3_FEATURES,
619821
     },
619821
     [FEAT_C000_0001_EDX] = {
619821
         .feat_names = ext4_feature_name,
619821
         .cpuid_eax = 0xC0000001, .cpuid_reg = R_EDX,
619821
+        .tcg_features = TCG_EXT4_FEATURES,
619821
     },
619821
     [FEAT_KVM] = {
619821
         .feat_names = kvm_feature_name,
619821
         .cpuid_eax = KVM_CPUID_FEATURES, .cpuid_reg = R_EAX,
619821
+        .tcg_features = TCG_KVM_FEATURES,
619821
     },
619821
     [FEAT_SVM] = {
619821
         .feat_names = svm_feature_name,
619821
         .cpuid_eax = 0x8000000A, .cpuid_reg = R_EDX,
619821
+        .tcg_features = TCG_SVM_FEATURES,
619821
     },
619821
     [FEAT_7_0_EBX] = {
619821
         .feat_names = cpuid_7_0_ebx_feature_name,
619821
         .cpuid_eax = 7,
619821
         .cpuid_needs_ecx = true, .cpuid_ecx = 0,
619821
         .cpuid_reg = R_EBX,
619821
+        .tcg_features = TCG_7_0_EBX_FEATURES,
619821
     },
619821
     [FEAT_7_0_ECX] = {
619821
         .feat_names = cpuid_7_0_ecx_feature_name,
619821
         .cpuid_eax = 7,
619821
         .cpuid_needs_ecx = true, .cpuid_ecx = 0,
619821
         .cpuid_reg = R_ECX,
619821
+        .tcg_features = TCG_7_0_ECX_FEATURES,
619821
     },
619821
     [FEAT_7_0_EDX] = {
619821
         .feat_names = cpuid_7_0_edx_feature_name,
619821
         .cpuid_eax = 7,
619821
         .cpuid_needs_ecx = true, .cpuid_ecx = 0,
619821
         .cpuid_reg = R_EDX,
619821
+        .tcg_features = TCG_7_0_EDX_FEATURES,
619821
     },
619821
     [FEAT_XSAVE] = {
619821
         .feat_names = cpuid_xsave_feature_name,
619821
@@ -2617,17 +2628,10 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
619821
     }
619821
 
619821
     if (!kvm_enabled()) {
619821
-        env->features[FEAT_1_EDX] &= TCG_FEATURES;
619821
-        env->features[FEAT_1_ECX] &= TCG_EXT_FEATURES;
619821
-        env->features[FEAT_7_0_EBX] &= TCG_7_0_EBX_FEATURES;
619821
-        env->features[FEAT_8000_0001_EDX] &= TCG_EXT2_FEATURES;
619821
-        env->features[FEAT_8000_0001_ECX] &= TCG_EXT3_FEATURES;
619821
-        env->features[FEAT_SVM] &= TCG_SVM_FEATURES;
619821
-        env->features[FEAT_KVM] &= TCG_KVM_FEATURES;
619821
-        env->features[FEAT_C000_0001_EDX] &= TCG_EXT4_FEATURES;
619821
-        env->features[FEAT_XSAVE] = 0;
619821
-        env->features[FEAT_7_0_ECX] &= TCG_7_0_ECX_FEATURES;
619821
-        env->features[FEAT_7_0_EDX] &= TCG_7_0_EDX_FEATURES;
619821
+        FeatureWord w;
619821
+        for (w = 0; w < FEATURE_WORDS; w++) {
619821
+            env->features[w] &= feature_word_info[w].tcg_features;
619821
+        }
619821
     } else {
619821
         KVMState *s = kvm_state;
619821
         if ((cpu->check_cpuid || cpu->enforce_cpuid)
619821
-- 
619821
1.8.3.1
619821