Received: from eggs.gnu.org ([2001:4830:134:3::10]:54056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNixA-00039Y-SN for qemu-devel@nongnu.org; Tue, 17 Feb 2015 09:16:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YNix6-0005jB-Eg for qemu-devel@nongnu.org; Tue, 17 Feb 2015 09:16:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58263) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNix6-0005hh-7G for qemu-devel@nongnu.org; Tue, 17 Feb 2015 09:16:40 -0500 Date: Tue, 17 Feb 2015 15:16:35 +0100 From: Igor Mammedov Message-ID: <20150217151635.485660e3@nial.brq.redhat.com> In-Reply-To: <1424167517-21866-5-git-send-email-mst@redhat.com> References: <1424167517-21866-1-git-send-email-mst@redhat.com> <1424167517-21866-5-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 4/4] acpi-build: simplify rsdp management for legacy List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, Anthony Liguori , Richard Henderson On Tue, 17 Feb 2015 11:05:45 +0100 "Michael S. Tsirkin" wrote: > 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 Reviewed-by: Igor Mammedov > --- > hw/i386/acpi-build.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c > index ffa3f00..f712277 100644 > --- a/hw/i386/acpi-build.c > +++ b/hw/i386/acpi-build.c > @@ -1257,7 +1257,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); > } > @@ -1560,12 +1560,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;