Skip to contentSkip to conversation

pc migration fixes

GIT PULL Applied Michael S. Tsirkin 2 participants 10 messages Jul 29, 2014

lore
Share & tools
lore
#0 lore raw

The following changes since commit c60a57ff497667780132a3fcdc1500c83af5d5c0:

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2014-07-25 16:58:41 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to f47337cb9181a1f9339b9b0516b92fe77a22f0f3:

piix: set legacy table size for 1.7 (2014-07-29 12:26:12 +0200)

----------------------------------------------------------------
pc migration fixes

Last minute fixes for migration.
It seems that if we don't fix it now, fixing it in the next version will be even more painful ...

----------------------------------------------------------------
Igor Mammedov (1):
pc: acpi: generate AML only for PCI0 devices if PCI bridge hotplug is disabled

Michael S. Tsirkin (3):
acpi-build: minor code cleanup
acpi-build: tweak acpi migration limits
piix: set legacy table size for 1.7

Paolo Bonzini (4):
acpi-dsdt: procedurally generate _PRT
pc: hack for migration compatibility from QEMU 2.0
bios-tables-test: fix ASL normalization false positive
pc: future-proof migration-compatibility of ACPI tables

 include/hw/i386/pc.h            |    1 +
 hw/i386/acpi-build.c            |   99 +-
 hw/i386/pc_piix.c               |   20 +
 hw/i386/pc_q35.c                |    5 +
 tests/bios-tables-test.c        |    6 +-
 hw/i386/acpi-dsdt.dsl           |   90 +-
 hw/i386/acpi-dsdt.hex.generated | 1910 +++------------------------------------
 tests/acpi-test-data/pc/DSDT    |  Bin 4499 -> 2807 bytes
 8 files changed, 269 insertions(+), 1862 deletions(-)
#1 lore raw

[Qemu-devel] [PULL 1/8] acpi-dsdt: procedurally generate _PRT

From: Paolo Bonzini <[email protected]>

This replaces the _PRT constant with a method that computes it.

The problem is that the DSDT+SSDT have grown from 2.0 to 2.1, enough to cross the 8k barrier (we align the ACPI tables to 4k before putting them in fw_cfg). This causes problems with migration and the pc-i440fx-2.0 machine type.

The solution to the problem is to hardcode 64k as the limit, but this doesn't solve the bug with pc-i440fx-2.0. The fix will be for QEMU 2.1 to use exactly the same size as QEMU 2.0 for the ACPI tables. First, however, we must make the actual AML equal or smaller; to do this, rewrite _PRT in a way that saves over 1k of bytecode.

---
 hw/i386/acpi-dsdt.dsl           |   90 +-
 hw/i386/acpi-dsdt.hex.generated | 1910 +++------------------------------------
 tests/acpi-test-data/pc/DSDT    |  Bin 4499 -> 2807 bytes
 3 files changed, 148 insertions(+), 1852 deletions(-)
hw/i386/acpi-dsdt.dsl +39 -51
index 3cc0ea0..6ba0170 100644
@@ -181,57 +181,45 @@ DefinitionBlock (
 
     Scope(\_SB) {
         Scope(PCI0) {
-            Name(_PRT, Package() {
-                /* PCI IRQ routing table, example from ACPI 2.0a specification,
-                   section 6.2.8.1 */
-                /* Note: we provide the same info as the PCI routing
-                   table of the Bochs BIOS */
-
-#define prt_slot(nr, lnk0, lnk1, lnk2, lnk3) \
-    Package() { nr##ffff, 0, lnk0, 0 }, \
-    Package() { nr##ffff, 1, lnk1, 0 }, \
-    Package() { nr##ffff, 2, lnk2, 0 }, \
-    Package() { nr##ffff, 3, lnk3, 0 }
-
-#define prt_slot0(nr) prt_slot(nr, LNKD, LNKA, LNKB, LNKC)
-#define prt_slot1(nr) prt_slot(nr, LNKA, LNKB, LNKC, LNKD)
-#define prt_slot2(nr) prt_slot(nr, LNKB, LNKC, LNKD, LNKA)
-#define prt_slot3(nr) prt_slot(nr, LNKC, LNKD, LNKA, LNKB)
-
-                prt_slot0(0x0000),
-                /* Device 1 is power mgmt device, and can only use irq 9 */
-                prt_slot(0x0001, LNKS, LNKB, LNKC, LNKD),
-                prt_slot2(0x0002),
-                prt_slot3(0x0003),
-                prt_slot0(0x0004),
-                prt_slot1(0x0005),
-                prt_slot2(0x0006),
-                prt_slot3(0x0007),
-                prt_slot0(0x0008),
-                prt_slot1(0x0009),
-                prt_slot2(0x000a),
-                prt_slot3(0x000b),
-                prt_slot0(0x000c),
-                prt_slot1(0x000d),
-                prt_slot2(0x000e),
-                prt_slot3(0x000f),
-                prt_slot0(0x0010),
-                prt_slot1(0x0011),
-                prt_slot2(0x0012),
-                prt_slot3(0x0013),
-                prt_slot0(0x0014),
-                prt_slot1(0x0015),
-                prt_slot2(0x0016),
-                prt_slot3(0x0017),
-                prt_slot0(0x0018),
-                prt_slot1(0x0019),
-                prt_slot2(0x001a),
-                prt_slot3(0x001b),
-                prt_slot0(0x001c),
-                prt_slot1(0x001d),
-                prt_slot2(0x001e),
-                prt_slot3(0x001f),
-            })
+            Method (_PRT, 0) {
+                Store(Package(128) {}, Local0)
+                Store(Zero, Local1)
+                While(LLess(Local1, 128)) {
+                    // slot = pin >> 2
+                    Store(ShiftRight(Local1, 2), Local2)
+
+                    // lnk = (slot + pin) & 3
+                    Store(And(Add(Local1, Local2), 3), Local3)
+                    If (LEqual(Local3, 0)) {
+                        Store(Package(4) { Zero, Zero, LNKD, Zero }, Local4)
+                    }
+                    If (LEqual(Local3, 1)) {
+                        // device 1 is the power-management device, needs SCI
+                        If (LEqual(Local1, 4)) {
+                            Store(Package(4) { Zero, Zero, LNKS, Zero }, Local4)
+                        } Else {
+                            Store(Package(4) { Zero, Zero, LNKA, Zero }, Local4)
+                        }
+                    }
+                    If (LEqual(Local3, 2)) {
+                        Store(Package(4) { Zero, Zero, LNKB, Zero }, Local4)
+                    }
+                    If (LEqual(Local3, 3)) {
+                        Store(Package(4) { Zero, Zero, LNKC, Zero }, Local4)
+                    }
+
+                    // Complete the interrupt routing entry:
+                    //    Package(4) { 0x[slot]FFFF, [pin], [link], 0) }
+
+                    Store(Or(ShiftLeft(Local2, 16), 0xFFFF), Index(Local4, 0))
+                    Store(And(Local1, 3),                    Index(Local4, 1))
+                    Store(Local4,                            Index(Local0, Local1))
+
+                    Increment(Local1)
+                }
+
+                Return(Local0)
+            }
         }
 
         Field(PCI0.ISA.P40C, ByteAcc, NoLock, Preserve) {
hw/i386/acpi-dsdt.hex.generated +109 -1801

2,005 lines not on this page · raw message

tests/acpi-test-data/pc/DSDT binary +0 -0
index 7ed03fd37effb1b0b2c19f49b5cbff168a29f9bc..d37ec34454e6f3db5e91b777f94e03be67a5f583 100644
GIT binary patch
Signature · 1 line
MST
#2 lore raw

[Qemu-devel] [PULL 2/8] pc: hack for migration compatibility from QEMU 2.0

In reply to Michael S. Tsirkin

From: Paolo Bonzini <[email protected]>

Changing the ACPI table size causes migration to break, and the memory hotplug work opened our eyes on how horribly we were breaking things in 2.0 already.

The ACPI table size is rounded to the next 4k, which one would think gives some headroom. In practice this is not the case, because the user can control the ACPI table size (each CPU adds 97 bytes to the SSDT and 8 to the MADT) and so some "-smp" values will break the 4k boundary and fail to migrate. Similarly, PCI bridges add ~1870 bytes to the SSDT.

This patch concerns itself with fixing migration from QEMU 2.0. It computes the payload size of QEMU 2.0 and always uses that one. The previous patch shrunk the ACPI tables enough that the QEMU 2.0 size should always be enough; non-AML tables can change depending on the configuration (especially MADT, SRAT, HPET) but they remain the same between QEMU 2.0 and 2.1, so we only compute our padding based on the sizes of the SSDT and DSDT.

Migration from QEMU 1.7 should work for guests that have a number of CPUs other than 12, 13, 14, 54, 55, 56, 97, 98, 139, 140. It was already broken from QEMU 1.7 to QEMU 2.0 in the same way, though.

Even with this patch, QEMU 1.7 and 2.0 have two different ideas of "-M pc-i440fx-2.0" when there are PCI bridges. Igor sent a patch to adopt the QEMU 1.7 definition. I think distributions should apply it if they move directly from QEMU 1.7 to 2.1+ without ever packaging version 2.0.

---
 include/hw/i386/pc.h |  1 +
 hw/i386/acpi-build.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++----
 hw/i386/pc_piix.c    | 19 ++++++++++++++++++
 hw/i386/pc_q35.c     |  5 +++++
 4 files changed, 78 insertions(+), 4 deletions(-)
include/hw/i386/pc.h +1 -0
index 1c0c382..f4b9b2b 100644
@@ -94,6 +94,7 @@ struct PcGuestInfo {
     uint64_t *node_mem;
     uint64_t *node_cpu;
     FWCfgState *fw_cfg;
+    int legacy_acpi_table_size;
     bool has_acpi_build;
     bool has_reserved_memory;
 };
hw/i386/acpi-build.c +53 -4

106 lines not on this page · raw message

hw/i386/pc_piix.c +19 -0
index 7081c08..4524e6b 100644
@@ -61,6 +61,7 @@ static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
 
 static bool has_pci_info;
 static bool has_acpi_build = true;
+static int legacy_acpi_table_size;
 static bool smbios_defaults = true;
 static bool smbios_legacy_mode;
 /* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
@@ -163,6 +164,7 @@ static void pc_init1(MachineState *machine,
     guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
 
     guest_info->has_acpi_build = has_acpi_build;
+    guest_info->legacy_acpi_table_size = legacy_acpi_table_size;
 
     guest_info->has_pci_info = has_pci_info;
     guest_info->isapc_ram_fw = !pci_enabled;
@@ -297,6 +299,23 @@ static void pc_init_pci(MachineState *machine)
 
 static void pc_compat_2_0(MachineState *machine)
 {
+    /* This value depends on the actual DSDT and SSDT compiled into
+     * the source QEMU; unfortunately it depends on the binary and
+     * not on the machine type, so we cannot make pc-i440fx-1.7 work on
+     * both QEMU 1.7 and QEMU 2.0.
+     *
+     * Large variations cause migration to fail for more than one
+     * consecutive value of the "-smp" maxcpus option.
+     *
+     * For small variations of the kind caused by different iasl versions,
+     * the 4k rounding usually leaves slack.  However, there could be still
+     * one or two values that break.  For QEMU 1.7 and QEMU 2.0 the
+     * slack is only ~10 bytes before one "-smp maxcpus" value breaks!
+     *
+     * 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on
+     * QEMU 1.7 it is 6414.  For RHEL/CentOS 7.0 it is 6418.
+     */
+    legacy_acpi_table_size = 6652;
     smbios_legacy_mode = true;
     has_reserved_memory = false;
 }
hw/i386/pc_q35.c +5 -0
index f551961..c39ee98 100644
@@ -155,6 +155,11 @@ static void pc_q35_init(MachineState *machine)
     guest_info->has_acpi_build = has_acpi_build;
     guest_info->has_reserved_memory = has_reserved_memory;
 
+    /* Migration was not supported in 2.0 for Q35, so do not bother
+     * with this hack (see hw/i386/acpi-build.c).
+     */
+    guest_info->legacy_acpi_table_size = 0;
+
     if (smbios_defaults) {
         MachineClass *mc = MACHINE_GET_CLASS(machine);
         /* These values are guest ABI, do not change */
Signature · 1 line
MST
#3 lore raw

[Qemu-devel] [PULL 3/8] bios-tables-test: fix ASL normalization false positive

In reply to Michael S. Tsirkin

From: Paolo Bonzini <[email protected]>

My version of IASL (from RHEL7) puts two newlines between the head comment and the DefinitionBlock property. Kill all newlines after the comment, so that normalize_asl works properly.

---
 tests/bios-tables-test.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tests/bios-tables-test.c +5 -1
index 62771f7..045eb27 100644
@@ -487,7 +487,11 @@ static GString *normalize_asl(gchar *asl_code)
     /* strip comments (different generation days) */
     comment = g_strstr_len(asl->str, asl->len, COMMENT_END);
     if (comment) {
-        asl = g_string_erase(asl, 0, comment + sizeof(COMMENT_END) - asl->str);
+        comment += strlen(COMMENT_END);
+        while (*comment == '\n') {
+            comment++;
+        }
+        asl = g_string_erase(asl, 0, comment - asl->str);
     }
 
     /* strip def block name (it has file path in it) */
Signature · 1 line
MST
#4 lore raw

[Qemu-devel] [PULL 4/8] pc: acpi: generate AML only for PCI0 devices if PCI bridge hotplug is disabled

In reply to Michael S. Tsirkin

From: Igor Mammedov <[email protected]>

Fixes migration regression from QEMU-1.7 to a newer QEMUs. SSDT table size in QEMU-1.7 doesn't change regardless of a number of PCI bridge devices present at startup.

However in QEMU-2.0 since addition of hotplug on PCI bridges, each PCI bridge adds ~1875 bytes to SSDT table, including pc-i440fx-1.7 machine type where PCI bridge hotplug disabled via compat property.
It breaks migration from "QEMU-1.7" to "QEMU-2.[01] -M pc-i440fx-1.7" since RAMBlock size of ACPI tables on target becomes larger then on source and migration fails with:

"Length mismatch: /rom@etc/acpi/tables: 2000 in != 3000"

error.

Fix this by generating AML only for PCI0 bus if hotplug on PCI bridges is disabled and preserves PCI brigde description in AML as it was done in QEMU-1.7 for pc-i440fx-1.7.

It will help to maintain size of SSDT static regardless of number of PCI bridges on startup for pc-i440fx-1.7 machine type.

---
 hw/i386/acpi-build.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)
hw/i386/acpi-build.c +21 -5
index d90c471..779160f 100644
@@ -74,6 +74,7 @@ typedef struct AcpiMcfgInfo {
 typedef struct AcpiPmInfo {
     bool s3_disabled;
     bool s4_disabled;
+    bool pcihp_bridge_en;
     uint8_t s4_val;
     uint16_t sci_int;
     uint8_t acpi_enable_cmd;
@@ -95,6 +96,7 @@ typedef struct AcpiBuildPciBusHotplugState {
     GArray *device_table;
     GArray *notify_table;
     struct AcpiBuildPciBusHotplugState *parent;
+    bool pcihp_bridge_en;
 } AcpiBuildPciBusHotplugState;
 
 static void acpi_get_dsdt(AcpiMiscInfo *info)
@@ -198,6 +200,9 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)
                                            NULL);
     pm->gpe0_blk_len = object_property_get_int(obj, ACPI_PM_PROP_GPE0_BLK_LEN,
                                                NULL);
+    pm->pcihp_bridge_en =
+        object_property_get_bool(obj, "acpi-pci-hotplug-with-bridge-support",
+                                 NULL);
 }
 
 static void acpi_get_misc_info(AcpiMiscInfo *info)
@@ -778,11 +783,13 @@ static void acpi_set_pci_info(void)
 }
 
 static void build_pci_bus_state_init(AcpiBuildPciBusHotplugState *state,
-                                     AcpiBuildPciBusHotplugState *parent)
+                                     AcpiBuildPciBusHotplugState *parent,
+                                     bool pcihp_bridge_en)
 {
     state->parent = parent;
     state->device_table = build_alloc_array();
     state->notify_table = build_alloc_array();
+    state->pcihp_bridge_en = pcihp_bridge_en;
 }
 
 static void build_pci_bus_state_cleanup(AcpiBuildPciBusHotplugState *state)
@@ -796,7 +803,7 @@ static void *build_pci_bus_begin(PCIBus *bus, void *parent_state)
     AcpiBuildPciBusHotplugState *parent = parent_state;
     AcpiBuildPciBusHotplugState *child = g_malloc(sizeof *child);
 
-    build_pci_bus_state_init(child, parent);
+    build_pci_bus_state_init(child, parent, parent->pcihp_bridge_en);
 
     return child;
 }
@@ -817,6 +824,14 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
     GArray *method;
     bool bus_hotplug_support = false;
 
+    /*
+        skip bridge subtree creation if bridge hotplug is disabled
+        to make it compatible with 1.7 machine type
+    */
+    if (!child->pcihp_bridge_en && bus->parent_dev) {
+        return;
+    }
+
     if (bus->parent_dev) {
         op = 0x82; /* DeviceOp */
         build_append_nameseg(bus_table, "S%.02X_",
@@ -863,7 +878,8 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
         pc = PCI_DEVICE_GET_CLASS(pdev);
         dc = DEVICE_GET_CLASS(pdev);
 
-        if (pc->class_id == PCI_CLASS_BRIDGE_ISA || pc->is_bridge) {
+        if (pc->class_id == PCI_CLASS_BRIDGE_ISA ||
+            (pc->is_bridge && child->pcihp_bridge_en)) {
             set_bit(slot, slot_device_system);
         }
 
@@ -875,7 +891,7 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
             }
         }
 
-        if (!dc->hotpluggable || pc->is_bridge) {
+        if (!dc->hotpluggable || (pc->is_bridge && child->pcihp_bridge_en)) {
             clear_bit(slot, slot_hotplug_enable);
         }
     }
@@ -1140,7 +1156,7 @@ build_ssdt(GArray *table_data, GArray *linker,
                 bus = PCI_HOST_BRIDGE(pci_host)->bus;
             }
 
-            build_pci_bus_state_init(&hotplug_state, NULL);
+            build_pci_bus_state_init(&hotplug_state, NULL, pm->pcihp_bridge_en);
 
             if (bus) {
                 /* Scan all PCI buses. Generate tables to support hotplug. */
Signature · 1 line
MST
#5 lore raw

[Qemu-devel] [PULL 5/8] acpi-build: minor code cleanup

In reply to Michael S. Tsirkin

Fix up and add comments to clarify code, plus a trivial code change for clarity.

---
 hw/i386/acpi-build.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
hw/i386/acpi-build.c +12 -6
index 779160f..ec86f1b 100644
@@ -825,9 +825,9 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
     bool bus_hotplug_support = false;
 
     /*
-        skip bridge subtree creation if bridge hotplug is disabled
-        to make it compatible with 1.7 machine type
-    */
+     * Skip bridge subtree creation if bridge hotplug is disabled
+     * to make acpi tables compatible with legacy machine types.
+     */
     if (!child->pcihp_bridge_en && bus->parent_dev) {
         return;
     }
@@ -869,6 +869,7 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
         PCIDeviceClass *pc;
         PCIDevice *pdev = bus->devices[i];
         int slot = PCI_SLOT(i);
+        bool bridge_in_acpi;
 
         if (!pdev) {
             continue;
@@ -878,8 +879,13 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
         pc = PCI_DEVICE_GET_CLASS(pdev);
         dc = DEVICE_GET_CLASS(pdev);
 
-        if (pc->class_id == PCI_CLASS_BRIDGE_ISA ||
-            (pc->is_bridge && child->pcihp_bridge_en)) {
+        /* When hotplug for bridges is enabled, bridges are
+         * described in ACPI separately (see build_pci_bus_end).
+         * In this case they aren't themselves hot-pluggable.
+         */
+        bridge_in_acpi = pc->is_bridge && child->pcihp_bridge_en;
+
+        if (pc->class_id == PCI_CLASS_BRIDGE_ISA || bridge_in_acpi) {
             set_bit(slot, slot_device_system);
         }
 
@@ -891,7 +897,7 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state)
             }
         }
 
-        if (!dc->hotpluggable || (pc->is_bridge && child->pcihp_bridge_en)) {
+        if (!dc->hotpluggable || bridge_in_acpi) {
             clear_bit(slot, slot_hotplug_enable);
         }
     }
Signature · 1 line
MST
#6 lore raw

[Qemu-devel] [PULL 6/8] pc: future-proof migration-compatibility of ACPI tables

In reply to Michael S. Tsirkin

From: Paolo Bonzini <[email protected]>

This patch avoids that similar changes break QEMU again in the future. QEMU will now hard-code 64k as the maximum ACPI table size, which (despite being an order of magnitude smaller than 640k) should be enough for everyone.

---
 hw/i386/acpi-build.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
hw/i386/acpi-build.c +9 -1
index ec86f1b..2178894 100644
@@ -62,6 +62,8 @@
 #define ACPI_BUILD_LEGACY_CPU_AML_SIZE    97
 #define ACPI_BUILD_ALIGN_SIZE             0x1000
 
+#define ACPI_BUILD_TABLE_SIZE             0x10000
+
 typedef struct AcpiCpuInfo {
     DECLARE_BITMAP(found_cpus, ACPI_CPU_HOTPLUG_ID_LIMIT);
 } AcpiCpuInfo;
@@ -1588,7 +1590,13 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
         }
         g_array_set_size(tables->table_data, legacy_table_size);
     } else {
-        acpi_align_size(tables->table_data, ACPI_BUILD_ALIGN_SIZE);
+        if (tables->table_data->len > ACPI_BUILD_TABLE_SIZE) {
+            /* As of QEMU 2.1, this fires with 160 VCPUs and 255 memory slots.  */
+            error_report("ACPI tables are larger than 64k.  Please remove");
+            error_report("CPUs, NUMA nodes, memory slots or PCI bridges.");
+            exit(1);
+        }
+        g_array_set_size(tables->table_data, ACPI_BUILD_TABLE_SIZE);
     }
 
     acpi_align_size(tables->linker, ACPI_BUILD_ALIGN_SIZE);
Signature · 1 line
MST
#7 lore raw

[Qemu-devel] [PULL 7/8] acpi-build: tweak acpi migration limits

In reply to Michael S. Tsirkin

- Tweak error message for legacy machine type:
Basically if table size exceeds the limits we set all bets are off for migration: e.g. it can start failing even within given qemu minor version simply because of a bugfix.
- Increase table size to 128k.
- Make sure we notice it long before we start getting close to the 128k limit: warn at 64k.
- Don't fail if we exceed the limit: most people don't care about migration, even less people care about cross version miration.

---
 hw/i386/acpi-build.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
hw/i386/acpi-build.c +9 -7
index 2178894..816c6d9 100644
@@ -62,7 +62,7 @@
 #define ACPI_BUILD_LEGACY_CPU_AML_SIZE    97
 #define ACPI_BUILD_ALIGN_SIZE             0x1000
 
-#define ACPI_BUILD_TABLE_SIZE             0x10000
+#define ACPI_BUILD_TABLE_SIZE             0x20000
 
 typedef struct AcpiCpuInfo {
     DECLARE_BITMAP(found_cpus, ACPI_CPU_HOTPLUG_ID_LIMIT);
@@ -1586,17 +1586,19 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
                      ACPI_BUILD_ALIGN_SIZE);
         if (tables->table_data->len > legacy_table_size) {
             /* Should happen only with PCI bridges and -M pc-i440fx-2.0.  */
-            error_report("Warning: migration to QEMU 2.0 may not work.");
+            error_report("Warning: migration may not work.");
         }
         g_array_set_size(tables->table_data, legacy_table_size);
     } else {
-        if (tables->table_data->len > ACPI_BUILD_TABLE_SIZE) {
+        /* Make sure we have a buffer in case we need to resize the tables. */
+        if (tables->table_data->len > ACPI_BUILD_TABLE_SIZE / 2) {
             /* As of QEMU 2.1, this fires with 160 VCPUs and 255 memory slots.  */
-            error_report("ACPI tables are larger than 64k.  Please remove");
-            error_report("CPUs, NUMA nodes, memory slots or PCI bridges.");
-            exit(1);
+            error_report("Warning: ACPI tables are larger than 64k.");
+            error_report("Warning: migration may not work.");
+            error_report("Warning: please remove CPUs, NUMA nodes, "
+                         "memory slots or PCI bridges.");
         }
-        g_array_set_size(tables->table_data, ACPI_BUILD_TABLE_SIZE);
+        acpi_align_size(tables->table_data, ACPI_BUILD_TABLE_SIZE);
     }
 
     acpi_align_size(tables->linker, ACPI_BUILD_ALIGN_SIZE);
Signature · 1 line
MST
#8 lore raw

[Qemu-devel] [PULL 8/8] piix: set legacy table size for 1.7

In reply to Michael S. Tsirkin
---
 hw/i386/pc_piix.c | 1 +
 1 file changed, 1 insertion(+)
hw/i386/pc_piix.c +1 -0
index 4524e6b..9694f88 100644
@@ -326,6 +326,7 @@ static void pc_compat_1_7(MachineState *machine)
     smbios_defaults = false;
     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);
 }
 
Signature · 1 line
MST
#9 lore raw
In reply to Michael S. Tsirkin
Quoted 30 lines · Michael S. Tsirkin

The following changes since commit c60a57ff497667780132a3fcdc1500c83af5d5c0:

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2014-07-25 16:58:41 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to f47337cb9181a1f9339b9b0516b92fe77a22f0f3:

piix: set legacy table size for 1.7 (2014-07-29 12:26:12 +0200)

----------------------------------------------------------------
pc migration fixes

Last minute fixes for migration.
It seems that if we don't fix it now, fixing it in the next version will be even more painful ...

----------------------------------------------------------------
Igor Mammedov (1):
pc: acpi: generate AML only for PCI0 devices if PCI bridge hotplug is disabled

Michael S. Tsirkin (3):
acpi-build: minor code cleanup
acpi-build: tweak acpi migration limits
piix: set legacy table size for 1.7

Quoted 5 lines

Paolo Bonzini (4):
acpi-dsdt: procedurally generate _PRT
pc: hack for migration compatibility from QEMU 2.0
bios-tables-test: fix ASL normalization false positive
pc: future-proof migration-compatibility of ACPI tables

Applied, thanks.

-- PMM