22c213
From 113078b23a4747b07eb363719d7cbc0af403dd2a Mon Sep 17 00:00:00 2001
22c213
From: Miroslav Rezanina <mrezanin@redhat.com>
22c213
Date: Fri, 11 Jan 2019 09:54:45 +0100
22c213
Subject: Machine type related general changes
22c213
22c213
This patch is first part of original "Add RHEL machine types" patch we
22c213
split to allow easier review. It contains changes not related to any
22c213
architecture.
22c213
22c213
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
22c213
22c213
Rebase changes (4.0.0):
22c213
- Remove e1000 device duplication changes to reflect upstream solution
22c213
- Rewrite machine compat properties to upstream solution
22c213
22c213
Rebase changes (4.1.0):
22c213
- Removed optional flag for machine compat properties (upstream)
22c213
- Remove c3e002cb chunk from hw/net/e1000.c
22c213
- Reorder compat structures
22c213
- Use one format for compat scructures
22c213
- Added compat for virtio-balloon-pci.any_layout for rhel71
22c213
22c213
Merged patches (4.0.0):
22c213
- d4c0957 compat: Generic HW_COMPAT_RHEL7_6
22c213
- cbac773 virtio: Make disable-legacy/disable-modern compat properties optional
22c213
22c213
Merged patches (4.1.0):
22c213
- 479ad30 redhat: fix cut'n'paste garbage in hw_compat comments
22c213
- f19738e compat: Generic hw_compat_rhel_8_0
22c213
22c213
Merged patches (4.2.0):
22c213
- 9f2bfaa machine types: Update hw_compat_rhel_8_0 from hw_compat_4_0
22c213
- ca4a5e8 virtio: Make disable-legacy/disable-modern compat properties optional
22c213
- compat: Generic hw_compat_rhel_8_1 (patch 93040/92956)
22c213
22c213
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
22c213
---
22c213
 hw/acpi/ich9.c          |  16 ++++
22c213
 hw/acpi/piix4.c         |   5 +-
22c213
 hw/char/serial.c        |  16 ++++
22c213
 hw/core/machine.c       | 170 ++++++++++++++++++++++++++++++++++++++++
22c213
 hw/display/vga-isa.c    |   2 +-
22c213
 hw/net/e1000e.c         |  21 +++++
22c213
 hw/net/rtl8139.c        |   4 +-
22c213
 hw/rtc/mc146818rtc.c    |   6 ++
22c213
 hw/smbios/smbios.c      |   1 +
22c213
 hw/timer/i8254_common.c |   2 +-
22c213
 hw/usb/hcd-uhci.c       |   4 +-
22c213
 hw/usb/hcd-xhci.c       |  20 +++++
22c213
 hw/usb/hcd-xhci.h       |   2 +
22c213
 include/hw/acpi/ich9.h  |   3 +
22c213
 include/hw/boards.h     |  24 ++++++
22c213
 include/hw/usb.h        |   4 +
22c213
 migration/migration.c   |   2 +
22c213
 migration/migration.h   |   5 ++
22c213
 18 files changed, 301 insertions(+), 6 deletions(-)
22c213
22c213
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
22c213
index ab203ad448..7ec26884e8 100644
22c213
--- a/hw/acpi/ich9.c
22c213
+++ b/hw/acpi/ich9.c
22c213
@@ -444,6 +444,18 @@ static void ich9_pm_set_enable_tco(Object *obj, bool value, Error **errp)
22c213
     s->pm.enable_tco = value;
22c213
 }
22c213
 
22c213
+static bool ich9_pm_get_force_rev1_fadt(Object *obj, Error **errp)
22c213
+{
22c213
+    ICH9LPCState *s = ICH9_LPC_DEVICE(obj);
22c213
+    return s->pm.force_rev1_fadt;
22c213
+}
22c213
+
22c213
+static void ich9_pm_set_force_rev1_fadt(Object *obj, bool value, Error **errp)
22c213
+{
22c213
+    ICH9LPCState *s = ICH9_LPC_DEVICE(obj);
22c213
+    s->pm.force_rev1_fadt = value;
22c213
+}
22c213
+
22c213
 void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp)
22c213
 {
22c213
     static const uint32_t gpe0_len = ICH9_PMIO_GPE0_LEN;
22c213
@@ -468,6 +480,10 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp)
22c213
                              ich9_pm_get_cpu_hotplug_legacy,
22c213
                              ich9_pm_set_cpu_hotplug_legacy,
22c213
                              NULL);
22c213
+    object_property_add_bool(obj, "__com.redhat_force-rev1-fadt",
22c213
+                             ich9_pm_get_force_rev1_fadt,
22c213
+                             ich9_pm_set_force_rev1_fadt,
22c213
+                             NULL);
22c213
     object_property_add(obj, ACPI_PM_PROP_S3_DISABLED, "uint8",
22c213
                         ich9_pm_get_disable_s3,
22c213
                         ich9_pm_set_disable_s3,
22c213
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
22c213
index 93aec2dd2c..3a26193cbe 100644
22c213
--- a/hw/acpi/piix4.c
22c213
+++ b/hw/acpi/piix4.c
22c213
@@ -274,6 +274,7 @@ static const VMStateDescription vmstate_acpi = {
22c213
     .name = "piix4_pm",
22c213
     .version_id = 3,
22c213
     .minimum_version_id = 3,
22c213
+    .minimum_version_id = 2,
22c213
     .post_load = vmstate_acpi_post_load,
22c213
     .fields = (VMStateField[]) {
22c213
         VMSTATE_PCI_DEVICE(parent_obj, PIIX4PMState),
22c213
@@ -627,8 +628,8 @@ static void piix4_send_gpe(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
22c213
 
22c213
 static Property piix4_pm_properties[] = {
22c213
     DEFINE_PROP_UINT32("smb_io_base", PIIX4PMState, smb_io_base, 0),
22c213
-    DEFINE_PROP_UINT8(ACPI_PM_PROP_S3_DISABLED, PIIX4PMState, disable_s3, 0),
22c213
-    DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_DISABLED, PIIX4PMState, disable_s4, 0),
22c213
+    DEFINE_PROP_UINT8(ACPI_PM_PROP_S3_DISABLED, PIIX4PMState, disable_s3, 1),
22c213
+    DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_DISABLED, PIIX4PMState, disable_s4, 1),
22c213
     DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
22c213
     DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support", PIIX4PMState,
22c213
                      use_acpi_pci_hotplug, true),
22c213
diff --git a/hw/char/serial.c b/hw/char/serial.c
22c213
index b4aa250950..0012f0e44d 100644
22c213
--- a/hw/char/serial.c
22c213
+++ b/hw/char/serial.c
22c213
@@ -34,6 +34,7 @@
22c213
 #include "sysemu/runstate.h"
22c213
 #include "qemu/error-report.h"
22c213
 #include "trace.h"
22c213
+#include "migration/migration.h"
22c213
 
22c213
 //#define DEBUG_SERIAL
22c213
 
22c213
@@ -703,6 +704,9 @@ static int serial_post_load(void *opaque, int version_id)
22c213
 static bool serial_thr_ipending_needed(void *opaque)
22c213
 {
22c213
     SerialState *s = opaque;
22c213
+    if (migrate_pre_2_2) {
22c213
+        return false;
22c213
+    }
22c213
 
22c213
     if (s->ier & UART_IER_THRI) {
22c213
         bool expected_value = ((s->iir & UART_IIR_ID) == UART_IIR_THRI);
22c213
@@ -784,6 +788,10 @@ static const VMStateDescription vmstate_serial_xmit_fifo = {
22c213
 static bool serial_fifo_timeout_timer_needed(void *opaque)
22c213
 {
22c213
     SerialState *s = (SerialState *)opaque;
22c213
+    if (migrate_pre_2_2) {
22c213
+        return false;
22c213
+    }
22c213
+
22c213
     return timer_pending(s->fifo_timeout_timer);
22c213
 }
22c213
 
22c213
@@ -801,6 +809,10 @@ static const VMStateDescription vmstate_serial_fifo_timeout_timer = {
22c213
 static bool serial_timeout_ipending_needed(void *opaque)
22c213
 {
22c213
     SerialState *s = (SerialState *)opaque;
22c213
+    if (migrate_pre_2_2) {
22c213
+        return false;
22c213
+    }
22c213
+
22c213
     return s->timeout_ipending != 0;
22c213
 }
22c213
 
22c213
@@ -818,6 +830,10 @@ static const VMStateDescription vmstate_serial_timeout_ipending = {
22c213
 static bool serial_poll_needed(void *opaque)
22c213
 {
22c213
     SerialState *s = (SerialState *)opaque;
22c213
+    if (migrate_pre_2_2) {
22c213
+        return false;
22c213
+    }
22c213
+
22c213
     return s->poll_msl >= 0;
22c213
 }
22c213
 
22c213
diff --git a/hw/core/machine.c b/hw/core/machine.c
22c213
index 1689ad3bf8..e0e0eec8bf 100644
22c213
--- a/hw/core/machine.c
22c213
+++ b/hw/core/machine.c
22c213
@@ -27,6 +27,176 @@
22c213
 #include "hw/pci/pci.h"
22c213
 #include "hw/mem/nvdimm.h"
22c213
 
22c213
+/*
22c213
+ * The same as hw_compat_4_1
22c213
+ */
22c213
+GlobalProperty hw_compat_rhel_8_1[] = {
22c213
+    /* hw_compat_rhel_8_1 from hw_compat_4_1 */
22c213
+    { "virtio-pci", "x-pcie-flr-init", "off" },
22c213
+};
22c213
+const size_t hw_compat_rhel_8_1_len = G_N_ELEMENTS(hw_compat_rhel_8_1);
22c213
+
22c213
+/* The same as hw_compat_3_1
22c213
+ * format of array has been changed by:
22c213
+ *     6c36bddf5340 ("machine: Use shorter format for GlobalProperty arrays")
22c213
+ */
22c213
+GlobalProperty hw_compat_rhel_8_0[] = {
22c213
+    /* hw_compat_rhel_8_0 from hw_compat_3_1 */
22c213
+    { "pcie-root-port", "x-speed", "2_5" },
22c213
+    /* hw_compat_rhel_8_0 from hw_compat_3_1 */
22c213
+    { "pcie-root-port", "x-width", "1" },
22c213
+    /* hw_compat_rhel_8_0 from hw_compat_3_1 */
22c213
+    { "memory-backend-file", "x-use-canonical-path-for-ramblock-id", "true" },
22c213
+    /* hw_compat_rhel_8_0 from hw_compat_3_1 */
22c213
+    { "memory-backend-memfd", "x-use-canonical-path-for-ramblock-id", "true" },
22c213
+    /* hw_compat_rhel_8_0 from hw_compat_3_1 */
22c213
+    { "tpm-crb", "ppi", "false" },
22c213
+    /* hw_compat_rhel_8_0 from hw_compat_3_1 */
22c213
+    { "tpm-tis", "ppi", "false" },
22c213
+    /* hw_compat_rhel_8_0 from hw_compat_3_1 */
22c213
+    { "usb-kbd", "serial", "42" },
22c213
+    /* hw_compat_rhel_8_0 from hw_compat_3_1 */
22c213
+    { "usb-mouse", "serial", "42" },
22c213
+    /* hw_compat_rhel_8_0 from hw_compat_3_1 */
22c213
+    { "usb-tablet", "serial", "42" },
22c213
+    /* hw_compat_rhel_8_0 from hw_compat_3_1 */
22c213
+    { "virtio-blk-device", "discard", "false" },
22c213
+    /* hw_compat_rhel_8_0 from hw_compat_3_1 */
22c213
+    { "virtio-blk-device", "write-zeroes", "false" },
22c213
+    /* hw_compat_rhel_8_0 from hw_compat_4_0 */
22c213
+    { "VGA",            "edid", "false" },
22c213
+    /* hw_compat_rhel_8_0 from hw_compat_4_0 */
22c213
+    { "secondary-vga",  "edid", "false" },
22c213
+    /* hw_compat_rhel_8_0 from hw_compat_4_0 */
22c213
+    { "bochs-display",  "edid", "false" },
22c213
+    /* hw_compat_rhel_8_0 from hw_compat_4_0 */
22c213
+    { "virtio-vga",     "edid", "false" },
22c213
+    /* hw_compat_rhel_8_0 from hw_compat_4_0 */
22c213
+    { "virtio-gpu-pci", "edid", "false" },
22c213
+    /* hw_compat_rhel_8_0 from hw_compat_4_0 */
22c213
+    { "virtio-device", "use-started", "false" },
22c213
+    /* hw_compat_rhel_8_0 from hw_compat_3_1 - that was added in 4.1 */
22c213
+    { "pcie-root-port-base", "disable-acs", "true" },
22c213
+};
22c213
+const size_t hw_compat_rhel_8_0_len = G_N_ELEMENTS(hw_compat_rhel_8_0);
22c213
+
22c213
+/* The same as hw_compat_3_0 + hw_compat_2_12
22c213
+ * except that
22c213
+ *   there's nothing in 3_0
22c213
+ *   migration.decompress-error-check=off was in 7.5 from bz 1584139
22c213
+ */
22c213
+GlobalProperty hw_compat_rhel_7_6[] = {
22c213
+    /* hw_compat_rhel_7_6 from hw_compat_2_12 */
22c213
+    { "hda-audio", "use-timer", "false" },
22c213
+    /* hw_compat_rhel_7_6 from hw_compat_2_12 */
22c213
+    { "cirrus-vga", "global-vmstate", "true" },
22c213
+    /* hw_compat_rhel_7_6 from hw_compat_2_12 */
22c213
+    { "VGA", "global-vmstate", "true" },
22c213
+    /* hw_compat_rhel_7_6 from hw_compat_2_12 */
22c213
+    { "vmware-svga", "global-vmstate", "true" },
22c213
+    /* hw_compat_rhel_7_6 from hw_compat_2_12 */
22c213
+    { "qxl-vga", "global-vmstate",  "true" },
22c213
+};
22c213
+const size_t hw_compat_rhel_7_6_len = G_N_ELEMENTS(hw_compat_rhel_7_6);
22c213
+
22c213
+/* The same as hw_compat_2_11 + hw_compat_2_10 */
22c213
+GlobalProperty hw_compat_rhel_7_5[] = {
22c213
+    /* hw_compat_rhel_7_5 from hw_compat_2_11 */
22c213
+    { "hpet", "hpet-offset-saved", "false" },
22c213
+    /* hw_compat_rhel_7_5 from hw_compat_2_11 */
22c213
+    { "virtio-blk-pci", "vectors", "2" },
22c213
+    /* hw_compat_rhel_7_5 from hw_compat_2_11 */
22c213
+    { "vhost-user-blk-pci", "vectors", "2" },
22c213
+    /* hw_compat_rhel_7_5 from hw_compat_2_11
22c213
+       bz 1608778 modified for our naming */
22c213
+    { "e1000-82540em", "migrate_tso_props", "off" },
22c213
+    /* hw_compat_rhel_7_5 from hw_compat_2_10 */
22c213
+    { "virtio-mouse-device", "wheel-axis", "false" },
22c213
+    /* hw_compat_rhel_7_5 from hw_compat_2_10 */
22c213
+    { "virtio-tablet-device", "wheel-axis", "false" },
22c213
+    { "cirrus-vga", "vgamem_mb", "16" },
22c213
+    { "migration", "decompress-error-check", "off" },
22c213
+};
22c213
+const size_t hw_compat_rhel_7_5_len = G_N_ELEMENTS(hw_compat_rhel_7_5);
22c213
+
22c213
+/* Mostly like hw_compat_2_9 except
22c213
+ * x-mtu-bypass-backend, x-migrate-msix has already been
22c213
+ * backported to RHEL7.4. shpc was already on in 7.4.
22c213
+ */
22c213
+GlobalProperty hw_compat_rhel_7_4[] = {
22c213
+    { "intel-iommu", "pt", "off" },
22c213
+};
22c213
+
22c213
+const size_t hw_compat_rhel_7_4_len = G_N_ELEMENTS(hw_compat_rhel_7_4);
22c213
+/* Mostly like HW_COMPAT_2_6 + HW_COMPAT_2_7 + HW_COMPAT_2_8 except
22c213
+ * disable-modern, disable-legacy, page-per-vq have already been
22c213
+ * backported to RHEL7.3
22c213
+ */
22c213
+GlobalProperty hw_compat_rhel_7_3[] = {
22c213
+    { "virtio-mmio", "format_transport_address", "off" },
22c213
+    { "virtio-serial-device", "emergency-write", "off" },
22c213
+    { "ioapic", "version", "0x11" },
22c213
+    { "intel-iommu", "x-buggy-eim", "true" },
22c213
+    { "virtio-pci", "x-ignore-backend-features", "on" },
22c213
+    { "fw_cfg_mem", "x-file-slots", stringify(0x10) },
22c213
+    { "fw_cfg_io", "x-file-slots", stringify(0x10) },
22c213
+    { "pflash_cfi01", "old-multiple-chip-handling", "on" },
22c213
+    { TYPE_PCI_DEVICE, "x-pcie-extcap-init", "off" },
22c213
+    { "virtio-pci", "x-pcie-deverr-init", "off" },
22c213
+    { "virtio-pci", "x-pcie-lnkctl-init", "off" },
22c213
+    { "virtio-pci", "x-pcie-pm-init", "off" },
22c213
+    { "virtio-net-device", "x-mtu-bypass-backend", "off" },
22c213
+    { "e1000e", "__redhat_e1000e_7_3_intr_state", "on" },
22c213
+};
22c213
+const size_t hw_compat_rhel_7_3_len = G_N_ELEMENTS(hw_compat_rhel_7_3);
22c213
+
22c213
+/* Mostly like hw_compat_2_4 + 2_3 but:
22c213
+ *  we don't need "any_layout" as it has been backported to 7.2
22c213
+ */
22c213
+GlobalProperty hw_compat_rhel_7_2[] = {
22c213
+        { "virtio-blk-device", "scsi", "true" },
22c213
+        { "e1000-82540em", "extra_mac_registers", "off" },
22c213
+        { "virtio-pci", "x-disable-pcie", "on" },
22c213
+        { "virtio-pci", "migrate-extra", "off" },
22c213
+        { "fw_cfg_mem", "dma_enabled", "off" },
22c213
+        { "fw_cfg_io", "dma_enabled", "off" },
22c213
+        { "isa-fdc", "fallback", "144" },
22c213
+        /* Optional because not all virtio-pci devices support legacy mode */
22c213
+        { "virtio-pci", "disable-modern", "on", .optional = true },
22c213
+        { "virtio-pci", "disable-legacy", "off", .optional = true },
22c213
+        { TYPE_PCI_DEVICE, "x-pcie-lnksta-dllla", "off" },
22c213
+        { "virtio-pci", "page-per-vq", "on" },
22c213
+        /* hw_compat_rhel_7_2 - introduced with 2.10.0 */
22c213
+        { "migration", "send-section-footer", "off" },
22c213
+        /* hw_compat_rhel_7_2 - introduced with 2.10.0 */
22c213
+        { "migration", "store-global-state", "off",
22c213
+        },
22c213
+};
22c213
+const size_t hw_compat_rhel_7_2_len = G_N_ELEMENTS(hw_compat_rhel_7_2);
22c213
+
22c213
+/* Mostly like hw_compat_2_1 but:
22c213
+ *    we don't need virtio-scsi-pci since 7.0 already had that on
22c213
+ *
22c213
+ * RH: Note, qemu-extended-regs should have been enabled in the 7.1
22c213
+ * machine type, but was accidentally turned off in 7.2 onwards.
22c213
+ */
22c213
+GlobalProperty hw_compat_rhel_7_1[] = {
22c213
+    { "intel-hda-generic", "old_msi_addr", "on" },
22c213
+    { "VGA", "qemu-extended-regs", "off" },
22c213
+    { "secondary-vga", "qemu-extended-regs", "off" },
22c213
+    { "usb-mouse", "usb_version", stringify(1) },
22c213
+    { "usb-kbd", "usb_version", stringify(1) },
22c213
+    { "virtio-pci",  "virtio-pci-bus-master-bug-migration", "on" },
22c213
+    { "virtio-blk-pci", "any_layout", "off" },
22c213
+    { "virtio-balloon-pci", "any_layout", "off" },
22c213
+    { "virtio-serial-pci", "any_layout", "off" },
22c213
+    { "virtio-9p-pci", "any_layout", "off" },
22c213
+    { "virtio-rng-pci", "any_layout", "off" },
22c213
+    /* HW_COMPAT_RHEL7_1 - introduced with 2.10.0 */
22c213
+    { "migration", "send-configuration", "off" },
22c213
+};
22c213
+const size_t hw_compat_rhel_7_1_len = G_N_ELEMENTS(hw_compat_rhel_7_1);
22c213
+
22c213
 GlobalProperty hw_compat_4_1[] = {
22c213
     { "virtio-pci", "x-pcie-flr-init", "off" },
22c213
 };
22c213
diff --git a/hw/display/vga-isa.c b/hw/display/vga-isa.c
22c213
index 873e5e9706..d1a2efe47e 100644
22c213
--- a/hw/display/vga-isa.c
22c213
+++ b/hw/display/vga-isa.c
22c213
@@ -82,7 +82,7 @@ static void vga_isa_realizefn(DeviceState *dev, Error **errp)
22c213
 }
22c213
 
22c213
 static Property vga_isa_properties[] = {
22c213
-    DEFINE_PROP_UINT32("vgamem_mb", ISAVGAState, state.vram_size_mb, 8),
22c213
+    DEFINE_PROP_UINT32("vgamem_mb", ISAVGAState, state.vram_size_mb, 16),
22c213
     DEFINE_PROP_END_OF_LIST(),
22c213
 };
22c213
 
22c213
diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c
22c213
index b69fd7d8ad..d8be50a1ce 100644
22c213
--- a/hw/net/e1000e.c
22c213
+++ b/hw/net/e1000e.c
22c213
@@ -79,6 +79,11 @@ typedef struct E1000EState {
22c213
 
22c213
     E1000ECore core;
22c213
 
22c213
+    /* 7.3 had the intr_state field that was in the original e1000e code
22c213
+     * but that was removed prior to 2.7's release
22c213
+     */
22c213
+    bool redhat_7_3_intr_state_enable;
22c213
+    uint32_t redhat_7_3_intr_state;
22c213
 } E1000EState;
22c213
 
22c213
 #define E1000E_MMIO_IDX     0
22c213
@@ -94,6 +99,10 @@ typedef struct E1000EState {
22c213
 #define E1000E_MSIX_TABLE   (0x0000)
22c213
 #define E1000E_MSIX_PBA     (0x2000)
22c213
 
22c213
+/* Values as in RHEL 7.3 build and original upstream */
22c213
+#define RH_E1000E_USE_MSI     BIT(0)
22c213
+#define RH_E1000E_USE_MSIX    BIT(1)
22c213
+
22c213
 static uint64_t
22c213
 e1000e_mmio_read(void *opaque, hwaddr addr, unsigned size)
22c213
 {
22c213
@@ -305,6 +314,8 @@ e1000e_init_msix(E1000EState *s)
22c213
     } else {
22c213
         if (!e1000e_use_msix_vectors(s, E1000E_MSIX_VEC_NUM)) {
22c213
             msix_uninit(d, &s->msix, &s->msix);
22c213
+        } else {
22c213
+            s->redhat_7_3_intr_state |= RH_E1000E_USE_MSIX;
22c213
         }
22c213
     }
22c213
 }
22c213
@@ -476,6 +487,8 @@ static void e1000e_pci_realize(PCIDevice *pci_dev, Error **errp)
22c213
     ret = msi_init(PCI_DEVICE(s), 0xD0, 1, true, false, NULL);
22c213
     if (ret) {
22c213
         trace_e1000e_msi_init_fail(ret);
22c213
+    } else {
22c213
+        s->redhat_7_3_intr_state |= RH_E1000E_USE_MSI;
22c213
     }
22c213
 
22c213
     if (e1000e_add_pm_capability(pci_dev, e1000e_pmrb_offset,
22c213
@@ -599,6 +612,11 @@ static const VMStateDescription e1000e_vmstate_intr_timer = {
22c213
     VMSTATE_STRUCT_ARRAY(_f, _s, _num, 0,                           \
22c213
                          e1000e_vmstate_intr_timer, E1000IntrDelayTimer)
22c213
 
22c213
+static bool rhel_7_3_check(void *opaque, int version_id)
22c213
+{
22c213
+    return ((E1000EState *)opaque)->redhat_7_3_intr_state_enable;
22c213
+}
22c213
+
22c213
 static const VMStateDescription e1000e_vmstate = {
22c213
     .name = "e1000e",
22c213
     .version_id = 1,
22c213
@@ -610,6 +628,7 @@ static const VMStateDescription e1000e_vmstate = {
22c213
         VMSTATE_MSIX(parent_obj, E1000EState),
22c213
 
22c213
         VMSTATE_UINT32(ioaddr, E1000EState),
22c213
+        VMSTATE_UINT32_TEST(redhat_7_3_intr_state, E1000EState, rhel_7_3_check),
22c213
         VMSTATE_UINT32(core.rxbuf_min_shift, E1000EState),
22c213
         VMSTATE_UINT8(core.rx_desc_len, E1000EState),
22c213
         VMSTATE_UINT32_ARRAY(core.rxbuf_sizes, E1000EState,
22c213
@@ -658,6 +677,8 @@ static PropertyInfo e1000e_prop_disable_vnet,
22c213
 
22c213
 static Property e1000e_properties[] = {
22c213
     DEFINE_NIC_PROPERTIES(E1000EState, conf),
22c213
+    DEFINE_PROP_BOOL("__redhat_e1000e_7_3_intr_state", E1000EState,
22c213
+                        redhat_7_3_intr_state_enable, false),
22c213
     DEFINE_PROP_SIGNED("disable_vnet_hdr", E1000EState, disable_vnet, false,
22c213
                         e1000e_prop_disable_vnet, bool),
22c213
     DEFINE_PROP_SIGNED("subsys_ven", E1000EState, subsys_ven,
22c213
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
22c213
index 88a97d756d..21d80e96cf 100644
22c213
--- a/hw/net/rtl8139.c
22c213
+++ b/hw/net/rtl8139.c
22c213
@@ -3177,7 +3177,7 @@ static int rtl8139_pre_save(void *opaque)
22c213
 
22c213
 static const VMStateDescription vmstate_rtl8139 = {
22c213
     .name = "rtl8139",
22c213
-    .version_id = 5,
22c213
+    .version_id = 4,
22c213
     .minimum_version_id = 3,
22c213
     .post_load = rtl8139_post_load,
22c213
     .pre_save  = rtl8139_pre_save,
22c213
@@ -3258,7 +3258,9 @@ static const VMStateDescription vmstate_rtl8139 = {
22c213
         VMSTATE_UINT32(tally_counters.TxMCol, RTL8139State),
22c213
         VMSTATE_UINT64(tally_counters.RxOkPhy, RTL8139State),
22c213
         VMSTATE_UINT64(tally_counters.RxOkBrd, RTL8139State),
22c213
+#if 0 /* Disabled for Red Hat Enterprise Linux bz 1420195 */
22c213
         VMSTATE_UINT32_V(tally_counters.RxOkMul, RTL8139State, 5),
22c213
+#endif
22c213
         VMSTATE_UINT16(tally_counters.TxAbt, RTL8139State),
22c213
         VMSTATE_UINT16(tally_counters.TxUndrn, RTL8139State),
22c213
 
22c213
diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c
22c213
index 74ae74bc5c..73820517df 100644
22c213
--- a/hw/rtc/mc146818rtc.c
22c213
+++ b/hw/rtc/mc146818rtc.c
22c213
@@ -42,6 +42,7 @@
22c213
 #include "qapi/visitor.h"
22c213
 #include "exec/address-spaces.h"
22c213
 #include "hw/rtc/mc146818rtc_regs.h"
22c213
+#include "migration/migration.h"
22c213
 
22c213
 #ifdef TARGET_I386
22c213
 #include "qapi/qapi-commands-misc-target.h"
22c213
@@ -820,6 +821,11 @@ static int rtc_post_load(void *opaque, int version_id)
22c213
 static bool rtc_irq_reinject_on_ack_count_needed(void *opaque)
22c213
 {
22c213
     RTCState *s = (RTCState *)opaque;
22c213
+
22c213
+    if (migrate_pre_2_2) {
22c213
+        return false;
22c213
+    }
22c213
+
22c213
     return s->irq_reinject_on_ack_count != 0;
22c213
 }
22c213
 
22c213
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
22c213
index 11d476c4a2..e6e9355384 100644
22c213
--- a/hw/smbios/smbios.c
22c213
+++ b/hw/smbios/smbios.c
22c213
@@ -777,6 +777,7 @@ void smbios_set_defaults(const char *manufacturer, const char *product,
22c213
     SMBIOS_SET_DEFAULT(type1.manufacturer, manufacturer);
22c213
     SMBIOS_SET_DEFAULT(type1.product, product);
22c213
     SMBIOS_SET_DEFAULT(type1.version, version);
22c213
+    SMBIOS_SET_DEFAULT(type1.family, "Red Hat Enterprise Linux");
22c213
     SMBIOS_SET_DEFAULT(type2.manufacturer, manufacturer);
22c213
     SMBIOS_SET_DEFAULT(type2.product, product);
22c213
     SMBIOS_SET_DEFAULT(type2.version, version);
22c213
diff --git a/hw/timer/i8254_common.c b/hw/timer/i8254_common.c
22c213
index 050875b497..32935da46c 100644
22c213
--- a/hw/timer/i8254_common.c
22c213
+++ b/hw/timer/i8254_common.c
22c213
@@ -231,7 +231,7 @@ static const VMStateDescription vmstate_pit_common = {
22c213
     .pre_save = pit_dispatch_pre_save,
22c213
     .post_load = pit_dispatch_post_load,
22c213
     .fields = (VMStateField[]) {
22c213
-        VMSTATE_UINT32_V(channels[0].irq_disabled, PITCommonState, 3),
22c213
+        VMSTATE_UINT32(channels[0].irq_disabled, PITCommonState), /* qemu-kvm's v2 had 'flags' here */
22c213
         VMSTATE_STRUCT_ARRAY(channels, PITCommonState, 3, 2,
22c213
                              vmstate_pit_channel, PITChannelState),
22c213
         VMSTATE_INT64(channels[0].next_transition_time,
22c213
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
22c213
index 23507ad3b5..9fd87a7ad9 100644
22c213
--- a/hw/usb/hcd-uhci.c
22c213
+++ b/hw/usb/hcd-uhci.c
22c213
@@ -1219,12 +1219,14 @@ static void usb_uhci_common_realize(PCIDevice *dev, Error **errp)
22c213
     UHCIState *s = UHCI(dev);
22c213
     uint8_t *pci_conf = s->dev.config;
22c213
     int i;
22c213
+    int irq_pin;
22c213
 
22c213
     pci_conf[PCI_CLASS_PROG] = 0x00;
22c213
     /* TODO: reset value should be 0. */
22c213
     pci_conf[USB_SBRN] = USB_RELEASE_1; // release number
22c213
 
22c213
-    pci_config_set_interrupt_pin(pci_conf, u->info.irq_pin + 1);
22c213
+    irq_pin = u->info.irq_pin;
22c213
+    pci_config_set_interrupt_pin(pci_conf, irq_pin + 1);
22c213
 
22c213
     if (s->masterbus) {
22c213
         USBPort *ports[NB_PORTS];
22c213
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
22c213
index 80988bb305..8fed2eedd6 100644
22c213
--- a/hw/usb/hcd-xhci.c
22c213
+++ b/hw/usb/hcd-xhci.c
22c213
@@ -3590,9 +3590,27 @@ static const VMStateDescription vmstate_xhci_slot = {
22c213
     }
22c213
 };
22c213
 
22c213
+static int xhci_event_pre_save(void *opaque)
22c213
+{
22c213
+    XHCIEvent *s = opaque;
22c213
+
22c213
+    s->cve_2014_5263_a = ((uint8_t *)&s->type)[0];
22c213
+    s->cve_2014_5263_b = ((uint8_t *)&s->type)[1];
22c213
+
22c213
+    return 0;
22c213
+}
22c213
+
22c213
+bool migrate_cve_2014_5263_xhci_fields;
22c213
+
22c213
+static bool xhci_event_cve_2014_5263(void *opaque, int version_id)
22c213
+{
22c213
+    return migrate_cve_2014_5263_xhci_fields;
22c213
+}
22c213
+
22c213
 static const VMStateDescription vmstate_xhci_event = {
22c213
     .name = "xhci-event",
22c213
     .version_id = 1,
22c213
+    .pre_save = xhci_event_pre_save,
22c213
     .fields = (VMStateField[]) {
22c213
         VMSTATE_UINT32(type,   XHCIEvent),
22c213
         VMSTATE_UINT32(ccode,  XHCIEvent),
22c213
@@ -3601,6 +3619,8 @@ static const VMStateDescription vmstate_xhci_event = {
22c213
         VMSTATE_UINT32(flags,  XHCIEvent),
22c213
         VMSTATE_UINT8(slotid,  XHCIEvent),
22c213
         VMSTATE_UINT8(epid,    XHCIEvent),
22c213
+        VMSTATE_UINT8_TEST(cve_2014_5263_a, XHCIEvent, xhci_event_cve_2014_5263),
22c213
+        VMSTATE_UINT8_TEST(cve_2014_5263_b, XHCIEvent, xhci_event_cve_2014_5263),
22c213
         VMSTATE_END_OF_LIST()
22c213
     }
22c213
 };
22c213
diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h
22c213
index 2fad4df2a7..f554b671e3 100644
22c213
--- a/hw/usb/hcd-xhci.h
22c213
+++ b/hw/usb/hcd-xhci.h
22c213
@@ -157,6 +157,8 @@ typedef struct XHCIEvent {
22c213
     uint32_t flags;
22c213
     uint8_t slotid;
22c213
     uint8_t epid;
22c213
+    uint8_t cve_2014_5263_a;
22c213
+    uint8_t cve_2014_5263_b;
22c213
 } XHCIEvent;
22c213
 
22c213
 typedef struct XHCIInterrupter {
22c213
diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
22c213
index 41568d1837..1a23ccc412 100644
22c213
--- a/include/hw/acpi/ich9.h
22c213
+++ b/include/hw/acpi/ich9.h
22c213
@@ -61,6 +61,9 @@ typedef struct ICH9LPCPMRegs {
22c213
     uint8_t smm_enabled;
22c213
     bool enable_tco;
22c213
     TCOIORegs tco_regs;
22c213
+
22c213
+    /* RH addition, see bz 1489800 */
22c213
+    bool force_rev1_fadt;
22c213
 } ICH9LPCPMRegs;
22c213
 
22c213
 #define ACPI_PM_PROP_TCO_ENABLED "enable_tco"
22c213
diff --git a/include/hw/boards.h b/include/hw/boards.h
22c213
index de45087f34..6f85a0e032 100644
22c213
--- a/include/hw/boards.h
22c213
+++ b/include/hw/boards.h
22c213
@@ -377,4 +377,28 @@ extern const size_t hw_compat_2_2_len;
22c213
 extern GlobalProperty hw_compat_2_1[];
22c213
 extern const size_t hw_compat_2_1_len;
22c213
 
22c213
+extern GlobalProperty hw_compat_rhel_8_1[];
22c213
+extern const size_t hw_compat_rhel_8_1_len;
22c213
+
22c213
+extern GlobalProperty hw_compat_rhel_8_0[];
22c213
+extern const size_t hw_compat_rhel_8_0_len;
22c213
+
22c213
+extern GlobalProperty hw_compat_rhel_7_6[];
22c213
+extern const size_t hw_compat_rhel_7_6_len;
22c213
+
22c213
+extern GlobalProperty hw_compat_rhel_7_5[];
22c213
+extern const size_t hw_compat_rhel_7_5_len;
22c213
+
22c213
+extern GlobalProperty hw_compat_rhel_7_4[];
22c213
+extern const size_t hw_compat_rhel_7_4_len;
22c213
+
22c213
+extern GlobalProperty hw_compat_rhel_7_3[];
22c213
+extern const size_t hw_compat_rhel_7_3_len;
22c213
+
22c213
+extern GlobalProperty hw_compat_rhel_7_2[];
22c213
+extern const size_t hw_compat_rhel_7_2_len;
22c213
+
22c213
+extern GlobalProperty hw_compat_rhel_7_1[];
22c213
+extern const size_t hw_compat_rhel_7_1_len;
22c213
+
22c213
 #endif
22c213
diff --git a/include/hw/usb.h b/include/hw/usb.h
22c213
index c24d968a19..b353438ea0 100644
22c213
--- a/include/hw/usb.h
22c213
+++ b/include/hw/usb.h
22c213
@@ -605,4 +605,8 @@ int usb_get_quirks(uint16_t vendor_id, uint16_t product_id,
22c213
                    uint8_t interface_class, uint8_t interface_subclass,
22c213
                    uint8_t interface_protocol);
22c213
 
22c213
+
22c213
+/* hcd-xhci.c -- rhel7.0.0 machine type compatibility */
22c213
+extern bool migrate_cve_2014_5263_xhci_fields;
22c213
+
22c213
 #endif
22c213
diff --git a/migration/migration.c b/migration/migration.c
22c213
index 354ad072fa..30c53c623b 100644
22c213
--- a/migration/migration.c
22c213
+++ b/migration/migration.c
22c213
@@ -121,6 +121,8 @@ enum mig_rp_message_type {
22c213
     MIG_RP_MSG_MAX
22c213
 };
22c213
 
22c213
+bool migrate_pre_2_2;
22c213
+
22c213
 /* When we add fault tolerance, we could have several
22c213
    migrations at once.  For now we don't need to add
22c213
    dynamic creation of migration */
22c213
diff --git a/migration/migration.h b/migration/migration.h
22c213
index 79b3dda146..0b1b0d4df5 100644
22c213
--- a/migration/migration.h
22c213
+++ b/migration/migration.h
22c213
@@ -335,6 +335,11 @@ void init_dirty_bitmap_incoming_migration(void);
22c213
 void migrate_add_address(SocketAddress *address);
22c213
 
22c213
 int foreach_not_ignored_block(RAMBlockIterFunc func, void *opaque);
22c213
+/*
22c213
+ * Disables a load of subsections that were added in 2.2/rh7.2 for backwards
22c213
+ * migration compatibility.
22c213
+ */
22c213
+extern bool migrate_pre_2_2;
22c213
 
22c213
 #define qemu_ram_foreach_block \
22c213
   #warning "Use foreach_not_ignored_block in migration code"
22c213
-- 
22c213
2.21.0
22c213