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