qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target-i386: add a list of enforceable CPU models to the help output
@ 2015-08-24  9:17 Peter Lieven
  2015-08-24 10:28 ` [Qemu-devel] CPU Model kvm64 and Windows2012R2 Peter Lieven
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Peter Lieven @ 2015-08-24  9:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Peter Lieven, afaerber, ehabkost, rth

this patch adds a probe that lists all enforceable and migrateable
CPU models to the -cpu help output. The idea is to know a priory
which CPU modules can be exposed to the user without loosing any
feature flags.

Signed-off-by: Peter Lieven <pl@kamp.de>
---
 target-i386/cpu.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index cfb8aa7..3a56d3f 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1961,6 +1961,45 @@ static void listflags(FILE *f, fprintf_function print, const char **featureset)
     }
 }
 
+/*
+ * Check if the CPU Definition is enforcable on the current host CPU
+ * and contains no unmigratable flags.
+ *
+ * Returns: true if the CPU can be enforced and migrated.
+ */
+static bool x86_cpu_enforce_and_migratable(X86CPUDefinition *def)
+{
+    int i;
+    for (i = 0; i < ARRAY_SIZE(feature_word_info); i++) {
+        FeatureWordInfo *fw = &feature_word_info[i];
+        uint32_t eax, ebx, ecx, edx, host;
+        host_cpuid(fw->cpuid_eax, 0, &eax, &ebx, &ecx, &edx);
+        switch (fw->cpuid_reg) {
+        case R_EAX:
+            host = eax;
+            break;
+        case R_EBX:
+            host = ebx;
+            break;
+        case R_ECX:
+            host = ecx;
+            break;
+        case R_EDX:
+            host = edx;
+            break;
+        default:
+            return false;
+        }
+        if (def->features[i] & ~host) {
+            return false;
+        }
+        if (def->features[i] & fw->unmigratable_flags) {
+            return false;
+        }
+    }
+    return true;
+}
+
 /* generate CPU information. */
 void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf)
 {
@@ -1987,6 +2026,16 @@ void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf)
         listflags(f, cpu_fprintf, fw->feat_names);
         (*cpu_fprintf)(f, "\n");
     }
+
+    (*cpu_fprintf)(f, "\nEnforceable and migratable x86 CPU models in KVM mode:\n");
+    (*cpu_fprintf)(f, " ");
+    for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); i++) {
+        def = &builtin_x86_defs[i];
+        if (x86_cpu_enforce_and_migratable(def)) {
+            (*cpu_fprintf)(f, " %s", def->name);
+        }
+    }
+    (*cpu_fprintf)(f, "\n");
 }
 
 CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-08-26 19:19 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-24  9:17 [Qemu-devel] [PATCH] target-i386: add a list of enforceable CPU models to the help output Peter Lieven
2015-08-24 10:28 ` [Qemu-devel] CPU Model kvm64 and Windows2012R2 Peter Lieven
2015-08-24 11:50   ` Paolo Bonzini
2015-08-24 11:59     ` Peter Lieven
2015-08-24 11:51   ` Paolo Bonzini
2015-08-24 15:46 ` [Qemu-devel] [PATCH] target-i386: add a list of enforceable CPU models to the help output Eric Blake
2015-08-24 19:36   ` Peter Lieven
2015-08-26 18:38     ` Eduardo Habkost
2015-08-26 18:46       ` Peter Lieven
2015-08-26 19:00         ` Eduardo Habkost
2015-08-26 19:19           ` Peter Lieven
2015-08-24 20:22 ` Andreas Färber
2015-08-24 21:35   ` Peter Lieven
2015-08-26 15:54 ` Eduardo Habkost
2015-08-26 18:38   ` Peter Lieven
2015-08-26 19:12     ` Eduardo Habkost

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).