Skip to contentSkip to conversation

i386: do not migrate MSR_SMI_COUNT on machine types <2.12

PATCH In review Paolo Bonzini 2 participants 3 messages Jul 24, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i386: do not migrate MSR_SMI_COUNT on machine types <2.12

MSR_SMI_COUNT started being migrated in QEMU 2.12. Do not migrate it on older machine types, or the subsection causes a load failure for guests that use SMM.

---
 include/hw/i386/pc.h  | 4 ++++
 target/i386/cpu.c     | 2 ++
 target/i386/cpu.h     | 1 +
 target/i386/machine.c | 2 +-
 4 files changed, 8 insertions(+), 1 deletion(-)
include/hw/i386/pc.h +4 -0
index 654003f44c..6894f37df1 100644
@@ -317,6 +317,10 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 #define PC_COMPAT_2_11 \
     HW_COMPAT_2_11 \
     {\
+        .driver   = TYPE_X86_CPU,\
+        .property = "x-migrate-smi-count",\
+        .value    = "off",\
+    },{\
         .driver   = "Skylake-Server" "-" TYPE_X86_CPU,\
         .property = "clflushopt",\
         .value    = "off",\
target/i386/cpu.c +2 -0
index e0e2f2eea1..92732ef1a0 100644
@@ -5435,6 +5435,8 @@ static Property x86_cpu_properties[] = {
                      false),
     DEFINE_PROP_BOOL("vmware-cpuid-freq", X86CPU, vmware_cpuid_freq, true),
     DEFINE_PROP_BOOL("tcg-cpuid", X86CPU, expose_tcg, true),
+    DEFINE_PROP_BOOL("x-migrate-smi-count", X86CPU, migrate_smi_count,
+                     false),
     /*
      * lecacy_cache defaults to true unless the CPU model provides its
      * own cache information (see x86_cpu_load_def()).
target/i386/cpu.h +1 -0
index 2c5a0d90a6..bcda6197a8 100644
@@ -1379,6 +1379,7 @@ struct X86CPU {
     bool expose_kvm;
     bool expose_tcg;
     bool migratable;
+    bool migrate_smi_count;
     bool max_features; /* Enable all supported features automatically */
     uint32_t apic_id;
 
target/i386/machine.c +1 -1
index 8b64dff487..084c2c73a8 100644
@@ -400,7 +400,7 @@ static bool msr_smi_count_needed(void *opaque)
     X86CPU *cpu = opaque;
     CPUX86State *env = &cpu->env;
 
-    return env->msr_smi_count != 0;
+    return cpu->migrate_smi_count && env->msr_smi_count != 0;
 }
 
 static const VMStateDescription vmstate_msr_smi_count = {
Signature · 1 line
2.17.1
#1 lore raw
Quoted 32 lines · * Paolo Bonzini ([email protected]) wrote:

MSR_SMI_COUNT started being migrated in QEMU 2.12. Do not migrate it on older machine types, or the subsection causes a load failure for guests that use SMM.

---
 include/hw/i386/pc.h  | 4 ++++
 target/i386/cpu.c     | 2 ++
 target/i386/cpu.h     | 1 +
 target/i386/machine.c | 2 +-
 4 files changed, 8 insertions(+), 1 deletion(-)
include/hw/i386/pc.h +4 -0
index 654003f44c..6894f37df1 100644
@@ -317,6 +317,10 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 #define PC_COMPAT_2_11 \
     HW_COMPAT_2_11 \
     {\
+        .driver   = TYPE_X86_CPU,\
+        .property = "x-migrate-smi-count",\
+        .value    = "off",\
+    },{\
         .driver   = "Skylake-Server" "-" TYPE_X86_CPU,\
         .property = "clflushopt",\
         .value    = "off",\
target/i386/cpu.c +0 -0
index e0e2f2eea1..92732ef1a0 100644

target/i386/cpu.c static Property x86_cpu_properties[] = { · line 5439

Quoted 5 lines
target/i386/cpu.c +2 -0
@@ -5435,6 +5435,8 @@ static Property x86_cpu_properties[] = {
                      false),
     DEFINE_PROP_BOOL("vmware-cpuid-freq", X86CPU, vmware_cpuid_freq, true),
     DEFINE_PROP_BOOL("tcg-cpuid", X86CPU, expose_tcg, true),
+    DEFINE_PROP_BOOL("x-migrate-smi-count", X86CPU, migrate_smi_count,
+                     false),

Shouldn't that be true?
(and then turned off in the compat)

Dave

Quoted 31 lines
target/i386/cpu.c +0 -0
     /*
      * lecacy_cache defaults to true unless the CPU model provides its
      * own cache information (see x86_cpu_load_def()).
target/i386/cpu.h +1 -0
index 2c5a0d90a6..bcda6197a8 100644
@@ -1379,6 +1379,7 @@ struct X86CPU {
     bool expose_kvm;
     bool expose_tcg;
     bool migratable;
+    bool migrate_smi_count;
     bool max_features; /* Enable all supported features automatically */
     uint32_t apic_id;
 
target/i386/machine.c +1 -1
index 8b64dff487..084c2c73a8 100644
@@ -400,7 +400,7 @@ static bool msr_smi_count_needed(void *opaque)
     X86CPU *cpu = opaque;
     CPUX86State *env = &cpu->env;
 
-    return env->msr_smi_count != 0;
+    return cpu->migrate_smi_count && env->msr_smi_count != 0;
 }
 
 static const VMStateDescription vmstate_msr_smi_count = {
Signature · 1 line
2.17.1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#2 lore raw
Quoted 4 lines · Dr. David Alan Gilbert

target/i386/cpu.c static Property x86_cpu_properties[] = { · line 5439

Quoted 2 lines
target/i386/cpu.c +2 -0
+    DEFINE_PROP_BOOL("x-migrate-smi-count", X86CPU, migrate_smi_count,
+                     false),

Shouldn't that be true?
(and then turned off in the compat)

Hrm of course. :)

Paolo