26ba25
From d625effaaebcc744531947209db5a4ec5aca0b0a Mon Sep 17 00:00:00 2001
26ba25
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
26ba25
Date: Fri, 14 Dec 2018 18:20:55 +0000
26ba25
Subject: [PATCH 3/5] i386: do not migrate MSR_SMI_COUNT on machine types <2.12
26ba25
26ba25
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
26ba25
Message-id: <20181214182056.20233-2-dgilbert@redhat.com>
26ba25
Patchwork-id: 83520
26ba25
O-Subject: [RHEL8 qemu-kvm PATCH 1/2] i386: do not migrate MSR_SMI_COUNT on machine types <2.12
26ba25
Bugzilla: 1659565
26ba25
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
26ba25
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
26ba25
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
26ba25
26ba25
From: Paolo Bonzini <pbonzini@redhat.com>
26ba25
26ba25
MSR_SMI_COUNT started being migrated in QEMU 2.12.  Do not migrate it
26ba25
on older machine types, or the subsection causes a load failure for
26ba25
guests that use SMM.
26ba25
26ba25
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
26ba25
(cherry picked from commit 990e0be2603511560168e1ad61f68294d951c39e)
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 include/hw/i386/pc.h  | 4 ++++
26ba25
 target/i386/cpu.c     | 2 ++
26ba25
 target/i386/cpu.h     | 1 +
26ba25
 target/i386/machine.c | 2 +-
26ba25
 4 files changed, 8 insertions(+), 1 deletion(-)
26ba25
26ba25
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
26ba25
index c29176d..dd473ca 100644
26ba25
--- a/include/hw/i386/pc.h
26ba25
+++ b/include/hw/i386/pc.h
26ba25
@@ -311,6 +311,10 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
26ba25
 #define PC_COMPAT_2_11 \
26ba25
     HW_COMPAT_2_11 \
26ba25
     {\
26ba25
+        .driver   = TYPE_X86_CPU,\
26ba25
+        .property = "x-migrate-smi-count",\
26ba25
+        .value    = "off",\
26ba25
+    },{\
26ba25
         .driver   = "Skylake-Server" "-" TYPE_X86_CPU,\
26ba25
         .property = "clflushopt",\
26ba25
         .value    = "off",\
26ba25
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
26ba25
index c37cd1e..c979feb 100644
26ba25
--- a/target/i386/cpu.c
26ba25
+++ b/target/i386/cpu.c
26ba25
@@ -5398,6 +5398,8 @@ static Property x86_cpu_properties[] = {
26ba25
                      false),
26ba25
     DEFINE_PROP_BOOL("vmware-cpuid-freq", X86CPU, vmware_cpuid_freq, true),
26ba25
     DEFINE_PROP_BOOL("tcg-cpuid", X86CPU, expose_tcg, true),
26ba25
+    DEFINE_PROP_BOOL("x-migrate-smi-count", X86CPU, migrate_smi_count,
26ba25
+                     true),
26ba25
     /*
26ba25
      * lecacy_cache defaults to true unless the CPU model provides its
26ba25
      * own cache information (see x86_cpu_load_def()).
26ba25
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
26ba25
index 58d5430..fb6caf4 100644
26ba25
--- a/target/i386/cpu.h
26ba25
+++ b/target/i386/cpu.h
26ba25
@@ -1369,6 +1369,7 @@ struct X86CPU {
26ba25
     bool expose_kvm;
26ba25
     bool expose_tcg;
26ba25
     bool migratable;
26ba25
+    bool migrate_smi_count;
26ba25
     bool max_features; /* Enable all supported features automatically */
26ba25
     uint32_t apic_id;
26ba25
 
26ba25
diff --git a/target/i386/machine.c b/target/i386/machine.c
26ba25
index 5e9a19b..2a85c91 100644
26ba25
--- a/target/i386/machine.c
26ba25
+++ b/target/i386/machine.c
26ba25
@@ -400,7 +400,7 @@ static bool msr_smi_count_needed(void *opaque)
26ba25
     X86CPU *cpu = opaque;
26ba25
     CPUX86State *env = &cpu->env;
26ba25
 
26ba25
-    return env->msr_smi_count != 0;
26ba25
+    return cpu->migrate_smi_count && env->msr_smi_count != 0;
26ba25
 }
26ba25
 
26ba25
 static const VMStateDescription vmstate_msr_smi_count = {
26ba25
-- 
26ba25
1.8.3.1
26ba25