From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YgCPh-0002il-Hw for qemu-devel@nongnu.org; Thu, 09 Apr 2015 09:22:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YgCPd-0003b6-HJ for qemu-devel@nongnu.org; Thu, 09 Apr 2015 09:22:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41380) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YgCPd-0003at-9c for qemu-devel@nongnu.org; Thu, 09 Apr 2015 09:22:29 -0400 Date: Thu, 9 Apr 2015 15:17:18 +0200 From: Igor Mammedov Message-ID: <20150409151718.5eb49015@nial.brq.redhat.com> In-Reply-To: <877ftl1n4j.fsf@linaro.org> References: <1428055432-12120-1-git-send-email-zhaoshenglong@huawei.com> <1428055432-12120-11-git-send-email-zhaoshenglong@huawei.com> <877ftl1n4j.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: Alex =?UTF-8?B?QmVubsOpZQ==?= 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, Shannon Zhao , pbonzini@redhat.com, lersek@redhat.com, christoffer.dall@linaro.org, shannon.zhao@linaro.org On Thu, 09 Apr 2015 13:50:52 +0100 Alex Benn=C3=A9e wrote: >=20 > Shannon Zhao writes: >=20 > > 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, > > } > > } > > =20 > > +/* RSDT */ > > +static void > > +build_rsdt(GArray *table_data, GArray *linker, GArray *table_offsets) this function looks like exact copy of x86 impl., could you reuse that? > > +{ > > + AcpiRsdtDescriptorRev1 *rsdt; > > + size_t rsdt_len; > > + int i; > > + > > + rsdt_len =3D sizeof(*rsdt) + sizeof(uint32_t) * table_offsets->len; >=20 > You should use explicit brackets to be unambiguous: >=20 > rsdt_len =3D sizeof(*rsdt) + (sizeof(uint32_t) * table_offsets->le= n); >=20 > > + rsdt =3D acpi_data_push(table_data, rsdt_len); > > + memcpy(rsdt->table_offset_entry, table_offsets->data, > > + sizeof(uint32_t) * table_offsets->len); >=20 > Or perhaps split the sizes: >=20 > const int table_data_len =3D (sizeof(uint32_t) * table_offsets->len); >=20 > rsdt_len =3D sizeof(*rsdt) + table_data_len; > rsdt =3D acpi_data_push(table_data, rsdt_len); > memcpy(rsdt->table_offset_entry, table_offsets->data, table_data_len) >=20 > Maybe? >=20 > > + for (i =3D 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)); >=20 > Why are these pointers always 32 bit? Can they ever be 64 bit? Laszlo, can you confirm that UEFI puts APCI tables below 4G address space? >=20 > > + } > > + build_header(linker, table_data, > > + (void *)rsdt, "RSDT", rsdt_len, 1); > > +} > > + > > /* GTDT */ > > static void > > build_gtdt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_in= fo) > > @@ -348,6 +372,9 @@ void virt_acpi_build(VirtGuestInfo *guest_info, Acp= iBuildTables *tables) > > acpi_add_table(table_offsets, tables_blob); > > build_gtdt(tables_blob, tables->linker, guest_info); > > =20 > > + /* 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); > > } >=20