Skip to contentSkip to conversation

x86 CPU model fixes

PATCH New Paolo Bonzini 2 participants 13 messages Dec 5, 2014

lore
Share & tools
lore
#0 lore raw

cover x86 CPU model fixes

Most processors were lacking the VME flags. Haswell and Broadwell were lacking two more. And Ivy Bridge was missing altogether.

Family/model/stepping for a low-end Xeon E3 v2 found on the SETI@Home CPU list (http://setiathome.berkeley.edu/cpu_list.php), they also match the Ivy Bridge Core i7 processor on which I tested the patch. The following bare-metal features are missing in the guest:

dts acpi ss ht tm pbe arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf dtes64 monitor ds_cpl vmx smx est tm2 xtpr pdcm ida arat epb pln pts dtherm tpr_shadow vnmi flexpriority ept vpid

... the absence of none of which is surprising.

Paolo

Paolo Bonzini (4):
pc: add 2.3 machine types
target-i386: add VME to all CPUs
target-i386: add f16c and rdrand to Haswell and Broadwell
target-i386: add Ivy Bridge CPU model

 hw/i386/pc_piix.c | 47 +++++++++++++++++++++++++++++++++++---
 hw/i386/pc_q35.c  | 44 ++++++++++++++++++++++++++++++++---
 target-i386/cpu.c | 68 ++++++++++++++++++++++++++++++++++++++++---------------
 3 files changed, 135 insertions(+), 24 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/4 pc: add 2.3 machine types

The next patch will differentiate them.

---
 hw/i386/pc_piix.c | 28 +++++++++++++++++++++++++---
 hw/i386/pc_q35.c  | 25 ++++++++++++++++++++++---
 2 files changed, 47 insertions(+), 6 deletions(-)
hw/i386/pc_piix.c +25 -3
index 741dffd..5ad23d0 100644
@@ -303,6 +303,10 @@ static void pc_init_pci(MachineState *machine)
     pc_init1(machine, 1, 1);
 }
 
+static void pc_compat_2_2(MachineState *machine)
+{
+}
+
 static void pc_compat_2_1(MachineState *machine)
 {
     PCMachineState *pcms = PC_MACHINE(machine);
@@ -380,6 +384,12 @@ static void pc_compat_1_2(MachineState *machine)
     x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, KVM_FEATURE_PV_EOI);
 }
 
+static void pc_init_pci_2_2(MachineState *machine)
+{
+    pc_compat_2_2(machine);
+    pc_init_pci(machine);
+}
+
 static void pc_init_pci_2_1(MachineState *machine)
 {
     pc_compat_2_1(machine);
@@ -473,6 +483,19 @@ static void pc_xen_hvm_init(MachineState *machine)
     .desc = "Standard PC (i440FX + PIIX, 1996)", \
     .hot_add_cpu = pc_hot_add_cpu
 
+#define PC_I440FX_2_3_MACHINE_OPTIONS                           \
+    PC_I440FX_MACHINE_OPTIONS,                                  \
+    .default_machine_opts = "firmware=bios-256k.bin",           \
+    .default_display = "std"
+
+static QEMUMachine pc_i440fx_machine_v2_3 = {
+    PC_I440FX_2_3_MACHINE_OPTIONS,
+    .name = "pc-i440fx-2.3",
+    .alias = "pc",
+    .init = pc_init_pci,
+    .is_default = 1,
+};
+
 #define PC_I440FX_2_2_MACHINE_OPTIONS                           \
     PC_I440FX_MACHINE_OPTIONS,                                  \
     .default_machine_opts = "firmware=bios-256k.bin",           \
@@ -481,9 +504,7 @@ static void pc_xen_hvm_init(MachineState *machine)
 static QEMUMachine pc_i440fx_machine_v2_2 = {
     PC_I440FX_2_2_MACHINE_OPTIONS,
     .name = "pc-i440fx-2.2",
-    .alias = "pc",
-    .init = pc_init_pci,
-    .is_default = 1,
+    .init = pc_init_pci_2_2,
 };
 
 #define PC_I440FX_2_1_MACHINE_OPTIONS                           \
@@ -923,6 +944,7 @@ static QEMUMachine xenfv_machine = {
 
 static void pc_machine_init(void)
 {
+    qemu_register_pc_machine(&pc_i440fx_machine_v2_3);
     qemu_register_pc_machine(&pc_i440fx_machine_v2_2);
     qemu_register_pc_machine(&pc_i440fx_machine_v2_1);
     qemu_register_pc_machine(&pc_i440fx_machine_v2_0);
hw/i386/pc_q35.c +22 -3
index e9ba1a2..1ff3828 100644
@@ -282,6 +282,10 @@ static void pc_q35_init(MachineState *machine)
     }
 }
 
+static void pc_compat_2_2(MachineState *machine)
+{
+}
+
 static void pc_compat_2_1(MachineState *machine)
 {
     PCMachineState *pcms = PC_MACHINE(machine);
@@ -329,6 +333,12 @@ static void pc_compat_1_4(MachineState *machine)
     x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
 }
 
+static void pc_q35_init_2_2(MachineState *machine)
+{
+    pc_compat_2_2(machine);
+    pc_q35_init(machine);
+}
+
 static void pc_q35_init_2_1(MachineState *machine)
 {
     pc_compat_2_1(machine);
@@ -372,16 +382,24 @@ static void pc_q35_init_1_4(MachineState *machine)
     .hot_add_cpu = pc_hot_add_cpu, \
     .units_per_default_bus = 1
 
-#define PC_Q35_2_2_MACHINE_OPTIONS                      \
+#define PC_Q35_2_3_MACHINE_OPTIONS                      \
     PC_Q35_MACHINE_OPTIONS,                             \
     .default_machine_opts = "firmware=bios-256k.bin",   \
     .default_display = "std"
 
+static QEMUMachine pc_q35_machine_v2_3 = {
+    PC_Q35_2_3_MACHINE_OPTIONS,
+    .name = "pc-q35-2.3",
+    .alias = "q35",
+    .init = pc_q35_init,
+};
+
+#define PC_Q35_2_2_MACHINE_OPTIONS PC_Q35_2_3_MACHINE_OPTIONS
+
 static QEMUMachine pc_q35_machine_v2_2 = {
     PC_Q35_2_2_MACHINE_OPTIONS,
     .name = "pc-q35-2.2",
-    .alias = "q35",
-    .init = pc_q35_init,
+    .init = pc_q35_init_2_2,
 };
 
 #define PC_Q35_2_1_MACHINE_OPTIONS                      \
@@ -460,6 +478,7 @@ static QEMUMachine pc_q35_machine_v1_4 = {
 
 static void pc_q35_machine_init(void)
 {
+    qemu_register_pc_machine(&pc_q35_machine_v2_3);
     qemu_register_pc_machine(&pc_q35_machine_v2_2);
     qemu_register_pc_machine(&pc_q35_machine_v2_1);
     qemu_register_pc_machine(&pc_q35_machine_v2_0);
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [Qemu-devel] [PATCH 1/4] pc: add 2.3 machine types

Quoted 13 lines · Paolo Bonzini

The next patch will differentiate them.

---
 hw/i386/pc_piix.c | 28 +++++++++++++++++++++++++---
 hw/i386/pc_q35.c  | 25 ++++++++++++++++++++++---
 2 files changed, 47 insertions(+), 6 deletions(-)
hw/i386/pc_piix.c +0 -0
index 741dffd..5ad23d0 100644

hw/i386/pc_piix.c static void pc_init_pci(MachineState *machine) · line 312

Quoted 10 lines
hw/i386/pc_piix.c +4 -0
@@ -303,6 +303,10 @@ static void pc_init_pci(MachineState *machine)
     pc_init1(machine, 1, 1);
 }
 
+static void pc_compat_2_2(MachineState *machine)
+{
+}
+
 static void pc_compat_2_1(MachineState *machine)
 {
     PCMachineState *pcms = PC_MACHINE(machine);

You need to make pc_compat_2_1() call pc_compat_2_2(). The same on pc_q35.c.

Quoted 22 lines
hw/i386/pc_piix.c +11 -0
@@ -380,6 +384,12 @@ static void pc_compat_1_2(MachineState *machine)
     x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, KVM_FEATURE_PV_EOI);
 }
 
+static void pc_init_pci_2_2(MachineState *machine)
+{
+    pc_compat_2_2(machine);
+    pc_init_pci(machine);
+}
+
 static void pc_init_pci_2_1(MachineState *machine)
 {
     pc_compat_2_1(machine);
@@ -473,6 +483,19 @@ static void pc_xen_hvm_init(MachineState *machine)
     .desc = "Standard PC (i440FX + PIIX, 1996)", \
     .hot_add_cpu = pc_hot_add_cpu
 
+#define PC_I440FX_2_3_MACHINE_OPTIONS                           \
+    PC_I440FX_MACHINE_OPTIONS,                                  \
+    .default_machine_opts = "firmware=bios-256k.bin",           \
+    .default_display = "std"
+

hw/i386/pc_piix.c static void pc_xen_hvm_init(MachineState *machine) · line 500

Quoted 10 lines
hw/i386/pc_piix.c +8 -0
+static QEMUMachine pc_i440fx_machine_v2_3 = {
+    PC_I440FX_2_3_MACHINE_OPTIONS,
+    .name = "pc-i440fx-2.3",
+    .alias = "pc",
+    .init = pc_init_pci,
+    .is_default = 1,
+};
+
 #define PC_I440FX_2_2_MACHINE_OPTIONS                           \
     PC_I440FX_MACHINE_OPTIONS,                                  \

I was going to suggest making PC_I440FX_2_2_MACHINE_OPTIONS reuse PC_I440FX_2_3_MACHINE_OPTIONS, but I think we have enough macro reuse mess here, and this is safer and simpler?

Quoted 11 lines
hw/i386/pc_piix.c +1 -3
     .default_machine_opts = "firmware=bios-256k.bin",           \
@@ -481,9 +504,7 @@ static void pc_xen_hvm_init(MachineState *machine)
 static QEMUMachine pc_i440fx_machine_v2_2 = {
     PC_I440FX_2_2_MACHINE_OPTIONS,
     .name = "pc-i440fx-2.2",
-    .alias = "pc",
-    .init = pc_init_pci,
-    .is_default = 1,
+    .init = pc_init_pci_2_2,
 };
 

[...]

Signature · 1 line
Eduardo
#3 lore raw

Re: [Qemu-devel] [PATCH 1/4] pc: add 2.3 machine types

Quoted 5 lines · Eduardo Habkost
Quoted 2 lines
Quoted 2 lines
 #define PC_I440FX_2_2_MACHINE_OPTIONS                           \
     PC_I440FX_MACHINE_OPTIONS,                                  \

I was going to suggest making PC_I440FX_2_2_MACHINE_OPTIONS reuse PC_I440FX_2_3_MACHINE_OPTIONS, but I think we have enough macro reuse mess here, and this is safer and simpler?

Yeah, this is following for default_display what the file was already doing for default_machine_opts.

Paolo

#4 lore raw

PATCH 2/4 target-i386: add VME to all CPUs

In reply to Paolo Bonzini

vm86 mode extensions date back to the 486. All models should have them.

---
 hw/i386/pc_piix.c | 15 +++++++++++++++
 hw/i386/pc_q35.c  | 15 +++++++++++++++
 target-i386/cpu.c | 30 +++++++++++++++---------------
 3 files changed, 45 insertions(+), 15 deletions(-)
hw/i386/pc_piix.c +15 -0
index 5ad23d0..3f1524e 100644
@@ -305,6 +305,21 @@ static void pc_init_pci(MachineState *machine)
 
 static void pc_compat_2_2(MachineState *machine)
 {
+    x86_cpu_compat_set_features("kvm64", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("kvm32", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("coreduo", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Conroe", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Penryn", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Nehalem", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("SandyBridge", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Opteron_G1", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Opteron_G2", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Opteron_G3", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Opteron_G4", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Opteron_G5", FEAT_1_ECX, CPUID_EXT_VME, 0);
 }
 
 static void pc_compat_2_1(MachineState *machine)
hw/i386/pc_q35.c +15 -0
index 1ff3828..bec234a 100644
@@ -284,6 +284,21 @@ static void pc_q35_init(MachineState *machine)
 
 static void pc_compat_2_2(MachineState *machine)
 {
+    x86_cpu_compat_set_features("kvm64", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("kvm32", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("coreduo", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Conroe", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Penryn", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Nehalem", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("SandyBridge", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Opteron_G1", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Opteron_G2", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Opteron_G3", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Opteron_G4", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Opteron_G5", FEAT_1_ECX, CPUID_EXT_VME, 0);
 }
 
 static void pc_compat_2_1(MachineState *machine)
target-i386/cpu.c +15 -15
index ef7d71c..136c457 100644
@@ -760,9 +760,9 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .family = 15,
         .model = 6,
         .stepping = 1,
-        /* Missing: CPUID_VME, CPUID_HT */
+        /* Missing: CPUID_HT */
         .features[FEAT_1_EDX] =
-            PPRO_FEATURES |
+            PPRO_FEATURES | CPUID_VME |
             CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA |
             CPUID_PSE36,
         /* Missing: CPUID_EXT_POPCNT, CPUID_EXT_MONITOR */
@@ -802,7 +802,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .model = 6,
         .stepping = 1,
         .features[FEAT_1_EDX] =
-            PPRO_FEATURES |
+            PPRO_FEATURES | CPUID_VME |
             CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA | CPUID_PSE36,
         .features[FEAT_1_ECX] =
             CPUID_EXT_SSE3,
@@ -928,7 +928,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .model = 15,
         .stepping = 3,
         .features[FEAT_1_EDX] =
-            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
+            CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
             CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
             CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
             CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
@@ -950,7 +950,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .model = 23,
         .stepping = 3,
         .features[FEAT_1_EDX] =
-            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
+            CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
             CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
             CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
             CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
@@ -973,7 +973,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .model = 26,
         .stepping = 3,
         .features[FEAT_1_EDX] =
-            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
+            CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
             CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
             CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
             CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
@@ -996,7 +996,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .model = 44,
         .stepping = 1,
         .features[FEAT_1_EDX] =
-            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
+            CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
             CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
             CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
             CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
@@ -1020,7 +1020,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .model = 42,
         .stepping = 1,
         .features[FEAT_1_EDX] =
-            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
+            CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
             CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
             CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
             CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
@@ -1049,7 +1049,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .model = 60,
         .stepping = 1,
         .features[FEAT_1_EDX] =
-            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
+            CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
             CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
             CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
             CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
@@ -1084,7 +1084,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .model = 61,
         .stepping = 2,
         .features[FEAT_1_EDX] =
-            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
+            CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
             CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
             CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
             CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
@@ -1120,7 +1120,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .model = 6,
         .stepping = 1,
         .features[FEAT_1_EDX] =
-            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
+            CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
             CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
             CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
             CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
@@ -1145,7 +1145,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .model = 6,
         .stepping = 1,
         .features[FEAT_1_EDX] =
-            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
+            CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
             CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
             CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
             CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
@@ -1173,7 +1173,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .model = 6,
         .stepping = 1,
         .features[FEAT_1_EDX] =
-            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
+            CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
             CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
             CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
             CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
@@ -1203,7 +1203,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .model = 1,
         .stepping = 2,
         .features[FEAT_1_EDX] =
-            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
+            CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
             CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
             CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
             CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
@@ -1238,7 +1238,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .model = 2,
         .stepping = 0,
         .features[FEAT_1_EDX] =
-            CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
+            CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
             CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
             CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
             CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
Signature · 1 line
1.8.3.1
#5 lore raw

Re: [Qemu-devel] [PATCH 2/4] target-i386: add VME to all CPUs

Quoted 4 lines · Paolo Bonzini

vm86 mode extensions date back to the 486. All models should have them.

TCG doesn't support VME (that's probably why we didn't have it set on most CPU models), and I would like to eventually make check/enforce mode work on TCG as well.

I was going to suggest adding it to kvm_default_features instead, but as we have existing models that have CPUID_VME already, let's be consistent and add it to all of them (and deal with TCG check/enforce mode later, if necessary).

Quoted 11 lines
---
 hw/i386/pc_piix.c | 15 +++++++++++++++
 hw/i386/pc_q35.c  | 15 +++++++++++++++
 target-i386/cpu.c | 30 +++++++++++++++---------------
 3 files changed, 45 insertions(+), 15 deletions(-)
hw/i386/pc_piix.c +0 -0
index 5ad23d0..3f1524e 100644

hw/i386/pc_piix.c static void pc_init_pci(MachineState *machine) · line 308

Quoted 4 lines
hw/i386/pc_piix.c +1 -0
@@ -305,6 +305,21 @@ static void pc_init_pci(MachineState *machine)
 
 static void pc_compat_2_2(MachineState *machine)
 {
+    x86_cpu_compat_set_features("kvm64", FEAT_1_ECX, CPUID_EXT_VME, 0);

qemu/hw/i386/pc_piix.c:313:54: error:
‘CPUID_EXT_VME’ undeclared (first use in this function)

     x86_cpu_compat_set_features("kvm64", FEAT_1_ECX, CPUID_EXT_VME, 0);
Quoted 4 lines
hw/i386/pc_piix.c +4 -0
+    x86_cpu_compat_set_features("kvm32", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("coreduo", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Conroe", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Penryn", FEAT_1_ECX, CPUID_EXT_VME, 0);

hw/i386/pc_piix.c static void pc_init_pci(MachineState *machine) · line 322

Quoted 10 lines
hw/i386/pc_piix.c +10 -0
+    x86_cpu_compat_set_features("Nehalem", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("SandyBridge", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Opteron_G1", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Opteron_G2", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Opteron_G3", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Opteron_G4", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Opteron_G5", FEAT_1_ECX, CPUID_EXT_VME, 0);

The features need to be _removed_ when running an older machine-type, not added. It should be:

    x86_cpu_compat_set_features(MODEL, FEAT_1_EDX, 0, CPUID_VME);

But the list of CPU models is correct, and matches what is being changed on builtin_x86_defs[].

Signature · 1 line
Eduardo
#6 lore raw

Re: [Qemu-devel] [PATCH 2/4] target-i386: add VME to all CPUs

Quoted 4 lines · Eduardo Habkost
Quoted 4 lines
Quoted 4 lines

vm86 mode extensions date back to the 486. All models should have them.

Quoted 8 lines

TCG doesn't support VME (that's probably why we didn't have it set on most CPU models), and I would like to eventually make check/enforce mode work on TCG as well.

I was going to suggest adding it to kvm_default_features instead, but as we have existing models that have CPUID_VME already, let's be consistent and add it to all of them (and deal with TCG check/enforce mode later, if necessary).

Yes, my thoughts as well. The weird thing is that we have it on the really old models that TCG ought to emulate almost completely, but not on the newer ones...

We can add tcg_default_unset_features too.

Paolo

#7 lore raw

PATCH 3/4 target-i386: add f16c and rdrand to Haswell and Broadwell

In reply to Paolo Bonzini

Both were added in Ivy Bridge (for which we do not have a CPU model yet!).

---
 hw/i386/pc_piix.c | 4 ++++
 hw/i386/pc_q35.c  | 4 ++++
 target-i386/cpu.c | 4 ++--
 3 files changed, 10 insertions(+), 2 deletions(-)
hw/i386/pc_piix.c +4 -0
index 3f1524e..cd9f917 100644
@@ -320,6 +320,10 @@ static void pc_compat_2_2(MachineState *machine)
     x86_cpu_compat_set_features("Opteron_G3", FEAT_1_ECX, CPUID_EXT_VME, 0);
     x86_cpu_compat_set_features("Opteron_G4", FEAT_1_ECX, CPUID_EXT_VME, 0);
     x86_cpu_compat_set_features("Opteron_G5", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, CPUID_EXT_F16C, 0);
+    x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, CPUID_EXT_RDRAND, 0);
+    x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, CPUID_EXT_F16C, 0);
+    x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, CPUID_EXT_RDRAND, 0);
 }
 
 static void pc_compat_2_1(MachineState *machine)
hw/i386/pc_q35.c +4 -0
index bec234a..f225276 100644
@@ -299,6 +299,10 @@ static void pc_compat_2_2(MachineState *machine)
     x86_cpu_compat_set_features("Opteron_G3", FEAT_1_ECX, CPUID_EXT_VME, 0);
     x86_cpu_compat_set_features("Opteron_G4", FEAT_1_ECX, CPUID_EXT_VME, 0);
     x86_cpu_compat_set_features("Opteron_G5", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, CPUID_EXT_F16C, 0);
+    x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, CPUID_EXT_RDRAND, 0);
+    x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, CPUID_EXT_F16C, 0);
+    x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, CPUID_EXT_RDRAND, 0);
 }
 
 static void pc_compat_2_1(MachineState *machine)
target-i386/cpu.c +2 -2
index 136c457..b2bb9a4 100644
@@ -1060,7 +1060,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_SSSE3 |
             CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3 |
             CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_FMA | CPUID_EXT_MOVBE |
-            CPUID_EXT_PCID,
+            CPUID_EXT_PCID | CPUID_EXT_F16C | CPUID_EXT_RDRAND,
         .features[FEAT_8000_0001_EDX] =
             CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX |
             CPUID_EXT2_SYSCALL,
@@ -1095,7 +1095,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_SSSE3 |
             CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3 |
             CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_FMA | CPUID_EXT_MOVBE |
-            CPUID_EXT_PCID,
+            CPUID_EXT_PCID | CPUID_EXT_F16C | CPUID_EXT_RDRAND,
         .features[FEAT_8000_0001_EDX] =
             CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX |
             CPUID_EXT2_SYSCALL,
Signature · 1 line
1.8.3.1
#8 lore raw

Re: [Qemu-devel] [PATCH 3/4] target-i386: add f16c and rdrand to Haswell and Broadwell

Quoted 15 lines · Paolo Bonzini

Both were added in Ivy Bridge (for which we do not have a CPU model yet!).

---
 hw/i386/pc_piix.c | 4 ++++
 hw/i386/pc_q35.c  | 4 ++++
 target-i386/cpu.c | 4 ++--
 3 files changed, 10 insertions(+), 2 deletions(-)
hw/i386/pc_piix.c +0 -0
index 3f1524e..cd9f917 100644

hw/i386/pc_piix.c static void pc_compat_2_2(MachineState *machine) · line 326

Quoted 7 lines
hw/i386/pc_piix.c +4 -0
@@ -320,6 +320,10 @@ static void pc_compat_2_2(MachineState *machine)
     x86_cpu_compat_set_features("Opteron_G3", FEAT_1_ECX, CPUID_EXT_VME, 0);
     x86_cpu_compat_set_features("Opteron_G4", FEAT_1_ECX, CPUID_EXT_VME, 0);
     x86_cpu_compat_set_features("Opteron_G5", FEAT_1_ECX, CPUID_EXT_VME, 0);
+    x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, CPUID_EXT_F16C, 0);
+    x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, CPUID_EXT_RDRAND, 0);
+    x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, CPUID_EXT_F16C, 0);
+    x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, CPUID_EXT_RDRAND, 0);

The feature should be removed on older machine-types, not added. This should be:

    x86_cpu_compat_set_features(MODEL, FEAT_1_ECX, 0, CPUID_EXT_...)

(You can also use CPUID_EXT_F16C|CPUID_EXT_RDRAND in a single x86_cpu_compat_set_features() call)

Signature · 1 line
Eduardo
#9 lore raw

PATCH 4/4 target-i386: add Ivy Bridge CPU model

In reply to Paolo Bonzini
---
 target-i386/cpu.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
target-i386/cpu.c +33 -1
index b2bb9a4..7767564 100644
@@ -1039,7 +1039,39 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .features[FEAT_XSAVE] =
             CPUID_XSAVE_XSAVEOPT,
         .xlevel = 0x8000000A,
-        .model_id = "Intel Xeon E312xx (Sandy Bridge)",
+        .model_id = "Intel Xeon E3-12xx (Sandy Bridge)",
+    },
+    {
+        .name = "IvyBridge",
+        .level = 0xd,
+        .vendor = CPUID_VENDOR_INTEL,
+        .family = 6,
+        .model = 58,
+        .stepping = 9,
+        .features[FEAT_1_EDX] =
+            CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
+            CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
+            CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
+            CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
+            CPUID_DE | CPUID_FP87,
+        .features[FEAT_1_ECX] =
+            CPUID_EXT_AVX | CPUID_EXT_XSAVE | CPUID_EXT_AES |
+            CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_POPCNT |
+            CPUID_EXT_X2APIC | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 |
+            CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | CPUID_EXT_PCLMULQDQ |
+            CPUID_EXT_SSE3 | CPUID_EXT_F16C | CPUID_EXT_RDRAND,
+        .features[FEAT_7_0_EBX] =
+            CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_SMEP |
+            CPUID_7_0_EBX_ERMS,
+        .features[FEAT_8000_0001_EDX] =
+            CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX |
+            CPUID_EXT2_SYSCALL,
+        .features[FEAT_8000_0001_ECX] =
+            CPUID_EXT3_LAHF_LM,
+        .features[FEAT_XSAVE] =
+            CPUID_XSAVE_XSAVEOPT,
+        .xlevel = 0x8000000A,
+        .model_id = "Intel Xeon E3-12xx v2 (Ivy Bridge)",
     },
     {
         .name = "Haswell",
Signature · 1 line
1.8.3.1
#10 lore raw

Re: [Qemu-devel] [PATCH 4/4] target-i386: add Ivy Bridge CPU model

Quoted 10 lines · Paolo Bonzini
---
 target-i386/cpu.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
target-i386/cpu.c +0 -0
index b2bb9a4..7767564 100644

target-i386/cpu.c static X86CPUDefinition builtin_x86_defs[] = { · line 1042

Quoted 5 lines
target-i386/cpu.c +1 -1
@@ -1039,7 +1039,39 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .features[FEAT_XSAVE] =
             CPUID_XSAVE_XSAVEOPT,
         .xlevel = 0x8000000A,
-        .model_id = "Intel Xeon E312xx (Sandy Bridge)",
+        .model_id = "Intel Xeon E3-12xx (Sandy Bridge)",

ABI change. Can we do that in a separate patch?

Signature · 1 line
Eduardo
#11 lore raw

Re: [Qemu-devel] [PATCH 4/4] target-i386: add Ivy Bridge CPU model

Quoted 6 lines · Eduardo Habkost
Quoted 5 lines · Paolo Bonzini
---
 target-i386/cpu.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
Quoted 12 lines

target-i386/cpu.c static X86CPUDefinition builtin_x86_defs[] = { · line 1042

Quoted 10 lines
target-i386/cpu.c +1 -1
index b2bb9a4..7767564 100644
@@ -1039,7 +1039,39 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .features[FEAT_XSAVE] =
             CPUID_XSAVE_XSAVEOPT,
         .xlevel = 0x8000000A,
-        .model_id = "Intel Xeon E312xx (Sandy Bridge)",
+        .model_id = "Intel Xeon E3-12xx (Sandy Bridge)",

ABI change. Can we do that in a separate patch?

We can just leave the typo in, I didn't know this was an ABI change.

Paolo

Reviewed-by on v1 4/4
#12 lore raw

Re: [Qemu-devel] [PATCH 4/4] target-i386: add Ivy Bridge CPU model

In reply to Paolo Bonzini
Quoted 1 line · Paolo Bonzini

For reference, this is the delta from SandyBridge:

  model = 58;
  stepping = 9;
  features[FEAT_1_ECX] |=
      CPUID_EXT_F16C | CPUID_EXT_RDRAND;
  features[FEAT_7_0_EBX] |=
      CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_SMEP |
      CPUID_7_0_EBX_ERMS;

This matches what I see in a real CPU with family/model/stepping IDs 6/58/9.

Quoted 52 lines
---
 target-i386/cpu.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
target-i386/cpu.c +33 -1
index b2bb9a4..7767564 100644
@@ -1039,7 +1039,39 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .features[FEAT_XSAVE] =
             CPUID_XSAVE_XSAVEOPT,
         .xlevel = 0x8000000A,
-        .model_id = "Intel Xeon E312xx (Sandy Bridge)",
+        .model_id = "Intel Xeon E3-12xx (Sandy Bridge)",
+    },
+    {
+        .name = "IvyBridge",
+        .level = 0xd,
+        .vendor = CPUID_VENDOR_INTEL,
+        .family = 6,
+        .model = 58,
+        .stepping = 9,
+        .features[FEAT_1_EDX] =
+            CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |
+            CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA |
+            CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 |
+            CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE |
+            CPUID_DE | CPUID_FP87,
+        .features[FEAT_1_ECX] =
+            CPUID_EXT_AVX | CPUID_EXT_XSAVE | CPUID_EXT_AES |
+            CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_POPCNT |
+            CPUID_EXT_X2APIC | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 |
+            CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | CPUID_EXT_PCLMULQDQ |
+            CPUID_EXT_SSE3 | CPUID_EXT_F16C | CPUID_EXT_RDRAND,
+        .features[FEAT_7_0_EBX] =
+            CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_SMEP |
+            CPUID_7_0_EBX_ERMS,
+        .features[FEAT_8000_0001_EDX] =
+            CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX |
+            CPUID_EXT2_SYSCALL,
+        .features[FEAT_8000_0001_ECX] =
+            CPUID_EXT3_LAHF_LM,
+        .features[FEAT_XSAVE] =
+            CPUID_XSAVE_XSAVEOPT,
+        .xlevel = 0x8000000A,
+        .model_id = "Intel Xeon E3-12xx v2 (Ivy Bridge)",
     },
     {
         .name = "Haswell",
Signature · 1 line
1.8.3.1
Signature · 1 line
Eduardo