[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 28/96] acpi-build: fix ACPI RAM management
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 28/96] acpi-build: fix ACPI RAM management |
Date: |
Wed, 18 Feb 2015 22:46:50 +0100 |
This fixes multiple issues around ACPI RAM management:
RSDP and linker RAM aren't currently marked dirty
on update, so they won't be migrated correctly.
Let's handle all tables in the same way: set correct size (assert if
too big), update, mark RAM dirty.
This also drops assert checking that table size didn't change: table
size is fundamentally dynamic and depends on hw configuration,
just set the correct size and use that (memory core asserts if size is
too large).
This also means we can drop tracking table size, memory core does this
for us now.
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/i386/acpi-build.c | 43 +++++++++++++++++++++++--------------------
1 file changed, 23 insertions(+), 20 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 693f447..031f88d 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1363,13 +1363,12 @@ typedef
struct AcpiBuildState {
/* Copy of table in RAM (for patching). */
ram_addr_t table_ram;
- uint32_t table_size;
/* Is table patched? */
uint8_t patched;
PcGuestInfo *guest_info;
void *rsdp;
+ ram_addr_t rsdp_ram;
ram_addr_t linker_ram;
- uint32_t linker_size;
} AcpiBuildState;
static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
@@ -1552,6 +1551,17 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables
*tables)
g_array_free(table_offsets, true);
}
+static void acpi_ram_update(ram_addr_t ram, GArray *data)
+{
+ uint32_t size = acpi_data_len(data);
+
+ /* Make sure RAM size is correct - in case it got changed e.g. by
migration */
+ qemu_ram_resize(ram, size, &error_abort);
+
+ memcpy(qemu_get_ram_ptr(ram), data->data, size);
+ cpu_physical_memory_set_dirty_range_nocode(ram, size);
+}
+
static void acpi_build_update(void *build_opaque, uint32_t offset)
{
AcpiBuildState *build_state = build_opaque;
@@ -1567,21 +1577,15 @@ static void acpi_build_update(void *build_opaque,
uint32_t offset)
acpi_build(build_state->guest_info, &tables);
- assert(acpi_data_len(tables.table_data) == build_state->table_size);
+ acpi_ram_update(build_state->table_ram, tables.table_data);
- /* Make sure RAM size is correct - in case it got changed by migration */
- qemu_ram_resize(build_state->table_ram, build_state->table_size,
- &error_abort);
-
- memcpy(qemu_get_ram_ptr(build_state->table_ram), tables.table_data->data,
- build_state->table_size);
- memcpy(build_state->rsdp, tables.rsdp->data, acpi_data_len(tables.rsdp));
- memcpy(qemu_get_ram_ptr(build_state->linker_ram), tables.linker->data,
- build_state->linker_size);
-
- cpu_physical_memory_set_dirty_range_nocode(build_state->table_ram,
- build_state->table_size);
+ if (build_state->rsdp) {
+ memcpy(build_state->rsdp, tables.rsdp->data,
acpi_data_len(tables.rsdp));
+ } else {
+ acpi_ram_update(build_state->rsdp_ram, tables.rsdp);
+ }
+ acpi_ram_update(build_state->linker_ram, tables.linker);
acpi_build_tables_cleanup(&tables, true);
}
@@ -1642,11 +1646,9 @@ void acpi_setup(PcGuestInfo *guest_info)
ACPI_BUILD_TABLE_FILE,
ACPI_BUILD_TABLE_MAX_SIZE);
assert(build_state->table_ram != RAM_ADDR_MAX);
- build_state->table_size = acpi_data_len(tables.table_data);
build_state->linker_ram =
acpi_add_rom_blob(build_state, tables.linker, "etc/table-loader", 0);
- build_state->linker_size = acpi_data_len(tables.linker);
fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_TPMLOG_FILE,
tables.tcpalog->data, acpi_data_len(tables.tcpalog));
@@ -1661,10 +1663,11 @@ void acpi_setup(PcGuestInfo *guest_info)
acpi_build_update, build_state,
tables.rsdp->data,
acpi_data_len(tables.rsdp));
build_state->rsdp = tables.rsdp->data;
+ build_state->rsdp_ram = (ram_addr_t)-1;
} else {
- build_state->rsdp = qemu_get_ram_ptr(
- acpi_add_rom_blob(build_state, tables.rsdp, ACPI_BUILD_RSDP_FILE,
0)
- );
+ build_state->rsdp = NULL;
+ build_state->rsdp_ram = acpi_add_rom_blob(build_state, tables.rsdp,
+ ACPI_BUILD_RSDP_FILE, 0);
}
qemu_register_reset(acpi_build_reset, build_state);
--
MST
- [Qemu-devel] [PULL 18/96] acpi, ich9: Add hotunplug request cb for ich9., (continued)
- [Qemu-devel] [PULL 18/96] acpi, ich9: Add hotunplug request cb for ich9., Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 19/96] acpi, pc: Add unplug cb for pc machine., Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 20/96] acpi, ich9: Add unplug cb for ich9., Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 21/96] acpi, piix4: Add unplug cb for piix4., Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 22/96] vl.c: Fix error messages when parsing maxmem parameters, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 23/96] pc: memory: Validate alignment of maxram_size to page size, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 24/96] acpi: update RSDP on guest access, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 25/96] pc: acpi-build: update linker on guest access, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 26/96] pc: acpi-build: migrate RSDP table, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 27/96] exec: round up size on MR resize, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 28/96] acpi-build: fix ACPI RAM management,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 29/96] acpi: has_immutable_rsdp->!rsdp_in_ram, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 30/96] acpi-build: simplify rsdp management for legacy, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 31/96] scripts/update-linux-headers.sh: pull virtio hdrs, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 32/96] include: import virtio headers from linux 4.0, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 35/96] virtio-balloon: use standard headers, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 33/96] virtio: use standard virtio_ring.h, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 34/96] virtio: use standard-headers, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 36/96] virtio-9p: use standard headers, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 37/96] virtio-blk: switch to standard-headers, Michael S. Tsirkin, 2015/02/18
- [Qemu-devel] [PULL 38/96] virtio-net,tap: use standard-headers, Michael S. Tsirkin, 2015/02/18