]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commitdiff
target-i386: Simplify reporting of unavailable features
authorEduardo Habkost <ehabkost@redhat.com>
Wed, 30 Apr 2014 16:48:29 +0000 (13:48 -0300)
committerAndreas Färber <afaerber@suse.de>
Wed, 25 Jun 2014 16:04:15 +0000 (18:04 +0200)
Instead of checking and calling unavailable_host_feature() once for each
bit, simply call the function (now renamed to
report_unavailable_features()) once for each feature word.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
[AF: Drop unused return value]
Signed-off-by: Andreas Färber <afaerber@suse.de>
target-i386/cpu.c

index 23ce915f634d4f84e65f3d7abea99727eebff871..e848f9cf0c6bdbbc48774c3b26ecba97d71fef54 100644 (file)
@@ -1234,11 +1234,11 @@ static const TypeInfo host_x86_cpu_type_info = {
 
 #endif
 
-static int unavailable_host_feature(FeatureWordInfo *f, uint32_t mask)
+static void report_unavailable_features(FeatureWordInfo *f, uint32_t mask)
 {
     int i;
 
-    for (i = 0; i < 32; ++i)
+    for (i = 0; i < 32; ++i) {
         if (1 << i & mask) {
             const char *reg = get_register_name_32(f->cpuid_reg);
             assert(reg);
@@ -1247,9 +1247,8 @@ static int unavailable_host_feature(FeatureWordInfo *f, uint32_t mask)
                 f->cpuid_eax, reg,
                 f->feat_names[i] ? "." : "",
                 f->feat_names[i] ? f->feat_names[i] : "", i);
-            break;
         }
-    return 0;
+    }
 }
 
 /* Check if all requested cpu flags are making their way to the guest
@@ -1272,12 +1271,10 @@ static int kvm_check_features_against_host(KVMState *s, X86CPU *cpu)
         uint32_t host_feat = kvm_arch_get_supported_cpuid(s, wi->cpuid_eax,
                                                              wi->cpuid_ecx,
                                                              wi->cpuid_reg);
-        uint32_t mask;
-        for (mask = 1; mask; mask <<= 1) {
-            if (guest_feat & mask && !(host_feat & mask)) {
-                unavailable_host_feature(wi, mask);
-                rv = 1;
-            }
+        uint32_t unavailable_features = guest_feat & ~host_feat;
+        if (unavailable_features) {
+            report_unavailable_features(wi, unavailable_features);
+            rv = 1;
         }
     }
     return rv;