This will make it easier to write unit tests for the feature
initialization logic.

Signed-off-by: Eduardo Habkost <ehabk...@redhat.com>
---
 target-i386/cpu.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index e9df33e..b6b3c4f 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -464,6 +464,11 @@ static uint32_t kvm_default_unset_features[FEATURE_WORDS] 
= {
     [FEAT_8000_0001_ECX] = CPUID_EXT3_SVM,
 };
 
+/* Features that are added by default to all CPU models in any accelerator: */
+FeatureWordArray default_features_all = {
+    [FEAT_1_ECX] = CPUID_EXT_HYPERVISOR,
+};
+
 void x86_cpu_compat_kvm_no_autoenable(FeatureWord w, uint32_t features)
 {
     kvm_default_features[w] &= ~features;
@@ -2005,15 +2010,14 @@ static void x86_cpu_load_def(X86CPU *cpu, 
X86CPUDefinition *def, Error **errp)
     }
 
     /* Special cases not set in the X86CPUDefinition structs: */
-    if (kvm_enabled()) {
-        FeatureWord w;
-        for (w = 0; w < FEATURE_WORDS; w++) {
+    for (w = 0; w < FEATURE_WORDS; w++) {
+        if (kvm_enabled()) {
             env->features[w] |= kvm_default_features[w];
             env->features[w] &= ~kvm_default_unset_features[w];
         }
+        env->features[w] |= default_features_all[w];
     }
 
-    env->features[FEAT_1_ECX] |= CPUID_EXT_HYPERVISOR;
 
     /* sysenter isn't supported in compatibility mode on AMD,
      * syscall isn't supported in compatibility mode on Intel.
-- 
1.9.3


Reply via email to