qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

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>


+6 -4
+6 -4
hw/i386/acpi-build.c
··· 1354 1354 { 1355 1355 void *linker_data = bios_linker_loader_cleanup(tables->linker); 1356 1356 g_free(linker_data); 1357 - g_array_free(tables->rsdp, mfre); 1357 + g_array_free(tables->rsdp, true); 1358 1358 g_array_free(tables->table_data, true); 1359 1359 g_array_free(tables->tcpalog, mfre); 1360 1360 } ··· 1657 1657 /* 1658 1658 * Keep for compatibility with old machine types. 1659 1659 * Though RSDP is small, its contents isn't immutable, so 1660 - * update it along with the rest of tables on guest access. 1660 + * we'll update it along with the rest of tables on guest access. 1661 1661 */ 1662 + uint32_t rsdp_size = acpi_data_len(tables.rsdp); 1663 + 1664 + build_state->rsdp = g_memdup(tables.rsdp->data, rsdp_size); 1662 1665 fw_cfg_add_file_callback(guest_info->fw_cfg, ACPI_BUILD_RSDP_FILE, 1663 1666 acpi_build_update, build_state, 1664 - tables.rsdp->data, acpi_data_len(tables.rsdp)); 1665 - build_state->rsdp = tables.rsdp->data; 1667 + build_state->rsdp, rsdp_size); 1666 1668 build_state->rsdp_ram = (ram_addr_t)-1; 1667 1669 } else { 1668 1670 build_state->rsdp = NULL;