summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2015-02-17 10:40:30 +0100
committerMichael S. Tsirkin <mst@redhat.com>2015-02-26 12:42:20 +0100
commitafaa2e4bc4e17360307cb86fbb1d5d350ae22961 (patch)
treea31c02a0706a5e15249f8f9bed95b1019578212a
parent384fb32ea7984ed6e5fdcea0bbc3d5b01238806b (diff)
downloadfocaccia-qemu-afaa2e4bc4e17360307cb86fbb1d5d350ae22961.tar.gz
focaccia-qemu-afaa2e4bc4e17360307cb86fbb1d5d350ae22961.zip
acpi-build: simplify rsdp management for legacy
For legacy machine types, rsdp is not in RAM, so we need a copy of rsdp
for fw cfg. We previously used g_array_free with false parameter,
but this seems to confuse people.
This also wastes a bit of memory as the buffer is unused for new
machine types.

Let's just use plain g_memdup, and free original memory together with
the array.

TODO: rationalize tcpalog memory management, and get rid of the mfre
parameter.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>


-rw-r--r--hw/i386/acpi-build.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 409229f602..9b11c927b5 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1354,7 +1354,7 @@ static inline void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre)
 {
     void *linker_data = bios_linker_loader_cleanup(tables->linker);
     g_free(linker_data);
-    g_array_free(tables->rsdp, mfre);
+    g_array_free(tables->rsdp, true);
     g_array_free(tables->table_data, true);
     g_array_free(tables->tcpalog, mfre);
 }
@@ -1657,12 +1657,14 @@ void acpi_setup(PcGuestInfo *guest_info)
         /*
          * Keep for compatibility with old machine types.
          * Though RSDP is small, its contents isn't immutable, so
-         * update it along with the rest of tables on guest access.
+         * we'll update it along with the rest of tables on guest access.
          */
+        uint32_t rsdp_size = acpi_data_len(tables.rsdp);
+
+        build_state->rsdp = g_memdup(tables.rsdp->data, rsdp_size);
         fw_cfg_add_file_callback(guest_info->fw_cfg, ACPI_BUILD_RSDP_FILE,
                                  acpi_build_update, build_state,
-                                 tables.rsdp->data, acpi_data_len(tables.rsdp));
-        build_state->rsdp = tables.rsdp->data;
+                                 build_state->rsdp, rsdp_size);
         build_state->rsdp_ram = (ram_addr_t)-1;
     } else {
         build_state->rsdp = NULL;