Skip to contentSkip to conversation

target-i386: Don't try to enable unsupported TCG features by default

PATCH In review Eduardo Habkost 3 participants 15 messages Sep 11, 2015 – Sep 18, 2015

lore
Share & tools
lore
#1 lore raw

PATCH 1/4 target-i386: Expand PPRO_FEATURES on qemu64/qemu32 definitions

In reply to Eduardo Habkost

The qemu64 and qemu32 CPU models won't be Pentium Pro supersets anymore because the DE feature will be removed. Copy PPRO_FEATURES into their definitions so we can change the CPU models later.

---
 target-i386/cpu.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
target-i386/cpu.c +8 -2
index 32fee00..d505743 100644
@@ -701,7 +701,10 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .model = 6,
         .stepping = 3,
         .features[FEAT_1_EDX] =
-            PPRO_FEATURES |
+            CPUID_FP87 | CPUID_DE | CPUID_PSE | CPUID_TSC |
+            CPUID_MSR | CPUID_MCE | CPUID_CX8 | CPUID_PGE | CPUID_CMOV |
+            CPUID_PAT | CPUID_FXSR | CPUID_MMX | CPUID_SSE | CPUID_SSE2 |
+            CPUID_PAE | CPUID_SEP | CPUID_APIC |
             CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA |
             CPUID_PSE36,
         .features[FEAT_1_ECX] =
@@ -804,7 +807,10 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .model = 6,
         .stepping = 3,
         .features[FEAT_1_EDX] =
-            PPRO_FEATURES,
+            CPUID_FP87 | CPUID_DE | CPUID_PSE | CPUID_TSC |
+            CPUID_MSR | CPUID_MCE | CPUID_CX8 | CPUID_PGE | CPUID_CMOV |
+            CPUID_PAT | CPUID_FXSR | CPUID_MMX | CPUID_SSE | CPUID_SSE2 |
+            CPUID_PAE | CPUID_SEP | CPUID_APIC,
         .features[FEAT_1_ECX] =
             CPUID_EXT_SSE3 | CPUID_EXT_POPCNT,
         .xlevel = 0x80000004,
Signature · 1 line
2.1.0
#0 lore raw

cover target-i386: Don't try to enable unsupported TCG features by default

This series makes QEMU stop trying to enable an unsupported feature by default in TCG mode, avoiding the warnings shown by the (now enabled by default) "check" mode.

To do that, I cchanged the kvm_default_features code to be based on QOM properties, and added a new "type" field to allow per-CPU-model KVM defaults to be specified.

Before this series:

  $ qemu-system-x86_64 -S
  warning: TCG doesn't support requested feature: CPUID.01H:EDX.de [bit 2]
  warning: TCG doesn't support requested feature: CPUID.80000001H:EDX [bit 2]

After this series:

  $ ./x86_64-softmmu/qemu-system-x86_64 -S
  [no warning output]

Eduardo Habkost (4):
target-i386: Expand PPRO_FEATURES on qemu64/qemu32 definitions
target-i386: Convert kvm_default_*features to property/value pairs
target-i386: Add optional class name to kvm_default_props
target-i386: Disable DE on qemu64 & qemu32 on TCG

 hw/i386/pc_piix.c |   8 ++---
 hw/i386/pc_q35.c  |   4 +--
 target-i386/cpu.c | 104 ++++++++++++++++++++++++++++++++++--------------------
 target-i386/cpu.h |  12 +++++--
 4 files changed, 81 insertions(+), 47 deletions(-)
Signature · 1 line
2.1.0
#2 lore raw

PATCH 2/4 target-i386: Convert kvm_default_*features to property/value pairs

Convert the kvm_default_features and kvm_default_unset_features arrays into a simple list of property/value pairs that will be applied to X86CPU objects when using KVM.

---
 hw/i386/pc_piix.c |  8 ++---
 hw/i386/pc_q35.c  |  4 +--
 target-i386/cpu.c | 87 ++++++++++++++++++++++++++++++++-----------------------
 target-i386/cpu.h | 11 +++++--
 4 files changed, 65 insertions(+), 45 deletions(-)
hw/i386/pc_piix.c +4 -4
index 3f925b2..e79ef0d 100644
@@ -325,7 +325,7 @@ static void pc_compat_2_1(MachineState *machine)
 
     pc_compat_2_2(machine);
     smbios_uuid_encoded = false;
-    x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM);
+    x86_cpu_change_kvm_default("svm", NULL);
     pcms->enforce_aligned_dimm = false;
 }
 
@@ -361,7 +361,7 @@ static void pc_compat_1_7(MachineState *machine)
     gigabyte_align = false;
     option_rom_has_mr = true;
     legacy_acpi_table_size = 6414;
-    x86_cpu_compat_kvm_no_autoenable(FEAT_1_ECX, CPUID_EXT_X2APIC);
+    x86_cpu_change_kvm_default("x2apic", NULL);
 }
 
 static void pc_compat_1_6(MachineState *machine)
@@ -391,7 +391,7 @@ static void pc_compat_1_3(MachineState *machine)
 static void pc_compat_1_2(MachineState *machine)
 {
     pc_compat_1_3(machine);
-    x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, 1 << KVM_FEATURE_PV_EOI);
+    x86_cpu_change_kvm_default("kvm-pv-eoi", NULL);
 }
 
 /* PC compat function for pc-0.10 to pc-0.13 */
@@ -414,7 +414,7 @@ static void pc_init_isa(MachineState *machine)
     if (!machine->cpu_model) {
         machine->cpu_model = "486";
     }
-    x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, 1 << KVM_FEATURE_PV_EOI);
+    x86_cpu_change_kvm_default("kvm-pv-eoi", NULL);
     enable_compat_apic_id_mode();
     pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, TYPE_I440FX_PCI_DEVICE);
 }
hw/i386/pc_q35.c +2 -2
index 11601ab..c17d9df 100644
@@ -309,7 +309,7 @@ static void pc_compat_2_1(MachineState *machine)
     pc_compat_2_2(machine);
     pcms->enforce_aligned_dimm = false;
     smbios_uuid_encoded = false;
-    x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM);
+    x86_cpu_change_kvm_default("svm", NULL);
 }
 
 static void pc_compat_2_0(MachineState *machine)
@@ -326,7 +326,7 @@ static void pc_compat_1_7(MachineState *machine)
     smbios_defaults = false;
     gigabyte_align = false;
     option_rom_has_mr = true;
-    x86_cpu_compat_kvm_no_autoenable(FEAT_1_ECX, CPUID_EXT_X2APIC);
+    x86_cpu_change_kvm_default("x2apic", NULL);
 }
 
 static void pc_compat_1_6(MachineState *machine)
target-i386/cpu.c +50 -37

111 lines not on this page · raw message

target-i386/cpu.h +9 -2
index 74b674d..f7c733b 100644
@@ -1332,8 +1332,15 @@ void cpu_smm_update(X86CPU *cpu);
 
 void cpu_report_tpr_access(CPUX86State *env, TPRAccess access);
 
-void x86_cpu_compat_kvm_no_autoenable(FeatureWord w, uint32_t features);
-void x86_cpu_compat_kvm_no_autodisable(FeatureWord w, uint32_t features);
+/* Change the value of a KVM-specific default
+ *
+ * If value is NULL, no default will be set and the original
+ * value from the CPU model table will be kept.
+ *
+ * It is valid to call this funciton only for properties that
+ * are already present in the kvm_default_props table.
+ */
+void x86_cpu_change_kvm_default(const char *prop, const char *value);
 
 
 /* Return name of 32-bit register, from a R_* constant */
Signature · 1 line
2.1.0
#5 lore raw

PATCH 3/4 target-i386: Add optional class name to kvm_default_props

In reply to Eduardo Habkost

This will allow us to define class-specific KVM defaults, instead of defaults that apply to all CPU models.

If this table is starting to look like the global properties tables, that's not a coincidence: in the future, we might convert this to accelerator-specific code that simply register global properties when the machine is initialized.

---
 hw/i386/pc_piix.c |  8 ++++----
 hw/i386/pc_q35.c  |  4 ++--
 target-i386/cpu.c | 29 +++++++++++++++++------------
 target-i386/cpu.h |  3 ++-
 4 files changed, 25 insertions(+), 19 deletions(-)
hw/i386/pc_piix.c +4 -4
index e79ef0d..ad98735 100644
@@ -325,7 +325,7 @@ static void pc_compat_2_1(MachineState *machine)
 
     pc_compat_2_2(machine);
     smbios_uuid_encoded = false;
-    x86_cpu_change_kvm_default("svm", NULL);
+    x86_cpu_change_kvm_default(NULL, "svm", NULL);
     pcms->enforce_aligned_dimm = false;
 }
 
@@ -361,7 +361,7 @@ static void pc_compat_1_7(MachineState *machine)
     gigabyte_align = false;
     option_rom_has_mr = true;
     legacy_acpi_table_size = 6414;
-    x86_cpu_change_kvm_default("x2apic", NULL);
+    x86_cpu_change_kvm_default(NULL, "x2apic", NULL);
 }
 
 static void pc_compat_1_6(MachineState *machine)
@@ -391,7 +391,7 @@ static void pc_compat_1_3(MachineState *machine)
 static void pc_compat_1_2(MachineState *machine)
 {
     pc_compat_1_3(machine);
-    x86_cpu_change_kvm_default("kvm-pv-eoi", NULL);
+    x86_cpu_change_kvm_default(NULL, "kvm-pv-eoi", NULL);
 }
 
 /* PC compat function for pc-0.10 to pc-0.13 */
@@ -414,7 +414,7 @@ static void pc_init_isa(MachineState *machine)
     if (!machine->cpu_model) {
         machine->cpu_model = "486";
     }
-    x86_cpu_change_kvm_default("kvm-pv-eoi", NULL);
+    x86_cpu_change_kvm_default(NULL, "kvm-pv-eoi", NULL);
     enable_compat_apic_id_mode();
     pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, TYPE_I440FX_PCI_DEVICE);
 }
hw/i386/pc_q35.c +2 -2
index c17d9df..94d417e 100644
@@ -309,7 +309,7 @@ static void pc_compat_2_1(MachineState *machine)
     pc_compat_2_2(machine);
     pcms->enforce_aligned_dimm = false;
     smbios_uuid_encoded = false;
-    x86_cpu_change_kvm_default("svm", NULL);
+    x86_cpu_change_kvm_default(NULL, "svm", NULL);
 }
 
 static void pc_compat_2_0(MachineState *machine)
@@ -326,7 +326,7 @@ static void pc_compat_1_7(MachineState *machine)
     smbios_defaults = false;
     gigabyte_align = false;
     option_rom_has_mr = true;
-    x86_cpu_change_kvm_default("x2apic", NULL);
+    x86_cpu_change_kvm_default(NULL, "x2apic", NULL);
 }
 
 static void pc_compat_1_6(MachineState *machine)
target-i386/cpu.c +17 -12
index 9a4bfa3..ec9eca2 100644
@@ -1367,6 +1367,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
 };
 
 typedef struct PropValue {
+    const char *type;
     const char *prop, *value;
 } PropValue;
 
@@ -1374,24 +1375,25 @@ typedef struct PropValue {
  * from all CPU models when KVM is enabled.
  */
 static PropValue kvm_default_props[] = {
-    { "kvmclock", "on" },
-    { "kvm-nopiodelay", "on" },
-    { "kvm-asyncpf", "on" },
-    { "kvm-steal-time", "on" },
-    { "kvm-pv-eoi", "on" },
-    { "kvmclock-stable-bit", "on" },
-    { "x2apic", "on" },
-    { "acpi", "off" },
-    { "monitor", "off" },
-    { "svm", "off" },
+    { NULL, "kvmclock", "on" },
+    { NULL, "kvm-nopiodelay", "on" },
+    { NULL, "kvm-asyncpf", "on" },
+    { NULL, "kvm-steal-time", "on" },
+    { NULL, "kvm-pv-eoi", "on" },
+    { NULL, "kvmclock-stable-bit", "on" },
+    { NULL, "x2apic", "on" },
+    { NULL, "acpi", "off" },
+    { NULL, "monitor", "off" },
+    { NULL, "svm", "off" },
     { NULL, NULL },
 };
 
-void x86_cpu_change_kvm_default(const char *prop, const char *value)
+void x86_cpu_change_kvm_default(const char *type, const char *prop,
+                                const char *value)
 {
     PropValue *pv;
     for (pv = kvm_default_props; pv->prop; pv++) {
-        if (!strcmp(pv->prop, prop)) {
+        if (!g_strcmp0(pv->type, type) && !strcmp(pv->prop, prop)) {
             pv->value = value;
             break;
         }
@@ -2079,6 +2081,9 @@ static void x86_cpu_apply_props(X86CPU *cpu, PropValue *props)
         if (!pv->value) {
             continue;
         }
+        if (pv->type && !object_dynamic_cast(OBJECT(cpu), pv->type)) {
+            continue;
+        }
         object_property_parse(OBJECT(cpu), pv->value, pv->prop,
                               &error_abort);
     }
target-i386/cpu.h +2 -1
index f7c733b..c77d455 100644
@@ -1340,7 +1340,8 @@ void cpu_report_tpr_access(CPUX86State *env, TPRAccess access);
  * It is valid to call this funciton only for properties that
  * are already present in the kvm_default_props table.
  */
-void x86_cpu_change_kvm_default(const char *prop, const char *value);
+void x86_cpu_change_kvm_default(const char *type, const char *prop,
+                                const char *value);
 
 
 /* Return name of 32-bit register, from a R_* constant */
Signature · 1 line
2.1.0
#6 lore raw

PATCH 4/4 target-i386: Disable DE on qemu64 & qemu32 on TCG

In reply to Eduardo Habkost

We don't want to make QEMU show CPUID feature warnings by default when running in TCG mode, so disable the flag in the default qemu32 and qemu64 CPU models, and add it to kvm_default_props so it gets enabled when running KVM.

We don't need any compat code for this because:
* DE was already enabled in KVM mode, and is kept enabled
* DE was already disabled in TCG mode, and is kept disabled

---
 target-i386/cpu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
target-i386/cpu.c +4 -2
index ec9eca2..1617e48 100644
@@ -669,7 +669,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .model = 6,
         .stepping = 3,
         .features[FEAT_1_EDX] =
-            CPUID_FP87 | CPUID_DE | CPUID_PSE | CPUID_TSC |
+            CPUID_FP87 | CPUID_PSE | CPUID_TSC |
             CPUID_MSR | CPUID_MCE | CPUID_CX8 | CPUID_PGE | CPUID_CMOV |
             CPUID_PAT | CPUID_FXSR | CPUID_MMX | CPUID_SSE | CPUID_SSE2 |
             CPUID_PAE | CPUID_SEP | CPUID_APIC |
@@ -775,7 +775,7 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .model = 6,
         .stepping = 3,
         .features[FEAT_1_EDX] =
-            CPUID_FP87 | CPUID_DE | CPUID_PSE | CPUID_TSC |
+            CPUID_FP87 | CPUID_PSE | CPUID_TSC |
             CPUID_MSR | CPUID_MCE | CPUID_CX8 | CPUID_PGE | CPUID_CMOV |
             CPUID_PAT | CPUID_FXSR | CPUID_MMX | CPUID_SSE | CPUID_SSE2 |
             CPUID_PAE | CPUID_SEP | CPUID_APIC,
@@ -1385,6 +1385,8 @@ static PropValue kvm_default_props[] = {
     { NULL, "acpi", "off" },
     { NULL, "monitor", "off" },
     { NULL, "svm", "off" },
+    { X86_CPU_TYPE_NAME("qemu64"), "de", "on" },
+    { X86_CPU_TYPE_NAME("qemu32"), "de", "on" },
     { NULL, NULL },
 };
 
Signature · 1 line
2.1.0
#7 lore raw
In reply to Eduardo Habkost
Quoted 10 lines · Eduardo Habkost

This series makes QEMU stop trying to enable an unsupported feature by default in TCG mode, avoiding the warnings shown by the (now enabled by default) "check" mode.

To do that, I cchanged the kvm_default_features code to be based on QOM properties, and added a new "type" field to allow per-CPU-model KVM defaults to be specified.

Before this series:

Quoted 8 lines
  $ qemu-system-x86_64 -S
  warning: TCG doesn't support requested feature: CPUID.01H:EDX.de [bit 2]
  warning: TCG doesn't support requested feature: CPUID.80000001H:EDX [bit 2]

After this series:

  $ ./x86_64-softmmu/qemu-system-x86_64 -S
  [no warning output]

Wouldn't it be easier simply to implement this bit?
It seems like we're simply creating a compatibility mess otherwise.

r~

#8 lore raw
Quoted 15 lines · Richard Henderson
Quoted 14 lines · Eduardo Habkost

This series makes QEMU stop trying to enable an unsupported feature by default in TCG mode, avoiding the warnings shown by the (now enabled by default) "check" mode.

To do that, I cchanged the kvm_default_features code to be based on QOM properties, and added a new "type" field to allow per-CPU-model KVM defaults to be specified.

Before this series:

  $ qemu-system-x86_64 -S
  warning: TCG doesn't support requested feature: CPUID.01H:EDX.de [bit 2]
  warning: TCG doesn't support requested feature: CPUID.80000001H:EDX [bit 2]
Quoted 7 lines
Quoted 4 lines

After this series:

  $ ./x86_64-softmmu/qemu-system-x86_64 -S
  [no warning output]

Wouldn't it be easier simply to implement this bit?
It seems like we're simply creating a compatibility mess otherwise.

I don't think the compatibility mess is worse than the one we already have with x2apic. I even think the new type/property/value system is cleaner than the existing kvm_default_*features arrays.

About implementing DE in TCG: I really don't think it is easier, but if somebody wants to implement it, it would be welcome.

Signature · 1 line
Eduardo
#9 lore raw
Quoted 2 lines · Eduardo Habkost

About implementing DE in TCG: I really don't think it is easier, but if somebody wants to implement it, it would be welcome.

Actually I agree that it's easier, and even a partial implementation (e.g. no I/O port breakpoints) would be nice to have because recent Windows IIRC requires DE.

Paolo

Acked-by on v1 2/4
#3 lore raw

Re: [Qemu-devel] [PATCH 2/4] target-i386: Convert kvm_default_*features to property/value pairs

In reply to Eduardo Habkost
Quoted 206 lines · Eduardo Habkost

Convert the kvm_default_features and kvm_default_unset_features arrays into a simple list of property/value pairs that will be applied to X86CPU objects when using KVM.

---
 hw/i386/pc_piix.c |  8 ++---
 hw/i386/pc_q35.c  |  4 +--
 target-i386/cpu.c | 87 ++++++++++++++++++++++++++++++++-----------------------
 target-i386/cpu.h | 11 +++++--
 4 files changed, 65 insertions(+), 45 deletions(-)
hw/i386/pc_piix.c +4 -4
index 3f925b2..e79ef0d 100644
@@ -325,7 +325,7 @@ static void pc_compat_2_1(MachineState *machine)
 
     pc_compat_2_2(machine);
     smbios_uuid_encoded = false;
-    x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM);
+    x86_cpu_change_kvm_default("svm", NULL);
     pcms->enforce_aligned_dimm = false;
 }
 
@@ -361,7 +361,7 @@ static void pc_compat_1_7(MachineState *machine)
     gigabyte_align = false;
     option_rom_has_mr = true;
     legacy_acpi_table_size = 6414;
-    x86_cpu_compat_kvm_no_autoenable(FEAT_1_ECX, CPUID_EXT_X2APIC);
+    x86_cpu_change_kvm_default("x2apic", NULL);
 }
 
 static void pc_compat_1_6(MachineState *machine)
@@ -391,7 +391,7 @@ static void pc_compat_1_3(MachineState *machine)
 static void pc_compat_1_2(MachineState *machine)
 {
     pc_compat_1_3(machine);
-    x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, 1 << KVM_FEATURE_PV_EOI);
+    x86_cpu_change_kvm_default("kvm-pv-eoi", NULL);
 }
 
 /* PC compat function for pc-0.10 to pc-0.13 */
@@ -414,7 +414,7 @@ static void pc_init_isa(MachineState *machine)
     if (!machine->cpu_model) {
         machine->cpu_model = "486";
     }
-    x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, 1 << KVM_FEATURE_PV_EOI);
+    x86_cpu_change_kvm_default("kvm-pv-eoi", NULL);
     enable_compat_apic_id_mode();
     pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, TYPE_I440FX_PCI_DEVICE);
 }
hw/i386/pc_q35.c +2 -2
index 11601ab..c17d9df 100644
@@ -309,7 +309,7 @@ static void pc_compat_2_1(MachineState *machine)
     pc_compat_2_2(machine);
     pcms->enforce_aligned_dimm = false;
     smbios_uuid_encoded = false;
-    x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM);
+    x86_cpu_change_kvm_default("svm", NULL);
 }
 
 static void pc_compat_2_0(MachineState *machine)
@@ -326,7 +326,7 @@ static void pc_compat_1_7(MachineState *machine)
     smbios_defaults = false;
     gigabyte_align = false;
     option_rom_has_mr = true;
-    x86_cpu_compat_kvm_no_autoenable(FEAT_1_ECX, CPUID_EXT_X2APIC);
+    x86_cpu_change_kvm_default("x2apic", NULL);
 }
 
 static void pc_compat_1_6(MachineState *machine)
target-i386/cpu.c +50 -37
index d505743..9a4bfa3 100644
@@ -478,38 +478,6 @@ const char *get_register_name_32(unsigned int reg)
     return x86_reg_info_32[reg].name;
 }
 
-/* KVM-specific features that are automatically added to all CPU models
- * when KVM is enabled.
- */
-static uint32_t kvm_default_features[FEATURE_WORDS] = {
-    [FEAT_KVM] = (1 << KVM_FEATURE_CLOCKSOURCE) |
-        (1 << KVM_FEATURE_NOP_IO_DELAY) |
-        (1 << KVM_FEATURE_CLOCKSOURCE2) |
-        (1 << KVM_FEATURE_ASYNC_PF) |
-        (1 << KVM_FEATURE_STEAL_TIME) |
-        (1 << KVM_FEATURE_PV_EOI) |
-        (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT),
-    [FEAT_1_ECX] = CPUID_EXT_X2APIC,
-};
-
-/* Features that are not added by default to any CPU model when KVM is enabled.
- */
-static uint32_t kvm_default_unset_features[FEATURE_WORDS] = {
-    [FEAT_1_EDX] = CPUID_ACPI,
-    [FEAT_1_ECX] = CPUID_EXT_MONITOR,
-    [FEAT_8000_0001_ECX] = CPUID_EXT3_SVM,
-};
-
-void x86_cpu_compat_kvm_no_autoenable(FeatureWord w, uint32_t features)
-{
-    kvm_default_features[w] &= ~features;
-}
-
-void x86_cpu_compat_kvm_no_autodisable(FeatureWord w, uint32_t features)
-{
-    kvm_default_unset_features[w] &= ~features;
-}
-
 /*
  * Returns the set of feature flags that are supported and migratable by
  * QEMU, for a given FeatureWord.
@@ -1398,6 +1366,43 @@ static X86CPUDefinition builtin_x86_defs[] = {
     },
 };
 
+typedef struct PropValue {
+    const char *prop, *value;
+} PropValue;
+
+/* KVM-specific features that are automatically added/removed
+ * from all CPU models when KVM is enabled.
+ */
+static PropValue kvm_default_props[] = {
+    { "kvmclock", "on" },
+    { "kvm-nopiodelay", "on" },
+    { "kvm-asyncpf", "on" },
+    { "kvm-steal-time", "on" },
+    { "kvm-pv-eoi", "on" },
+    { "kvmclock-stable-bit", "on" },
+    { "x2apic", "on" },
+    { "acpi", "off" },
+    { "monitor", "off" },
+    { "svm", "off" },
+    { NULL, NULL },
+};
+
+void x86_cpu_change_kvm_default(const char *prop, const char *value)
+{
+    PropValue *pv;
+    for (pv = kvm_default_props; pv->prop; pv++) {
+        if (!strcmp(pv->prop, prop)) {
+            pv->value = value;
+            break;
+        }
+    }
+
+    /* It is valid to call this function only for properties that
+     * are already present in the kvm_default_props table.
+     */
+    assert(pv->prop);
+}
+
 static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w,
                                                    bool migratable_only);
 
@@ -2067,6 +2072,18 @@ static int x86_cpu_filter_features(X86CPU *cpu)
     return rv;
 }
 
+static void x86_cpu_apply_props(X86CPU *cpu, PropValue *props)
+{
+    PropValue *pv;
+    for (pv = props; pv->prop; pv++) {
+        if (!pv->value) {
+            continue;
+        }
+        object_property_parse(OBJECT(cpu), pv->value, pv->prop,
+                              &error_abort);
+    }
+}
+
 /* Load data from X86CPUDefinition
  */
 static void x86_cpu_load_def(X86CPU *cpu, X86CPUDefinition *def, Error **errp)
@@ -2090,11 +2107,7 @@ static void x86_cpu_load_def(X86CPU *cpu, X86CPUDefinition *def, Error **errp)
 
     /* Special cases not set in the X86CPUDefinition structs: */
     if (kvm_enabled()) {
-        FeatureWord w;
-        for (w = 0; w < FEATURE_WORDS; w++) {
-            env->features[w] |= kvm_default_features[w];
-            env->features[w] &= ~kvm_default_unset_features[w];
-        }
+        x86_cpu_apply_props(cpu, kvm_default_props);
     }
 
     env->features[FEAT_1_ECX] |= CPUID_EXT_HYPERVISOR;
target-i386/cpu.h +2 -2
index 74b674d..f7c733b 100644
@@ -1332,8 +1332,15 @@ void cpu_smm_update(X86CPU *cpu);
 
 void cpu_report_tpr_access(CPUX86State *env, TPRAccess access);
 
-void x86_cpu_compat_kvm_no_autoenable(FeatureWord w, uint32_t features);
-void x86_cpu_compat_kvm_no_autodisable(FeatureWord w, uint32_t features);
+/* Change the value of a KVM-specific default
+ *

target-i386/cpu.h void cpu_smm_update(X86CPU *cpu); · line 1346

Quoted 10 lines
target-i386/cpu.h +7 -0
+ * If value is NULL, no default will be set and the original
+ * value from the CPU model table will be kept.
+ *
+ * It is valid to call this funciton only for properties that
+ * are already present in the kvm_default_props table.
+ */
+void x86_cpu_change_kvm_default(const char *prop, const char *value);
 
 
 /* Return name of 32-bit register, from a R_* constant */
#10 lore raw
In reply to Paolo Bonzini
Quoted 9 lines · Paolo Bonzini
Quoted 2 lines · Eduardo Habkost

About implementing DE in TCG: I really don't think it is easier, but if somebody wants to implement it, it would be welcome.

Actually I agree that it's easier, and even a partial implementation (e.g. no I/O port breakpoints) would be nice to have because recent Windows IIRC requires DE.

So if anybody volunteer to implement DE in TCG before 2.5, we won't need this series (except for patch 2/4, that I plan to apply anyway).

If nobody implements it before soft freeze, I will resubmit the series.

Signature · 1 line
Eduardo
#11 lore raw
In reply to Paolo Bonzini
Quoted 9 lines · Paolo Bonzini
Quoted 2 lines · Eduardo Habkost

About implementing DE in TCG: I really don't think it is easier, but if somebody wants to implement it, it would be welcome.

Actually I agree that it's easier, and even a partial implementation (e.g. no I/O port breakpoints) would be nice to have because recent Windows IIRC requires DE.

Isn't I/O port breakpoints the only thing we're missing from DE?

r~

#12 lore raw
Quoted 7 lines · Richard Henderson
Quoted 6 lines
Quoted 6 lines

About implementing DE in TCG: I really don't think it is easier, but if

Quoted 1 line
Quoted 1 line

somebody wants to implement it, it would be welcome.

Actually I agree that it's easier, and even a partial implementation (e.g. no I/O port breakpoints) would be nice to have because recent Windows IIRC requires DE.

Isn't I/O port breakpoints the only thing we're missing from DE?

I was thinking of the CR4 bit, but it looks like we don't raise #GP at all on writes to unknown CR0 or CR4 bits.

Paolo

#13 lore raw
Quoted 6 lines · Paolo Bonzini
Quoted 3 lines · Richard Henderson
Quoted 3 lines
Quoted 3 lines

About implementing DE in TCG: I really don't think it is easier, but if

Quoted 1 line
Quoted 1 line

somebody wants to implement it, it would be welcome.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

Actually I agree that it's easier, and even a partial implementation (e.g. no I/O port breakpoints) would be nice to have because recent Windows IIRC requires DE.

Isn't I/O port breakpoints the only thing we're missing from DE?

I was thinking of the CR4 bit, but it looks like we don't raise #GP at all on writes to unknown CR0 or CR4 bits.

Nor do we #gp accesses to dr[45] with DE, nor map dr[45] to dr[67] without DE.

Does the i/o breakpoint happen before or after the access? If before, we could implement the breakpoint in check_io. Otherwise we'd need a new helper.

r~

#14 lore raw
Quoted 12 lines · Richard Henderson
Quoted 11 lines · Paolo Bonzini
Quoted 7 lines · Richard Henderson
Quoted 6 lines
Quoted 6 lines

About implementing DE in TCG: I really don't think it is easier, but if

Quoted 1 line
Quoted 1 line

somebody wants to implement it, it would be welcome.

Actually I agree that it's easier, and even a partial implementation (e.g. no I/O port breakpoints) would be nice to have because recent Windows IIRC requires DE.

Isn't I/O port breakpoints the only thing we're missing from DE?

Quoted 7 lines
Quoted 2 lines

I was thinking of the CR4 bit, but it looks like we don't raise #GP at all on writes to unknown CR0 or CR4 bits.

Nor do we #gp accesses to dr[45] with DE, nor map dr[45] to dr[67] without DE.

Does the i/o breakpoint happen before or after the access? If before, we could implement the breakpoint in check_io. Otherwise we'd need a new helper.

Table 6-3 says it's a trap, so it occurs after.

Paolo

author Applied
#4 lore raw

Re: [Qemu-devel] [PATCH 2/4] target-i386: Convert kvm_default_*features to property/value pairs

In reply to Paolo Bonzini
Quoted 6 lines · Paolo Bonzini
Quoted 5 lines · Eduardo Habkost

Convert the kvm_default_features and kvm_default_unset_features arrays into a simple list of property/value pairs that will be applied to X86CPU objects when using KVM.

[...]

Quoted 2 lines

Tested using the avocado-vt+tp-qemu CPUID test case that compares CPUID data with existing CPUID dumps, no issues found.

Applied to x86 tree.

Signature · 1 line
Eduardo