b38b0f
From 61aa52146679fb00f976bc1eb7884f1ddcf7342c Mon Sep 17 00:00:00 2001
b38b0f
From: Eduardo Habkost <ehabkost@redhat.com>
b38b0f
Date: Thu, 29 Aug 2019 20:55:31 +0100
b38b0f
Subject: [PATCH 04/10] i386: x86_cpu_list_feature_names() function
b38b0f
b38b0f
RH-Author: Eduardo Habkost <ehabkost@redhat.com>
b38b0f
Message-id: <20190829205532.8302-2-ehabkost@redhat.com>
b38b0f
Patchwork-id: 90200
b38b0f
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH 1/2] i386: x86_cpu_list_feature_names() function
b38b0f
Bugzilla: 1747185
b38b0f
RH-Acked-by: Thomas Huth <thuth@redhat.com>
b38b0f
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
b38b0f
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
b38b0f
b38b0f
Extract feature name listing code from
b38b0f
x86_cpu_class_check_missing_features().  It will be reused to
b38b0f
return information about CPU filtered features at runtime.
b38b0f
b38b0f
Message-Id: <20190422234742.15780-2-ehabkost@redhat.com>
b38b0f
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
b38b0f
(cherry picked from commit 5a853fc57a0860da4a55d1448a77845f97e7a9be)
b38b0f
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
b38b0f
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
b38b0f
---
b38b0f
 target/i386/cpu.c | 35 ++++++++++++++++++++++-------------
b38b0f
 1 file changed, 22 insertions(+), 13 deletions(-)
b38b0f
b38b0f
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
b38b0f
index f71b044..934f11b 100644
b38b0f
--- a/target/i386/cpu.c
b38b0f
+++ b/target/i386/cpu.c
b38b0f
@@ -3559,6 +3559,27 @@ static void x86_cpu_parse_featurestr(const char *typename, char *features,
b38b0f
 static void x86_cpu_expand_features(X86CPU *cpu, Error **errp);
b38b0f
 static int x86_cpu_filter_features(X86CPU *cpu);
b38b0f
 
b38b0f
+/* Build a list with the name of all features on a feature word array */
b38b0f
+static void x86_cpu_list_feature_names(FeatureWordArray features,
b38b0f
+                                       strList **feat_names)
b38b0f
+{
b38b0f
+    FeatureWord w;
b38b0f
+    strList **next = feat_names;
b38b0f
+
b38b0f
+    for (w = 0; w < FEATURE_WORDS; w++) {
b38b0f
+        uint32_t filtered = features[w];
b38b0f
+        int i;
b38b0f
+        for (i = 0; i < 32; i++) {
b38b0f
+            if (filtered & (1UL << i)) {
b38b0f
+                strList *new = g_new0(strList, 1);
b38b0f
+                new->value = g_strdup(x86_cpu_feature_name(w, i));
b38b0f
+                *next = new;
b38b0f
+                next = &new->next;
b38b0f
+            }
b38b0f
+        }
b38b0f
+    }
b38b0f
+}
b38b0f
+
b38b0f
 /* Check for missing features that may prevent the CPU class from
b38b0f
  * running using the current machine and accelerator.
b38b0f
  */
b38b0f
@@ -3566,7 +3587,6 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,
b38b0f
                                                  strList **missing_feats)
b38b0f
 {
b38b0f
     X86CPU *xc;
b38b0f
-    FeatureWord w;
b38b0f
     Error *err = NULL;
b38b0f
     strList **next = missing_feats;
b38b0f
 
b38b0f
@@ -3593,18 +3613,7 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,
b38b0f
 
b38b0f
     x86_cpu_filter_features(xc);
b38b0f
 
b38b0f
-    for (w = 0; w < FEATURE_WORDS; w++) {
b38b0f
-        uint32_t filtered = xc->filtered_features[w];
b38b0f
-        int i;
b38b0f
-        for (i = 0; i < 32; i++) {
b38b0f
-            if (filtered & (1UL << i)) {
b38b0f
-                strList *new = g_new0(strList, 1);
b38b0f
-                new->value = g_strdup(x86_cpu_feature_name(w, i));
b38b0f
-                *next = new;
b38b0f
-                next = &new->next;
b38b0f
-            }
b38b0f
-        }
b38b0f
-    }
b38b0f
+    x86_cpu_list_feature_names(xc->filtered_features, next);
b38b0f
 
b38b0f
     object_unref(OBJECT(xc));
b38b0f
 }
b38b0f
-- 
b38b0f
1.8.3.1
b38b0f