Skip to contentSkip to conversation

Correct the max cpuid level for each x86 cpu model

PATCH New Dan Kenigsberg 1 participant 1 message Dec 23, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Correct the max cpuid level for each x86 cpu model

Hi,

This little patch corrects the max cpuid level that is exposed to the guest for each of the x86 cpu models. It allows cpuid levels other than 2.

Dan.

target-i386/helper2.c +8 -1
index b9b3093..dee53d6 100644
@@ -119,6 +119,7 @@ CPUX86State *cpu_x86_init(const char *cpu_model)
 
 typedef struct x86_def_t {
     const char *name;
+    uint32_t level;
     uint32_t vendor1, vendor2, vendor3;
     char model_id[48];
     int family;
@@ -136,6 +137,7 @@ static x86_def_t x86_defs[] = {
 #ifdef TARGET_X86_64
     {
         .name = "qemu64",
+        .level = 2,
         .vendor1 = 0x68747541, /* "Auth" */
         .vendor2 = 0x69746e65, /* "enti" */
         .vendor3 = 0x444d4163, /* "cAMD" */
@@ -156,6 +158,7 @@ static x86_def_t x86_defs[] = {
 #endif
     {
         .name = "qemu32",
+        .level = 2,
         .family = 6,
         .model = 3,
         .stepping = 3,
@@ -165,6 +168,7 @@ static x86_def_t x86_defs[] = {
     },
     {
         .name = "486",
+        .level = 0,
         .family = 4,
         .model = 0,
         .stepping = 0,
@@ -173,6 +177,7 @@ static x86_def_t x86_defs[] = {
     },
     {
         .name = "pentium",
+        .level = 1,
         .family = 5,
         .model = 4,
         .stepping = 3,
@@ -181,6 +186,7 @@ static x86_def_t x86_defs[] = {
     },
     {
         .name = "pentium2",
+        .level = 2,
         .family = 6,
         .model = 5,
         .stepping = 2,
@@ -189,6 +195,7 @@ static x86_def_t x86_defs[] = {
     },
     {
         .name = "pentium3",
+        .level = 2,
         .family = 6,
         .model = 7,
         .stepping = 3,
@@ -321,7 +328,7 @@ static int cpu_x86_register (CPUX86State *env, const char *cpu_model)
         env->cpuid_vendor2 = 0x49656e69; /* "ineI" */
         env->cpuid_vendor3 = 0x6c65746e; /* "ntel" */
     }
-    env->cpuid_level = 2;
+    env->cpuid_level = def->level;
     env->cpuid_version = (def->family << 8) | (def->model << 4) | def->stepping;
     env->cpuid_features = def->features;
     env->pat = 0x0007040600070406ULL;