cryptospore / rpms / qemu-kvm

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