From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YgBv1-0006Am-4S for qemu-devel@nongnu.org; Thu, 09 Apr 2015 08:50:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YgBuu-0007dQ-OH for qemu-devel@nongnu.org; Thu, 09 Apr 2015 08:50:50 -0400 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:36827 helo=socrates.bennee.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YgBuu-0007dA-IL for qemu-devel@nongnu.org; Thu, 09 Apr 2015 08:50:44 -0400 References: <1428055432-12120-1-git-send-email-zhaoshenglong@huawei.com> <1428055432-12120-11-git-send-email-zhaoshenglong@huawei.com> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <1428055432-12120-11-git-send-email-zhaoshenglong@huawei.com> Date: Thu, 09 Apr 2015 13:50:52 +0100 Message-ID: <877ftl1n4j.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v4 10/20] hw/arm/virt-acpi-build: Generate RSDT table List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Shannon Zhao Cc: peter.maydell@linaro.org, hangaohuai@huawei.com, mst@redhat.com, a.spyridakis@virtualopensystems.com, msalter@redhat.com, claudio.fontana@huawei.com, qemu-devel@nongnu.org, peter.huangpeng@huawei.com, hanjun.guo@linaro.org, imammedo@redhat.com, pbonzini@redhat.com, lersek@redhat.com, christoffer.dall@linaro.org, shannon.zhao@linaro.org Shannon Zhao writes: > From: Shannon Zhao > > RSDT points to other tables FADT, MADT, GTDT. > > Signed-off-by: Shannon Zhao > Signed-off-by: Shannon Zhao > --- > hw/arm/virt-acpi-build.c | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c > index a7aba75..85e84b1 100644 > --- a/hw/arm/virt-acpi-build.c > +++ b/hw/arm/virt-acpi-build.c > @@ -176,6 +176,30 @@ static void acpi_dsdt_add_virtio(Aml *scope, const hwaddr *mmio_addrs, > } > } > > +/* RSDT */ > +static void > +build_rsdt(GArray *table_data, GArray *linker, GArray *table_offsets) > +{ > + AcpiRsdtDescriptorRev1 *rsdt; > + size_t rsdt_len; > + int i; > + > + rsdt_len = sizeof(*rsdt) + sizeof(uint32_t) * table_offsets->len; You should use explicit brackets to be unambiguous: rsdt_len = sizeof(*rsdt) + (sizeof(uint32_t) * table_offsets->len); > + rsdt = acpi_data_push(table_data, rsdt_len); > + memcpy(rsdt->table_offset_entry, table_offsets->data, > + sizeof(uint32_t) * table_offsets->len); Or perhaps split the sizes: const int table_data_len = (sizeof(uint32_t) * table_offsets->len); rsdt_len = sizeof(*rsdt) + table_data_len; rsdt = acpi_data_push(table_data, rsdt_len); memcpy(rsdt->table_offset_entry, table_offsets->data, table_data_len) Maybe? > + for (i = 0; i < table_offsets->len; ++i) { > + /* rsdt->table_offset_entry to be filled by Guest linker */ > + bios_linker_loader_add_pointer(linker, > + ACPI_BUILD_TABLE_FILE, > + ACPI_BUILD_TABLE_FILE, > + table_data, &rsdt->table_offset_entry[i], > + sizeof(uint32_t)); Why are these pointers always 32 bit? Can they ever be 64 bit? > + } > + build_header(linker, table_data, > + (void *)rsdt, "RSDT", rsdt_len, 1); > +} > + > /* GTDT */ > static void > build_gtdt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info) > @@ -348,6 +372,9 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables) > acpi_add_table(table_offsets, tables_blob); > build_gtdt(tables_blob, tables->linker, guest_info); > > + /* RSDT is pointed to by RSDP */ > + build_rsdt(tables_blob, tables->linker, table_offsets); > + > /* Cleanup memory that's no longer used. */ > g_array_free(table_offsets, true); > } -- Alex Bennée