qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL v2 0/5] QOM CPUState patch queue 2014-11-04
@ 2014-11-04 16:30 Andreas Färber
  2014-11-04 16:30 ` [Qemu-devel] [PULL v2 1/5] target-i386: Rename KVM auto-feature-enable compat function Andreas Färber
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Andreas Färber @ 2014-11-04 16:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Eduardo Habkost

Hello Peter,

This is my QOM CPU patch queue. v2 is a rebase. Please pull.

Regards,
Andreas

Cc: Peter Maydell <peter.maydell@linaro.org>

Cc: Eduardo Habkost <ehabkost@redhat.com>

The following changes since commit 1bc8dae31baa8b02a1b8e70c3244232e03bbb3b2:

  Merge remote-tracking branch 'remotes/kraxel/tags/pull-gtk-20141104-2' into staging (2014-11-04 15:00:17 +0000)

are available in the git repository at:


  git://github.com/afaerber/qemu-cpu.git tags/qom-cpu-for-peter

for you to fetch changes up to 4991f26efbcfc7ebb7c3029bb56fa21cecf1946f:

  target-i386: Disable SVM by default in KVM mode (2014-11-04 17:27:21 +0100)

----------------------------------------------------------------
QOM CPUState and X86CPU

* Cleanups for -cpu ...,enforce

----------------------------------------------------------------
Eduardo Habkost (5):
      target-i386: Rename KVM auto-feature-enable compat function
      target-i386: Disable CPUID_ACPI by default in KVM mode
      target-i386: Remove unsupported bits from all CPU models
      target-i386: Don't enable nested VMX by default
      target-i386: Disable SVM by default in KVM mode

 hw/i386/pc_piix.c |  9 ++++++---
 hw/i386/pc_q35.c  |  5 ++++-
 target-i386/cpu.c | 42 ++++++++++++++++++++++++++++--------------
 target-i386/cpu.h |  3 ++-
 4 files changed, 40 insertions(+), 19 deletions(-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL v2 1/5] target-i386: Rename KVM auto-feature-enable compat function
  2014-11-04 16:30 [Qemu-devel] [PULL v2 0/5] QOM CPUState patch queue 2014-11-04 Andreas Färber
@ 2014-11-04 16:30 ` Andreas Färber
  2014-11-04 16:30 ` [Qemu-devel] [PULL v2 2/5] target-i386: Disable CPUID_ACPI by default in KVM mode Andreas Färber
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Andreas Färber @ 2014-11-04 16:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: Eduardo Habkost, Michael S. Tsirkin, Anthony Liguori,
	Paolo Bonzini, Andreas Färber, Richard Henderson

From: Eduardo Habkost <ehabkost@redhat.com>

The x86_cpu_compat_disable_kvm_features() name was a bit confusing, as
it won't forcibly disable the feature for all CPU models (i.e. add it to
kvm_default_unset_features), but it will instead turn off the KVM
auto-enabling of the feature (i.e. remove it from kvm_default_features),
meaning the feature may still be enabled by default in some CPU models).

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 hw/i386/pc_piix.c | 6 +++---
 hw/i386/pc_q35.c  | 2 +-
 target-i386/cpu.c | 2 +-
 target-i386/cpu.h | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 537bcf2..87601ee 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -340,7 +340,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_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
+    x86_cpu_compat_kvm_no_autoenable(FEAT_1_ECX, CPUID_EXT_X2APIC);
 }
 
 static void pc_compat_1_6(MachineState *machine)
@@ -372,7 +372,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_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
+    x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, KVM_FEATURE_PV_EOI);
 }
 
 static void pc_init_pci_2_1(MachineState *machine)
@@ -443,7 +443,7 @@ static void pc_init_isa(MachineState *machine)
     if (!machine->cpu_model) {
         machine->cpu_model = "486";
     }
-    x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
+    x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, KVM_FEATURE_PV_EOI);
     enable_compat_apic_id_mode();
     pc_init1(machine, 0, 1);
 }
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 296bdec..2044b62 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -301,7 +301,7 @@ static void pc_compat_1_7(MachineState *machine)
     smbios_defaults = false;
     gigabyte_align = false;
     option_rom_has_mr = true;
-    x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
+    x86_cpu_compat_kvm_no_autoenable(FEAT_1_ECX, CPUID_EXT_X2APIC);
 }
 
 static void pc_compat_1_6(MachineState *machine)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index e4ccee1..1b25965 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -462,7 +462,7 @@ static uint32_t kvm_default_unset_features[FEATURE_WORDS] = {
     [FEAT_1_ECX] = CPUID_EXT_MONITOR,
 };
 
-void x86_cpu_compat_disable_kvm_features(FeatureWord w, uint32_t features)
+void x86_cpu_compat_kvm_no_autoenable(FeatureWord w, uint32_t features)
 {
     kvm_default_features[w] &= ~features;
 }
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 9f01831..a3fc6d8 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -1365,7 +1365,7 @@ void cpu_report_tpr_access(CPUX86State *env, TPRAccess access);
 void x86_cpu_compat_set_features(const char *cpu_model, FeatureWord w,
                                  uint32_t feat_add, uint32_t feat_remove);
 
-void x86_cpu_compat_disable_kvm_features(FeatureWord w, uint32_t features);
+void x86_cpu_compat_kvm_no_autoenable(FeatureWord w, uint32_t features);
 
 
 /* Return name of 32-bit register, from a R_* constant */
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL v2 2/5] target-i386: Disable CPUID_ACPI by default in KVM mode
  2014-11-04 16:30 [Qemu-devel] [PULL v2 0/5] QOM CPUState patch queue 2014-11-04 Andreas Färber
  2014-11-04 16:30 ` [Qemu-devel] [PULL v2 1/5] target-i386: Rename KVM auto-feature-enable compat function Andreas Färber
@ 2014-11-04 16:30 ` Andreas Färber
  2014-11-04 16:30 ` [Qemu-devel] [PULL v2 3/5] target-i386: Remove unsupported bits from all CPU models Andreas Färber
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Andreas Färber @ 2014-11-04 16:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Richard Henderson, Eduardo Habkost,
	Andreas Färber

From: Eduardo Habkost <ehabkost@redhat.com>

KVM never supported the CPUID_ACPI flag, so it doesn't make sense to
have it enabled by default when KVM is enabled.

The motivation here is exactly the same we had for the MONITOR flag
(disabled by commit 136a7e9a85d7047461f8153f7d12c514a3d68f69).

And like in the MONITOR flag case, we don't need machine-type compat code
because it is currently impossible to run a KVM VM with the ACPI flag set.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-i386/cpu.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 1b25965..727416e 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -459,6 +459,7 @@ static uint32_t kvm_default_features[FEATURE_WORDS] = {
 /* 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,
 };
 
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL v2 3/5] target-i386: Remove unsupported bits from all CPU models
  2014-11-04 16:30 [Qemu-devel] [PULL v2 0/5] QOM CPUState patch queue 2014-11-04 Andreas Färber
  2014-11-04 16:30 ` [Qemu-devel] [PULL v2 1/5] target-i386: Rename KVM auto-feature-enable compat function Andreas Färber
  2014-11-04 16:30 ` [Qemu-devel] [PULL v2 2/5] target-i386: Disable CPUID_ACPI by default in KVM mode Andreas Färber
@ 2014-11-04 16:30 ` Andreas Färber
  2014-11-04 16:30 ` [Qemu-devel] [PULL v2 4/5] target-i386: Don't enable nested VMX by default Andreas Färber
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Andreas Färber @ 2014-11-04 16:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Richard Henderson, Eduardo Habkost, Aurelien Jarno,
	Andreas Färber

From: Eduardo Habkost <ehabkost@redhat.com>

The following CPU features were never supported by neither TCG or KVM,
so they are useless on the CPU model definitions, today:

 * CPUID_DTS (DS)
 * CPUID_HT
 * CPUID_TM
 * CPUID_PBE
 * CPUID_EXT_DTES64
 * CPUID_EXT_DSCPL
 * CPUID_EXT_EST
 * CPUID_EXT_TM2
 * CPUID_EXT_XTPR
 * CPUID_EXT_PDCM
 * CPUID_SVM_LBRV

As using "enforce" mode is the only way to ensure guest ABI doesn't
change when moving to a different host, we should make "enforce" mode
the default or at least encourage management software to always use it.

In turn, to make "enforce" usable, we need CPU models that work without
always requiring some features to be explicitly disabled. This patch
removes the above features from all CPU model definitions.

We won't need any machine-type compat code for those changes, because it
is impossible to have existing VMs with those features enabled.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-i386/cpu.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 727416e..0c41b92 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -679,10 +679,11 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .family = 16,
         .model = 2,
         .stepping = 3,
+        /* Missing: CPUID_HT */
         .features[FEAT_1_EDX] =
             PPRO_FEATURES |
             CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA |
-            CPUID_PSE36 | CPUID_VME | CPUID_HT,
+            CPUID_PSE36 | CPUID_VME,
         .features[FEAT_1_ECX] =
             CPUID_EXT_SSE3 | CPUID_EXT_MONITOR | CPUID_EXT_CX16 |
             CPUID_EXT_POPCNT,
@@ -698,8 +699,9 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .features[FEAT_8000_0001_ECX] =
             CPUID_EXT3_LAHF_LM | CPUID_EXT3_SVM |
             CPUID_EXT3_ABM | CPUID_EXT3_SSE4A,
+        /* Missing: CPUID_SVM_LBRV */
         .features[FEAT_SVM] =
-            CPUID_SVM_NPT | CPUID_SVM_LBRV,
+            CPUID_SVM_NPT,
         .xlevel = 0x8000001A,
         .model_id = "AMD Phenom(tm) 9550 Quad-Core Processor"
     },
@@ -710,15 +712,16 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .family = 6,
         .model = 15,
         .stepping = 11,
+        /* Missing: CPUID_DTS, CPUID_HT, CPUID_TM, CPUID_PBE */
         .features[FEAT_1_EDX] =
             PPRO_FEATURES |
             CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA |
-            CPUID_PSE36 | CPUID_VME | CPUID_DTS | CPUID_ACPI | CPUID_SS |
-            CPUID_HT | CPUID_TM | CPUID_PBE,
+            CPUID_PSE36 | CPUID_VME | CPUID_ACPI | CPUID_SS,
+        /* Missing: CPUID_EXT_DTES64, CPUID_EXT_DSCPL, CPUID_EXT_EST,
+         * CPUID_EXT_TM2, CPUID_EXT_XTPR, CPUID_EXT_PDCM */
         .features[FEAT_1_ECX] =
             CPUID_EXT_SSE3 | CPUID_EXT_MONITOR | CPUID_EXT_SSSE3 |
-            CPUID_EXT_DTES64 | CPUID_EXT_DSCPL | CPUID_EXT_VMX | CPUID_EXT_EST |
-            CPUID_EXT_TM2 | CPUID_EXT_CX16 | CPUID_EXT_XTPR | CPUID_EXT_PDCM,
+            CPUID_EXT_VMX | CPUID_EXT_CX16,
         .features[FEAT_8000_0001_EDX] =
             CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX,
         .features[FEAT_8000_0001_ECX] =
@@ -793,13 +796,15 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .family = 6,
         .model = 14,
         .stepping = 8,
+        /* Missing: CPUID_DTS, CPUID_HT, CPUID_TM, CPUID_PBE */
         .features[FEAT_1_EDX] =
             PPRO_FEATURES | CPUID_VME |
-            CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA | CPUID_DTS | CPUID_ACPI |
-            CPUID_SS | CPUID_HT | CPUID_TM | CPUID_PBE,
+            CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA | CPUID_ACPI |
+            CPUID_SS,
+        /* Missing: CPUID_EXT_EST, CPUID_EXT_TM2 , CPUID_EXT_XTPR,
+         * CPUID_EXT_PDCM */
         .features[FEAT_1_ECX] =
-            CPUID_EXT_SSE3 | CPUID_EXT_MONITOR | CPUID_EXT_VMX |
-            CPUID_EXT_EST | CPUID_EXT_TM2 | CPUID_EXT_XTPR | CPUID_EXT_PDCM,
+            CPUID_EXT_SSE3 | CPUID_EXT_MONITOR | CPUID_EXT_VMX,
         .features[FEAT_8000_0001_EDX] =
             CPUID_EXT2_NX,
         .xlevel = 0x80000008,
@@ -872,14 +877,16 @@ static X86CPUDefinition builtin_x86_defs[] = {
         .family = 6,
         .model = 28,
         .stepping = 2,
+        /* Missing: CPUID_DTS, CPUID_HT, CPUID_TM, CPUID_PBE */
         .features[FEAT_1_EDX] =
             PPRO_FEATURES |
-            CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA | CPUID_VME | CPUID_DTS |
-            CPUID_ACPI | CPUID_SS | CPUID_HT | CPUID_TM | CPUID_PBE,
+            CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA | CPUID_VME |
+            CPUID_ACPI | CPUID_SS,
             /* Some CPUs got no CPUID_SEP */
+        /* Missing: CPUID_EXT_DSCPL, CPUID_EXT_EST, CPUID_EXT_TM2,
+         * CPUID_EXT_XTPR */
         .features[FEAT_1_ECX] =
             CPUID_EXT_SSE3 | CPUID_EXT_MONITOR | CPUID_EXT_SSSE3 |
-            CPUID_EXT_DSCPL | CPUID_EXT_EST | CPUID_EXT_TM2 | CPUID_EXT_XTPR |
             CPUID_EXT_MOVBE,
         .features[FEAT_8000_0001_EDX] =
             (PPRO_FEATURES & CPUID_EXT2_AMD_ALIASES) |
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL v2 4/5] target-i386: Don't enable nested VMX by default
  2014-11-04 16:30 [Qemu-devel] [PULL v2 0/5] QOM CPUState patch queue 2014-11-04 Andreas Färber
                   ` (2 preceding siblings ...)
  2014-11-04 16:30 ` [Qemu-devel] [PULL v2 3/5] target-i386: Remove unsupported bits from all CPU models Andreas Färber
@ 2014-11-04 16:30 ` Andreas Färber
  2014-11-04 16:30 ` [Qemu-devel] [PULL v2 5/5] target-i386: Disable SVM by default in KVM mode Andreas Färber
  2014-11-04 17:24 ` [Qemu-devel] [PULL v2 0/5] QOM CPUState patch queue 2014-11-04 Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Andreas Färber @ 2014-11-04 16:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: Eduardo Habkost, Michael S. Tsirkin, Anthony Liguori,
	Paolo Bonzini, Andreas Färber, Richard Henderson

From: Eduardo Habkost <ehabkost@redhat.com>

TCG doesn't support VMX, and nested VMX is not enabled by default in the
KVM kernel module.

So, there's no reason to have VMX enabled by default on the core2duo and
coreduo CPU models, today. Even the newer Intel CPU model definitions
don't have it enabled.

In this case, we need machine-type compat code, as people may be running
the older machine-types on hosts that had VMX nesting enabled.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 hw/i386/pc_piix.c | 2 ++
 hw/i386/pc_q35.c  | 2 ++
 target-i386/cpu.c | 8 ++++----
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 87601ee..8de85c3 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -306,6 +306,8 @@ static void pc_init_pci(MachineState *machine)
 static void pc_compat_2_1(MachineState *machine)
 {
     smbios_uuid_encoded = false;
+    x86_cpu_compat_set_features("coreduo", FEAT_1_ECX, CPUID_EXT_VMX, 0);
+    x86_cpu_compat_set_features("core2duo", FEAT_1_ECX, CPUID_EXT_VMX, 0);
 }
 
 static void pc_compat_2_0(MachineState *machine)
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 2044b62..fd8593b 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -285,6 +285,8 @@ static void pc_q35_init(MachineState *machine)
 static void pc_compat_2_1(MachineState *machine)
 {
     smbios_uuid_encoded = false;
+    x86_cpu_compat_set_features("coreduo", FEAT_1_ECX, CPUID_EXT_VMX, 0);
+    x86_cpu_compat_set_features("core2duo", FEAT_1_ECX, CPUID_EXT_VMX, 0);
 }
 
 static void pc_compat_2_0(MachineState *machine)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 0c41b92..b731832 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -718,10 +718,10 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA |
             CPUID_PSE36 | CPUID_VME | CPUID_ACPI | CPUID_SS,
         /* Missing: CPUID_EXT_DTES64, CPUID_EXT_DSCPL, CPUID_EXT_EST,
-         * CPUID_EXT_TM2, CPUID_EXT_XTPR, CPUID_EXT_PDCM */
+         * CPUID_EXT_TM2, CPUID_EXT_XTPR, CPUID_EXT_PDCM, CPUID_EXT_VMX */
         .features[FEAT_1_ECX] =
             CPUID_EXT_SSE3 | CPUID_EXT_MONITOR | CPUID_EXT_SSSE3 |
-            CPUID_EXT_VMX | CPUID_EXT_CX16,
+            CPUID_EXT_CX16,
         .features[FEAT_8000_0001_EDX] =
             CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX,
         .features[FEAT_8000_0001_ECX] =
@@ -802,9 +802,9 @@ static X86CPUDefinition builtin_x86_defs[] = {
             CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA | CPUID_ACPI |
             CPUID_SS,
         /* Missing: CPUID_EXT_EST, CPUID_EXT_TM2 , CPUID_EXT_XTPR,
-         * CPUID_EXT_PDCM */
+         * CPUID_EXT_PDCM, CPUID_EXT_VMX */
         .features[FEAT_1_ECX] =
-            CPUID_EXT_SSE3 | CPUID_EXT_MONITOR | CPUID_EXT_VMX,
+            CPUID_EXT_SSE3 | CPUID_EXT_MONITOR,
         .features[FEAT_8000_0001_EDX] =
             CPUID_EXT2_NX,
         .xlevel = 0x80000008,
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL v2 5/5] target-i386: Disable SVM by default in KVM mode
  2014-11-04 16:30 [Qemu-devel] [PULL v2 0/5] QOM CPUState patch queue 2014-11-04 Andreas Färber
                   ` (3 preceding siblings ...)
  2014-11-04 16:30 ` [Qemu-devel] [PULL v2 4/5] target-i386: Don't enable nested VMX by default Andreas Färber
@ 2014-11-04 16:30 ` Andreas Färber
  2014-11-04 17:24 ` [Qemu-devel] [PULL v2 0/5] QOM CPUState patch queue 2014-11-04 Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Andreas Färber @ 2014-11-04 16:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: Eduardo Habkost, Michael S. Tsirkin, Anthony Liguori,
	Paolo Bonzini, Andreas Färber, Richard Henderson

From: Eduardo Habkost <ehabkost@redhat.com>

Make SVM be disabled by default on all CPU models when in KVM mode.
Nested SVM is enabled by default in the KVM kernel module, but it is
probably less stable than nested VMX (which is already disabled by
default).

Add a new compat function, x86_cpu_compat_kvm_no_autodisable(), to keep
compatibility on previous machine-types.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 hw/i386/pc_piix.c | 1 +
 hw/i386/pc_q35.c  | 1 +
 target-i386/cpu.c | 6 ++++++
 target-i386/cpu.h | 1 +
 4 files changed, 9 insertions(+)

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 8de85c3..b559181 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -308,6 +308,7 @@ static void pc_compat_2_1(MachineState *machine)
     smbios_uuid_encoded = false;
     x86_cpu_compat_set_features("coreduo", FEAT_1_ECX, CPUID_EXT_VMX, 0);
     x86_cpu_compat_set_features("core2duo", FEAT_1_ECX, CPUID_EXT_VMX, 0);
+    x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM);
 }
 
 static void pc_compat_2_0(MachineState *machine)
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index fd8593b..598e679 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -287,6 +287,7 @@ static void pc_compat_2_1(MachineState *machine)
     smbios_uuid_encoded = false;
     x86_cpu_compat_set_features("coreduo", FEAT_1_ECX, CPUID_EXT_VMX, 0);
     x86_cpu_compat_set_features("core2duo", FEAT_1_ECX, CPUID_EXT_VMX, 0);
+    x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM);
 }
 
 static void pc_compat_2_0(MachineState *machine)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index b731832..fa860de 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -461,6 +461,7 @@ static uint32_t kvm_default_features[FEATURE_WORDS] = {
 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)
@@ -468,6 +469,11 @@ 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.
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index a3fc6d8..1b2c12a 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -1366,6 +1366,7 @@ void x86_cpu_compat_set_features(const char *cpu_model, FeatureWord w,
                                  uint32_t feat_add, uint32_t feat_remove);
 
 void x86_cpu_compat_kvm_no_autoenable(FeatureWord w, uint32_t features);
+void x86_cpu_compat_kvm_no_autodisable(FeatureWord w, uint32_t features);
 
 
 /* Return name of 32-bit register, from a R_* constant */
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PULL v2 0/5] QOM CPUState patch queue 2014-11-04
  2014-11-04 16:30 [Qemu-devel] [PULL v2 0/5] QOM CPUState patch queue 2014-11-04 Andreas Färber
                   ` (4 preceding siblings ...)
  2014-11-04 16:30 ` [Qemu-devel] [PULL v2 5/5] target-i386: Disable SVM by default in KVM mode Andreas Färber
@ 2014-11-04 17:24 ` Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2014-11-04 17:24 UTC (permalink / raw)
  To: Andreas Färber; +Cc: QEMU Developers, Eduardo Habkost

On 4 November 2014 16:30, Andreas Färber <afaerber@suse.de> wrote:
> Hello Peter,
>
> This is my QOM CPU patch queue. v2 is a rebase. Please pull.
>
> Regards,
> Andreas
>
> Cc: Peter Maydell <peter.maydell@linaro.org>
>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
>
> The following changes since commit 1bc8dae31baa8b02a1b8e70c3244232e03bbb3b2:
>
>   Merge remote-tracking branch 'remotes/kraxel/tags/pull-gtk-20141104-2' into staging (2014-11-04 15:00:17 +0000)
>
> are available in the git repository at:
>
>
>   git://github.com/afaerber/qemu-cpu.git tags/qom-cpu-for-peter
>
> for you to fetch changes up to 4991f26efbcfc7ebb7c3029bb56fa21cecf1946f:
>
>   target-i386: Disable SVM by default in KVM mode (2014-11-04 17:27:21 +0100)
>
> ----------------------------------------------------------------
> QOM CPUState and X86CPU
>
> * Cleanups for -cpu ...,enforce
>
> ----------------------------------------------------------------

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-11-04 17:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-04 16:30 [Qemu-devel] [PULL v2 0/5] QOM CPUState patch queue 2014-11-04 Andreas Färber
2014-11-04 16:30 ` [Qemu-devel] [PULL v2 1/5] target-i386: Rename KVM auto-feature-enable compat function Andreas Färber
2014-11-04 16:30 ` [Qemu-devel] [PULL v2 2/5] target-i386: Disable CPUID_ACPI by default in KVM mode Andreas Färber
2014-11-04 16:30 ` [Qemu-devel] [PULL v2 3/5] target-i386: Remove unsupported bits from all CPU models Andreas Färber
2014-11-04 16:30 ` [Qemu-devel] [PULL v2 4/5] target-i386: Don't enable nested VMX by default Andreas Färber
2014-11-04 16:30 ` [Qemu-devel] [PULL v2 5/5] target-i386: Disable SVM by default in KVM mode Andreas Färber
2014-11-04 17:24 ` [Qemu-devel] [PULL v2 0/5] QOM CPUState patch queue 2014-11-04 Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).