Skip to contentSkip to conversation

target-i386: Check for host features before filter_features_for_kvm()

PATCH Applied Eduardo Habkost 3 participants 3 messages Apr 2, 2013 – Apr 5, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-i386: Check for host features before filter_features_for_kvm()

commit 5ec01c2e96910e1588d1a0de8609b9dda7618c7f broke "-cpu ..,enforce", as it has moved kvm_check_features_against_host() after the filter_features_for_kvm() call. filter_features_for_kvm() removes all features not supported by the host, so this effectively made kvm_check_features_against_host() impossible to fail.

This patch changes the call so we check for host feature support before filtering the feature bits.

---
 target-i386/cpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
target-i386/cpu.c +3 -3
index 9ee5b3d..8fe8bc7 100644
@@ -2132,14 +2132,14 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
         env->cpuid_ext3_features &= TCG_EXT3_FEATURES;
         env->cpuid_svm_features &= TCG_SVM_FEATURES;
     } else {
-#ifdef CONFIG_KVM
-        filter_features_for_kvm(cpu);
-#endif
         if (check_cpuid && kvm_check_features_against_host(cpu)
             && enforce_cpuid) {
             error_setg(errp, "Host's CPU doesn't support requested features");
             return;
         }
+#ifdef CONFIG_KVM
+        filter_features_for_kvm(cpu);
+#endif
     }
 
 #ifndef CONFIG_USER_ONLY
Signature · 1 line
1.8.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 27 lines · On Tue, 2 Apr 2013 17:48:12 -0300 Eduardo Habkost <[email protected]> wrote:

commit 5ec01c2e96910e1588d1a0de8609b9dda7618c7f broke "-cpu ..,enforce", as it has moved kvm_check_features_against_host() after the filter_features_for_kvm() call. filter_features_for_kvm() removes all features not supported by the host, so this effectively made kvm_check_features_against_host() impossible to fail.

This patch changes the call so we check for host feature support before filtering the feature bits.

---
 target-i386/cpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
target-i386/cpu.c +0 -3
index 9ee5b3d..8fe8bc7 100644
@@ -2132,14 +2132,14 @@ static void x86_cpu_realizefn(DeviceState *dev,
 Error **errp) env->cpuid_ext3_features &= TCG_EXT3_FEATURES;
         env->cpuid_svm_features &= TCG_SVM_FEATURES;
     } else {
-#ifdef CONFIG_KVM
-        filter_features_for_kvm(cpu);
-#endif
         if (check_cpuid && kvm_check_features_against_host(cpu)

target-i386/cpu.c static void x86_cpu_realizefn(DeviceState *dev, · line 2145

Quoted 10 lines
target-i386/cpu.c +3 -0
             && enforce_cpuid) {
             error_setg(errp, "Host's CPU doesn't support requested
 features"); return;
         }
+#ifdef CONFIG_KVM
+        filter_features_for_kvm(cpu);
+#endif
     }
 
 #ifndef CONFIG_USER_ONLY