Patchwork [3/5] target-i386: postpone cpuid_level update to realize time

login
register
mail settings
Submitter Eduardo Habkost
Date Dec. 3, 2012, 5:27 p.m.
Message ID <1354555681-15343-4-git-send-email-ehabkost@redhat.com>
Download mbox | patch
Permalink /patch/203401/
State New
Headers show

Comments

Eduardo Habkost - Dec. 3, 2012, 5:27 p.m.
From: Igor Mammedov <imammedo@redhat.com>

delay capping cpuid_level to 7 to realize time so property setters
for cpuid_7_0_ebx_features and "level" could be used in any order/time
between x86_cpu_initfn() and x86_cpu_realize().

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 target-i386/cpu.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Patch

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 569acac..ee03652 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1380,9 +1380,6 @@  static int cpu_x86_parse_featurestr(x86_def_t *x86_cpu_def, char *features)
         if (kvm_check_features_against_host(x86_cpu_def) && enforce_cpuid)
             goto error;
     }
-    if (x86_cpu_def->cpuid_7_0_ebx_features && x86_cpu_def->level < 7) {
-        x86_cpu_def->level = 7;
-    }
     return 0;
 
 error:
@@ -2073,6 +2070,11 @@  static void x86_cpu_apic_init(X86CPU *cpu, Error **errp)
 void x86_cpu_realize(Object *obj, Error **errp)
 {
     X86CPU *cpu = X86_CPU(obj);
+    CPUX86State *env = &cpu->env;
+
+    if (env->cpuid_7_0_ebx_features && env->cpuid_level < 7) {
+        env->cpuid_level = 7;
+    }
 
 #ifndef CONFIG_USER_ONLY
     qemu_register_reset(x86_cpu_machine_reset_cb, cpu);