qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC 2/2 v2] target-i386: Add "x-allow-emulation" X86CPU pr


From: Eduardo Habkost
Subject: [Qemu-devel] [RFC 2/2 v2] target-i386: Add "x-allow-emulation" X86CPU property
Date: Thu, 5 Jun 2014 16:57:46 -0300
User-agent: Mutt/1.5.21 (2010-09-15)

The new option will allow slow emulated features (the ones returned by
GET_EMULATED_CPUID) to be enabled. We don't want to allow them to be
enabled by accident, so they will be enabled only if emulation is
explicitly allowed by the user.

Use "x-" prefix on the property name, to document that it is not
supposed to be supported forever, and intended for developers who want
to test GET_EMULATED_CPUID.

Signed-off-by: Eduardo Habkost <address@hidden>
---
Changes v1 -> v2:
 * Rename property to x-allow-emulation
---
 target-i386/cpu-qom.h |  3 +++
 target-i386/cpu.c     | 18 ++++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h
index 385b81f..831f7bf 100644
--- a/target-i386/cpu-qom.h
+++ b/target-i386/cpu-qom.h
@@ -74,6 +74,8 @@ typedef struct X86CPUClass {
  * @migratable: If set, only migratable flags will be accepted when "enforce"
  * mode is used, and only migratable flags will be included in the "host"
  * CPU model.
+ * @allow_emulation: If set, accelerator-specific code will allow emulated
+ * features to be enabled.
  *
  * An x86 CPU.
  */
@@ -91,6 +93,7 @@ typedef struct X86CPU {
     bool check_cpuid;
     bool enforce_cpuid;
     bool migratable;
+    bool allow_emulation;
 
     /* if true the CPUID code directly forward host cache leaves to the guest 
*/
     bool cache_info_passthrough;
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 1395473..cf6ab59 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1280,7 +1280,8 @@ static void host_x86_cpu_class_init(ObjectClass *oc, void 
*data)
 }
 
 static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w,
-                                                   bool migratable_only);
+                                                   bool migratable_only,
+                                                   bool allow_emulation);
 
 static void host_x86_cpu_initfn(Object *obj)
 {
@@ -1297,7 +1298,8 @@ static void host_x86_cpu_initfn(Object *obj)
 
     for (w = 0; w < FEATURE_WORDS; w++) {
         env->features[w] =
-            x86_cpu_get_supported_feature_word(w, cpu->migratable);
+            x86_cpu_get_supported_feature_word(w, cpu->migratable,
+                                                  cpu->allow_emulation);
     }
     object_property_set_bool(OBJECT(cpu), true, "pmu", &error_abort);
 }
@@ -1887,7 +1889,8 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error 
**errp)
 }
 
 static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w,
-                                                   bool migratable_only)
+                                                   bool migratable_only,
+                                                   bool allow_emulation)
 {
     FeatureWordInfo *wi = &feature_word_info[w];
     uint32_t r;
@@ -1896,6 +1899,11 @@ static uint32_t 
x86_cpu_get_supported_feature_word(FeatureWord w,
         r = kvm_arch_get_supported_cpuid(kvm_state, wi->cpuid_eax,
                                                     wi->cpuid_ecx,
                                                     wi->cpuid_reg);
+        if (allow_emulation) {
+            r |= kvm_arch_get_emulated_cpuid(kvm_state,  wi->cpuid_eax,
+                                                         wi->cpuid_ecx,
+                                                         wi->cpuid_reg);
+        }
     } else if (tcg_enabled()) {
         r = wi->tcg_features;
     } else {
@@ -1920,7 +1928,8 @@ static int x86_cpu_filter_features(X86CPU *cpu)
 
     for (w = 0; w < FEATURE_WORDS; w++) {
         uint32_t host_feat =
-            x86_cpu_get_supported_feature_word(w, cpu->migratable);
+            x86_cpu_get_supported_feature_word(w, cpu->migratable,
+                                                  cpu->allow_emulation);
         uint32_t requested_features = env->features[w];
         env->features[w] &= host_feat;
         cpu->filtered_features[w] = requested_features & ~env->features[w];
@@ -2854,6 +2863,7 @@ static Property x86_cpu_properties[] = {
     DEFINE_PROP_BOOL("hv-time", X86CPU, hyperv_time, false),
     DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, false),
     DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false),
+    DEFINE_PROP_BOOL("x-allow-emulation", X86CPU, allow_emulation, true),
     DEFINE_PROP_END_OF_LIST()
 };
 
-- 
1.9.0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]